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
No related branches found
No related tags found
No related merge requests found
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
sha: 6dfcb89af3c9b4d172cc2e5a8a2fa0f54615a338 sha: 7539d8bd1a00a3c1bfd34cdb606d3a6372e83469
hooks: hooks:
- id: check-added-large-files - id: check-added-large-files
- id: check-json - id: check-json
- id: check-xml - id: check-xml
- id: check-yaml - id: check-yaml
- id: check-merge-conflict - id: check-merge-conflict
- repo: https://www.shore.co.il/git/ansible-pre-commit/ - id: flake8
sha: 94b506c144d4e22ebc1deef637a818db13bcaca5 - id: check-symlinks
- repo: https://github.com/adarnimrod/ansible-pre-commit.git
sha: 0fadd691465b97db8992cfc66650f630e433324b
hooks: 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 Gitolite
################ ########
An Ansible role for provisioning gitolite and a readonly cgit web interface .. image:: https://travis-ci.org/adarnimrod/gitolite.svg?branch=master
(served by Apache). :target: https://travis-ci.org/adarnimrod/gitolite
Provision Gitolite and a readonly cgit web interface served by Apache.
Requirements 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 Role Variables
-------------- --------------
...@@ -27,17 +29,22 @@ See :code:`tests/playbook.yml`. ...@@ -27,17 +29,22 @@ See :code:`tests/playbook.yml`.
Testing 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 .. code:: shell
pip install -r tests/requirements.txt
ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
molecule dependency
To run the full test suite: To run the full test suite:
.. code:: shell .. code:: shell
molecule test pre-commit run --all-files
molecule test --platform all
License License
------- -------
...@@ -62,7 +69,6 @@ TODO ...@@ -62,7 +69,6 @@ TODO
- Include dependencies in `meta/main.yml` and test. - Include dependencies in `meta/main.yml` and test.
- Log to syslog. - Log to syslog.
- Metrics? - Metrics?
- Rebase on ansible-role-example.
- Flush handlers and wait for service to come up. - Flush handlers and wait for service to come up.
- Add mail alias. - Add mail alias.
- Remove dependency on the common role, use specific roles. - Remove dependency on the common role, use specific roles.
......
[defaults] [defaults]
library = library
host_key_checking = False host_key_checking = False
retry_files_enabled = False retry_files_enabled = False
roles_path = roles:../:../../:.molecule/roles roles_path = .molecule/roles:.molecule/../roles:../:../../
command_warnings = True command_warnings = True
deprecation_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. # Content of the SSH public key for the gitolite admin account.
gitolite_public_key: gitolite_public_key:
--- ---
# handlers file for ansible-role-gitolite # handlers file for gitolite
--- ---
galaxy_info: galaxy_info:
author: Nimrod Adar author: Nimrod Adar
description: Gitolite installation description: Provision Gitolite and a readonly cgit web interface served by Apache
company: Shore technologies company: Shore technologies
license: MIT license: MIT
min_ansible_version: 2.0 min_ansible_version: 2.0
...@@ -9,7 +9,11 @@ galaxy_info: ...@@ -9,7 +9,11 @@ galaxy_info:
- name: Debian - name: Debian
versions: versions:
- jessie - jessie
- name: Ubuntu
versions:
- trusty
- xenial
galaxy_tags: [ git, scm, gitolite ] galaxy_tags: [ git, scm, gitolite ]
dependencies: dependencies:
- role: common - name: adarnimrod.apache
- role: apache src: adarnimrod.apache
--- ---
ansible: ansible:
verbose: v verbose: vv
playbook: tests/playbook.yml playbook: tests/playbook.yml
diff: True diff: True
config_file: ../ansible.cfg
molecule: dependency:
testinfra_dir: tests name: galaxy
ansible_config_template: ansible.cfg requirements_file: tests/requirements.yml
vagrant: vagrant:
providers: providers:
...@@ -14,9 +15,15 @@ vagrant: ...@@ -14,9 +15,15 @@ vagrant:
type: virtualbox type: virtualbox
platforms: platforms:
- name: openbsd - 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: instances:
- name: ansible-role-example - name: gitolite
options: options:
append_platform_to_hostname: yes append_platform_to_hostname: yes
raw_config_args: raw_config_args:
...@@ -24,3 +31,37 @@ vagrant: ...@@ -24,3 +31,37 @@ vagrant:
- 'vbguest.auto_update = false' - 'vbguest.auto_update = false'
- 'landrush.enabled = false' - 'landrush.enabled = false'
- 'landrush_ip.override = 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 # tasks file for cgit
- name: APT install cgit
- assert:
that:
- ansible_os_family == 'Debian'
- name: apt install
apt: apt:
name: '{{ item }}' name: '{{ item }}'
state: present state: present
......
--- ---
# tasks file for ansible-role-gitolite # tasks file for gitolite
- name: Assertions
- assert: assert:
that: that:
- ansible_os_family in ['Debian']
- ansible_distribution_release in ['xenial', 'trusty', 'jessie']
- gitolite_public_key is defined - gitolite_public_key is defined
- ansible_os_family == 'Debian'
- name: APT install - name: APT install
with_items: with_items:
- gitolite3 - gitolite3
- curl - curl
apt: apt:
name: '{{ item }}' name: ['curl', 'gitolite3']
state: present state: present
update_cache: yes update_cache: yes
cache_valid_time: 3600 cache_valid_time: 3600
......
--- ---
- hosts: all - hosts: gitolite-openbsd
gather_facts: false
roles: [adarnimrod.openbsd-bootstrap]
- hosts: gitolite-xenial
gather_facts: false 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: 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): def test_example(Command):
assert Command('uname').rc == 0 assert Command('uname').rc == 0
def test_root(Command, Sudo): def test_root(Command, Sudo):
with 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