From 16fffcdcbcc011bc45cf39c24781d05357714e4b Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Thu, 27 Aug 2015 21:15:48 -0400 Subject: [PATCH] Initial commit Signed-off-by: Paul Belanger --- .travis.yml | 31 +++++++++ README.rst | 20 ++++++ defaults/main.yaml | 9 +++ handlers/main.yaml | 2 + meta/main.yaml | 139 ++++++++++++++++++++++++++++++++++++++ tasks/config.yaml | 1 + tasks/install.yaml | 41 +++++++++++ tasks/install/debian.yaml | 9 +++ tasks/main.yaml | 9 +++ tasks/service.yaml | 1 + tests/ansible.cfg | 2 + tests/inventory | 1 + tests/test001.yaml | 4 ++ tests/test002.yaml | 4 ++ vars/Debian.yaml | 10 +++ 15 files changed, 283 insertions(+) create mode 100644 .travis.yml create mode 100644 README.rst create mode 100644 defaults/main.yaml create mode 100644 handlers/main.yaml create mode 100644 meta/main.yaml create mode 100644 tasks/config.yaml create mode 100644 tasks/install.yaml create mode 100644 tasks/install/debian.yaml create mode 100644 tasks/main.yaml create mode 100644 tasks/service.yaml create mode 100644 tests/ansible.cfg create mode 100644 tests/inventory create mode 100644 tests/test001.yaml create mode 100644 tests/test002.yaml create mode 100644 vars/Debian.yaml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e76944e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +--- +language: python +python: "2.7" + +env: + global: + - ANSIBLE_CONFIG=tests/ansible.cfg + matrix: + - SITE=test001.yaml + - SITE=test002.yaml + +before_install: + - sudo apt-get update -qq + +install: + # Install Ansible. + - pip install ansible + +script: + # Check the role/playbook's syntax. + - "ansible-playbook -i tests/inventory tests/$SITE --syntax-check" + + # Run the role/playbook with ansible-playbook. + - "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo" + + # Run the role/playbook again, checking to make sure it's idempotent. + - > + ansible-playbook -i tests/inventory tests/$SITE --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.rst b/README.rst new file mode 100644 index 0000000..0956820 --- /dev/null +++ b/README.rst @@ -0,0 +1,20 @@ +nodepool +======== + +Requirements +------------ + +Role Variables +-------------- + +Dependencies +------------ + +Example Playbook +---------------- + +License +------- + +Author Information +------------------ diff --git a/defaults/main.yaml b/defaults/main.yaml new file mode 100644 index 0000000..4050ad1 --- /dev/null +++ b/defaults/main.yaml @@ -0,0 +1,9 @@ +--- +# tasks/install.yaml +nodepool_git_dest: /opt/git/openstack-infra/nodepool +nodepool_git_uri: https://git.openstack.org/openstack-infra/nodepool +nodepool_git_version: master + +nodepool_install_method: git + +nodepool_pip_version: diff --git a/handlers/main.yaml b/handlers/main.yaml new file mode 100644 index 0000000..0ed8582 --- /dev/null +++ b/handlers/main.yaml @@ -0,0 +1,2 @@ +--- +# handlers file for nodepool diff --git a/meta/main.yaml b/meta/main.yaml new file mode 100644 index 0000000..62c7d35 --- /dev/null +++ b/meta/main.yaml @@ -0,0 +1,139 @@ +--- +galaxy_info: + author: your name + description: + company: your company (optional) + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + min_ansible_version: 1.2 + # + # Below are all platforms currently available. Just uncomment + # the ones that apply to your role. If you don't see your + # platform on this list, let us know and we'll get it added! + # + #platforms: + #- name: EL + # versions: + # - all + # - 5 + # - 6 + # - 7 + #- name: GenericUNIX + # versions: + # - all + # - any + #- name: Fedora + # versions: + # - all + # - 16 + # - 17 + # - 18 + # - 19 + # - 20 + # - 21 + # - 22 + #- name: Windows + # versions: + # - all + # - 2012R2 + #- name: SmartOS + # versions: + # - all + # - any + #- name: opensuse + # versions: + # - all + # - 12.1 + # - 12.2 + # - 12.3 + # - 13.1 + # - 13.2 + #- name: Amazon + # versions: + # - all + # - 2013.03 + # - 2013.09 + #- name: GenericBSD + # versions: + # - all + # - any + #- name: FreeBSD + # versions: + # - all + # - 8.0 + # - 8.1 + # - 8.2 + # - 8.3 + # - 8.4 + # - 9.0 + # - 9.1 + # - 9.1 + # - 9.2 + #- name: Ubuntu + # versions: + # - all + # - lucid + # - maverick + # - natty + # - oneiric + # - precise + # - quantal + # - raring + # - saucy + # - trusty + # - utopic + # - vivid + #- name: SLES + # versions: + # - all + # - 10SP3 + # - 10SP4 + # - 11 + # - 11SP1 + # - 11SP2 + # - 11SP3 + #- name: GenericLinux + # versions: + # - all + # - any + #- name: Debian + # versions: + # - all + # - etch + # - jessie + # - lenny + # - squeeze + # - wheezy + # + # Below are all categories currently available. Just as with + # the platforms above, uncomment those that apply to your role. + # + #categories: + #- cloud + #- cloud:ec2 + #- cloud:gce + #- cloud:rax + #- clustering + #- database + #- database:nosql + #- database:sql + #- development + #- monitoring + #- networking + #- packaging + #- system + #- web +dependencies: [] + # List your role dependencies here, one per line. + # Be sure to remove the '[]' above if you add dependencies + # to this list. + diff --git a/tasks/config.yaml b/tasks/config.yaml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/tasks/config.yaml @@ -0,0 +1 @@ +--- diff --git a/tasks/install.yaml b/tasks/install.yaml new file mode 100644 index 0000000..c5107e9 --- /dev/null +++ b/tasks/install.yaml @@ -0,0 +1,41 @@ +--- +- name: Define nodepool_build_depends. + set_fact: + nodepool_build_depends: "{{ __nodepool_build_depends | list }}" + when: nodepool_build_depends is not defined + +- name: Define nodepool_depends. + set_fact: + nodepool_depends: "{{ __nodepool_depends | list }}" + when: nodepool_depends is not defined + +- include: install/debian.yaml + when: ansible_os_family == 'Debian' + +- name: Download nodepool using git. + git: + dest: "{{ nodepool_git_dest }}" + repo: "{{ nodepool_git_uri }}" + version: "{{ nodepool_git_version }}" + when: nodepool_install_method == 'git' + +- name: Install nodepool using pip. + pip: + name: "file://{{ nodepool_git_dest }}" + when: nodepool_install_method == 'git' + +- name: Install nodepool using pip. + pip: + name: nodepool + when: nodepool_install_method == 'pip' + +- name: Install nodepool using pip. + pip: + name: nodepool + when: nodepool_install_method == 'pip' and nodepool_pip_version is none + +- name: Install nodepool using pip. + pip: + name: nodepool + version: "{{ nodepool_pip_version }}" + when: nodepool_install_method == 'pip' and nodepool_pip_version is not none diff --git a/tasks/install/debian.yaml b/tasks/install/debian.yaml new file mode 100644 index 0000000..a058453 --- /dev/null +++ b/tasks/install/debian.yaml @@ -0,0 +1,9 @@ +--- +- name: Ensure build dependencies are installed. + apt: "pkg={{ item }} state=installed" + with_items: nodepool_build_depends + when: nodepool_install_method == 'git' or nodepool_install_method == 'pip' + +- name: Ensure dependencies are installed. + apt: "pkg={{ item }} state=installed" + with_items: nodepool_depends diff --git a/tasks/main.yaml b/tasks/main.yaml new file mode 100644 index 0000000..8ef1218 --- /dev/null +++ b/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- name: Include OS-specific variables. + include_vars: "{{ ansible_os_family }}.yaml" + +- include: install.yaml + +- include: config.yaml + +- include: service.yaml diff --git a/tasks/service.yaml b/tasks/service.yaml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/tasks/service.yaml @@ -0,0 +1 @@ +--- diff --git a/tests/ansible.cfg b/tests/ansible.cfg new file mode 100644 index 0000000..2d4c5f9 --- /dev/null +++ b/tests/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +roles_path = .. diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/tests/test001.yaml b/tests/test001.yaml new file mode 100644 index 0000000..cbd1798 --- /dev/null +++ b/tests/test001.yaml @@ -0,0 +1,4 @@ +--- +- hosts: localhost + roles: + - ansible-role-nodepool diff --git a/tests/test002.yaml b/tests/test002.yaml new file mode 100644 index 0000000..9840bfb --- /dev/null +++ b/tests/test002.yaml @@ -0,0 +1,4 @@ +--- +- hosts: localhost + roles: + - { role: ansible-role-nodepool, nodepool_install_method: 'pip' } diff --git a/vars/Debian.yaml b/vars/Debian.yaml new file mode 100644 index 0000000..881a6a9 --- /dev/null +++ b/vars/Debian.yaml @@ -0,0 +1,10 @@ +--- +__nodepool_build_depends: + - libxml2-dev + - libxslt1-dev + - python-dev + - zlib1g-dev + +__nodepool_depends: + - debootstrap + - qemu-utils