From 2ee38e32b8c968cdbbf389cb3eb04af08a107a85 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Sat, 18 Jul 2015 10:33:07 +0530 Subject: [PATCH] Add anisble-galaxy configuration with timezone setup in common ref: - https://docs.ansible.com/galaxy.html - https://servercheck.in/blog/using-ansible-galaxy - https://github.com/yatesr/ansible-timezone --- .travis.yml | 19 ++++++++++++++----- README.md | 6 ++++++ playbook.yml | 1 - requirements.txt | 1 - requirements.yml | 4 ++++ roles/common/meta/main.yml | 3 +++ roles/common/tasks/main.yml | 2 +- 7 files changed, 28 insertions(+), 8 deletions(-) delete mode 100644 requirements.txt create mode 100644 requirements.yml create mode 100644 roles/common/meta/main.yml diff --git a/.travis.yml b/.travis.yml index 9c225fc..3cfe310 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,23 @@ --- language: python python: "2.7" - -before_install: - # Make sure everything's up to date. - - sudo apt-get update -qq +sudo: true install: # Install Ansible. - - pip install ansible + - sudo pip install ansible + - sudo ansible-galaxy install -r requirements.yml script: + # Check the role/playbook's syntax. - ansible-playbook -i hosts playbook.yml --syntax-check + + # Run the role/playbook with ansible-playbook. + - "ansible-playbook -i hosts playbook.yml --connection=local --sudo -vvvv" + + # Run the role/playbook again, checking to make sure it's idempotent. + - > + ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo + | grep -q 'changed=0.*failed=0' + && (echo 'Idempotence test: pass' && exit 0) + || (echo 'Idempotence test: fail' && exit 1) diff --git a/README.md b/README.md index cc42399..68f9889 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Make sure you have [vagrant] and virtualbox installed, then run: ```shell sudo pip install ansible +sudo ansible-galaxy install -r requirements.yml vagrant up ``` @@ -26,6 +27,11 @@ Login to the new machine with: vagrant ssh ``` +### Further Reading + +1. https://docs.ansible.com/galaxy.html + + [vagrant]: https://www.vagrantup.com/downloads.html ## Contributing diff --git a/playbook.yml b/playbook.yml index b497327..b909fa8 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,7 +1,6 @@ --- - hosts: all sudo: true - gather_facts: false roles: - common diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 4d41833..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -ansible==1.9.2 diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..3e9eef9 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,4 @@ +# https://docs.ansible.com/galaxy.html#advanced-control-over-role-requirements-files + +# https://github.com/yatesr/ansible-timezone +- src: yatesr.timezone diff --git a/roles/common/meta/main.yml b/roles/common/meta/main.yml new file mode 100644 index 0000000..e40db96 --- /dev/null +++ b/roles/common/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - { role: yatesr.timezone, timezone: Asia/Kolkata } diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index e964445..9fc44fa 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -1,4 +1,4 @@ --- # roles/common/tasks/main.yml -- name: set system locale +- name: Set system locale command: update-locale LC_ALL={{ lc_all }} LANG={{ lang }} LC_CTYPE={{ lc_ctype }} LC_COLLATE={{ lc_collate }}