Skip to content

Instantly share code, notes, and snippets.

@samdoran
Last active September 2, 2016 15:40
Show Gist options
  • Save samdoran/96c644030a614c6104ad7c390039aeb5 to your computer and use it in GitHub Desktop.
Save samdoran/96c644030a614c6104ad7c390039aeb5 to your computer and use it in GitHub Desktop.
pasteboard
- name: Playbook
hosts: all
roles:
- role: sshd
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_version | version_compare('6', '>=')
# Patch files from command line
$ cd ~/ansible-playbooks/playbooks/
$ ansible-playbook -i ~/temp_patches patch_things.yml -e 'target_hosts=all'
# Load ad-hoc inventory patches into Ansible Tower
$ tower-manage inventory_import --source patch_hosts --inventory-name Patches --overwrite --overwrite-vars
===========
# Playbook
- name: Patch all the things
hosts: "{{ target_hosts | default('all') }}"
roles:
- sshd
- changerootpw
---
- hosts: localhost
remote_user: root
roles:
- role-elasticsearch-curator
---
image: "samdoran/gitlab-ci-test-el6"
before_script:
- ansible --version
- printf '[defaults]\nroles_path=../' > ansible.cfg
test:
script:
# Basic role syntax check
- ansible-playbook tests/gitlab-ci-test.yml -i tests/inventory --syntax-check
# Run the first time
- ansible-playbook tests/gitlab-ci-test.yml -i tests/inventory -c local -b
# Run again and expect no changes
- >
ansible-playbook tests/gitlab-ci-test.yml -i tests/inventory -c local -b
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
- src: git@git.acme.com:ansible/role-gitlab.git
name: gitlab
scm: git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment