Skip to content
Snippets Groups Projects
Commit ae87865b authored by nimrod's avatar nimrod
Browse files

Merge branch 'master' of /home/nimrod/Documents/Shore/Ansible/example

# Conflicts:
#	README.rst
#	defaults/main.yml
#	handlers/main.yml
#	meta/main.yml
#	tasks/main.yml
#	vars/main.yml
parents 36d4e542 4132c3f9
Branches
No related tags found
No related merge requests found
- repo: https://github.com/pre-commit/pre-commit-hooks
sha: 6dfcb89af3c9b4d172cc2e5a8a2fa0f54615a338
sha: 7539d8bd1a00a3c1bfd34cdb606d3a6372e83469
hooks:
- id: check-added-large-files
- id: check-json
- id: check-xml
- id: check-yaml
- id: check-merge-conflict
- repo: https://www.shore.co.il/git/ansible-pre-commit/
sha: 94b506c144d4e22ebc1deef637a818db13bcaca5
- id: flake8
- id: check-symlinks
- repo: https://github.com/adarnimrod/ansible-pre-commit.git
sha: 0fadd691465b97db8992cfc66650f630e433324b
hooks:
- id: ansible-pre-commit
- id: ansible-syntax-check
always_run: true
files: tests/playbook.yml
args:
- tests/playbook.yml
- repo: https://github.com/willthames/ansible-lint
sha: 959ab0f525e9abb19cf75f34381015cf33695f61
hooks:
- id: ansible-lint
always_run: true
files: tests/playbook.yml
args:
- tests/playbook.yml
- repo: local
hooks:
- id: piprot
name: piprot
description: Check up-to-date Python requirements
language: system
entry: piprot --quiet --outdated tests/requirements.txt
files: requirements.txt
always_run: true
---
language: python
python: "2.7"
dist: trusty
sudo: false
group: beta
services: [docker]
cache:
- pip
- directories:
- $HOME/.pre-commit
- $HOME/virtualenv
install:
- pip install -r tests/requirements.txt | cat
- ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
- molecule dependency
script:
- pre-commit run --all-files
- molecule test --driver docker
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
email: false
Gitolite
################
########
An Ansible role for provisioning gitolite and a readonly cgit web interface
(served by Apache).
.. image:: https://travis-ci.org/adarnimrod/gitolite.svg?branch=master
:target: https://travis-ci.org/adarnimrod/gitolite
Provision Gitolite and a readonly cgit web interface served by Apache.
Requirements
------------
See :code:`meta/main.yml` and assertions at top of :code:`tasks/main.yml`.
See :code:`meta/main.yml` and assertions at the top of :code:`tasks/main.yml`.
Role Variables
--------------
......@@ -27,17 +29,22 @@ See :code:`tests/playbook.yml`.
Testing
-------
To install the dependencies:
Testing requires Python 2.7 and either Docker or Vagrant and Virtualbox.
Install the Python dependencies, dependent roles and roles required for
testing:
.. code:: shell
pip install -r tests/requirements.txt
ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
molecule dependency
To run the full test suite:
.. code:: shell
molecule test
pre-commit run --all-files
molecule test --platform all
License
-------
......@@ -62,7 +69,6 @@ TODO
- Include dependencies in `meta/main.yml` and test.
- Log to syslog.
- Metrics?
- Rebase on ansible-role-example.
- Flush handlers and wait for service to come up.
- Add mail alias.
- Remove dependency on the common role, use specific roles.
......
[defaults]
library = library
host_key_checking = False
retry_files_enabled = False
roles_path = roles:../:../../:.molecule/roles
roles_path = .molecule/roles:.molecule/../roles:../:../../
command_warnings = True
deprecation_warnings = True
[ssh_connection]
pipelining = True
---
# defaults file for ansible-role-gitolite
# defaults file for gitolite
# Content of the SSH public key for the gitolite admin account.
gitolite_public_key:
---
# handlers file for ansible-role-gitolite
# handlers file for gitolite
---
galaxy_info:
author: Nimrod Adar
description: Gitolite installation
description: Provision Gitolite and a readonly cgit web interface served by Apache
company: Shore technologies
license: MIT
min_ansible_version: 2.0
......@@ -9,7 +9,11 @@ galaxy_info:
- name: Debian
versions:
- jessie
- name: Ubuntu
versions:
- trusty
- xenial
galaxy_tags: [ git, scm, gitolite ]
dependencies:
- role: common
- role: apache
- name: adarnimrod.apache
src: adarnimrod.apache
---
ansible:
verbose: v
verbose: vv
playbook: tests/playbook.yml
diff: True
config_file: ../ansible.cfg
molecule:
testinfra_dir: tests
ansible_config_template: ansible.cfg
dependency:
name: galaxy
requirements_file: tests/requirements.yml
vagrant:
providers:
......@@ -14,9 +15,15 @@ vagrant:
type: virtualbox
platforms:
- name: openbsd
box: kaorimatz/openbsd-5.9-amd64
box: kaorimatz/openbsd-6.0-amd64
- name: jessie
box: debian/jessie64
- name: trusty
box: ubuntu/trusty64
- name: xenial
box: ubuntu/xenial64
instances:
- name: ansible-role-example
- name: gitolite
options:
append_platform_to_hostname: yes
raw_config_args:
......@@ -24,3 +31,37 @@ vagrant:
- 'vbguest.auto_update = false'
- 'landrush.enabled = false'
- 'landrush_ip.override = false'
docker:
containers:
- name: gitolite-xenial
image: ubuntu
image_version: xenial
command: /sbin/init
cap_add:
- SYS_ADMIN
volume_mounts:
- /sys/fs/cgroup:/sys/fs/cgroup
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
- name: gitolite-jessie
image: debian
image_version: jessie
command: /sbin/init
cap_add:
- SYS_ADMIN
volume_mounts:
- /sys/fs/cgroup:/sys/fs/cgroup
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
- name: gitolite-trusty
image: ubuntu
image_version: trusty
command: /sbin/init
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
---
# tasks file for cgit
- assert:
that:
- ansible_os_family == 'Debian'
- name: apt install
- name: APT install cgit
apt:
name: '{{ item }}'
state: present
......
---
# tasks file for ansible-role-gitolite
- assert:
# tasks file for gitolite
- name: Assertions
assert:
that:
- ansible_os_family in ['Debian']
- ansible_distribution_release in ['xenial', 'trusty', 'jessie']
- gitolite_public_key is defined
- ansible_os_family == 'Debian'
- name: APT install
with_items:
- gitolite3
- curl
apt:
name: '{{ item }}'
name: ['curl', 'gitolite3']
state: present
update_cache: yes
cache_valid_time: 3600
......
---
- hosts: all
- hosts: gitolite-openbsd
gather_facts: false
roles: [adarnimrod.openbsd-bootstrap]
- hosts: gitolite-xenial
gather_facts: false
roles: [adarnimrod.debian-bootstrap]
- hosts: all
pre_tasks:
- name: Create SSH keypair
local_action: command ssh-keygen -t rsa -N '' -f files/id_rsa
run_once: True
become: False
args:
creates: files/id_rsa
roles:
- role: ansible-role-example
- role: gitolite
gitolite_public_key: '{{ lookup("file", "id_rsa.pub") }}'
ansible==2.2.0.0
testinfra==1.4.4
molecule==1.15.0
ansible-lint==3.4.5
pre-commit==0.9.3
piprot==0.9.7
python-vagrant==0.5.14
docker-py==1.10.6
---
- src: adarnimrod.openbsd-bootstrap
- src: adarnimrod.debian-bootstrap
from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_example(Command):
assert Command('uname').rc == 0
def test_root(Command, Sudo):
with Sudo():
assert Command('whoami').stdout == 'root'
assert Command('whoami').stdout.strip() == 'root'
---
# vars file for ansible-role-gitolite
# vars file for gitolite
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment