diff --git a/galaxy.yml b/galaxy.yml index 557548a..181a607 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ namespace: "robertdebock" name: "development_environment" description: Install everything you need to develop Ansible roles. -version: "1.2.0" +version: "1.2.1" readme: "README.md" authors: - "Robert de Bock" diff --git a/roles/ansible/.ansible-lint b/roles/ansible/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/ansible/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/ansible/.github/ISSUE_TEMPLATE/bug_report.md b/roles/ansible/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/ansible/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/ansible/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/ansible/.github/settings.yml b/roles/ansible/.github/settings.yml index 1163812..5019e26 100644 --- a/roles/ansible/.github/settings.yml +++ b/roles/ansible/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install and configure ansible on your system. homepage: https://robertdebock.nl/ diff --git a/roles/ansible/.gitignore b/roles/ansible/.gitignore index 47cf7b9..982db11 100644 --- a/roles/ansible/.gitignore +++ b/roles/ansible/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log -*.swp \ No newline at end of file +*.swp +.tox diff --git a/roles/ansible/.travis.yml b/roles/ansible/.travis.yml index 873ad0e..1ddc43a 100644 --- a/roles/ansible/.travis.yml +++ b/roles/ansible/.travis.yml @@ -1,85 +1,44 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="fedora" + - image="fedora" tag="rawhide" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/ansible/README.md b/roles/ansible/README.md index 8235356..430a7f3 100644 --- a/roles/ansible/README.md +++ b/roles/ansible/README.md @@ -2,14 +2,14 @@ ansible ========= Ansible logo -Build status + Build status Install and configure ansible on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.ansible ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -32,6 +32,24 @@ The machine you are running this on, may need to be prepared. roles: - role: robertdebock.bootstrap - role: robertdebock.epel + - role: robertdebock.buildtools + - role: robertdebock.python_pip +``` + +After running this role, this playbook runs to verify that everything works, this may be a good example how you can use this role. +```yaml +--- +- name: Verify + hosts: all + become: no + gather_facts: no + + tasks: + - name: run ansible + shell: ansible --version > ansible.version + args: + creates: ansible.version + ``` Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. @@ -69,6 +87,8 @@ The following roles can be installed to ensure all requirements are met, using ` --- - robertdebock.bootstrap - robertdebock.epel +- robertdebock.buildtools +- robertdebock.python_pip ``` @@ -84,42 +104,80 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|latest|no| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| amazonlinux:1 | No package matching 'python3-pip' | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-ansible) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-ansible) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-ansible/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- file +- ini_file +- lineinfile +``` License ------- diff --git a/roles/ansible/meta/.galaxy_install_info b/roles/ansible/meta/.galaxy_install_info index d00809d..97ea144 100644 --- a/roles/ansible/meta/.galaxy_install_info +++ b/roles/ansible/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:03 2019', version: 2.0.7} +install_date: Mon Dec 16 06:44:21 2019 +version: 2.1.1 diff --git a/roles/ansible/meta/exception.yml b/roles/ansible/meta/exception.yml new file mode 100644 index 0000000..95e813f --- /dev/null +++ b/roles/ansible/meta/exception.yml @@ -0,0 +1,4 @@ +--- +exceptions: + - variation: amazonlinux:1 + reason: "No package matching 'python3-pip'" diff --git a/roles/ansible/meta/main.yml b/roles/ansible/meta/main.yml index a6d1b97..a90b0f0 100644 --- a/roles/ansible/meta/main.yml +++ b/roles/ansible/meta/main.yml @@ -5,26 +5,26 @@ galaxy_info: description: Install and configure ansible on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - Candidate - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 - - 7 - - name: Fedora versions: - - all - - name: OpenSUSE + - 7 + - 8 + - name: Fedora versions: - all - name: Ubuntu @@ -34,14 +34,5 @@ galaxy_info: galaxy_tags: - ansible - - alpine - - archlinux - - centos - - debian - - el - - fedora - - opensuse - - rhel - - ubuntu dependencies: [] diff --git a/roles/ansible/molecule/alpine-edge/molecule.yml b/roles/ansible/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 54814b5..0000000 --- a/roles/ansible/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/ansible/molecule/alpine-latest/molecule.yml b/roles/ansible/molecule/alpine-latest/molecule.yml deleted file mode 100644 index e180d19..0000000 --- a/roles/ansible/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/ansible/molecule/archlinux/molecule.yml b/roles/ansible/molecule/archlinux/molecule.yml deleted file mode 100644 index 1bf197f..0000000 --- a/roles/ansible/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/ansible/molecule/centos-6/molecule.yml b/roles/ansible/molecule/centos-6/molecule.yml deleted file mode 100644 index f273374..0000000 --- a/roles/ansible/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/ansible/molecule/centos-latest/molecule.yml b/roles/ansible/molecule/centos-latest/molecule.yml deleted file mode 100644 index d709d26..0000000 --- a/roles/ansible/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/ansible/molecule/debian-stable/molecule.yml b/roles/ansible/molecule/debian-stable/molecule.yml deleted file mode 100644 index 4b954a9..0000000 --- a/roles/ansible/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/ansible/molecule/debian-unstable/molecule.yml b/roles/ansible/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 3975f18..0000000 --- a/roles/ansible/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/ansible/molecule/default/molecule.yml b/roles/ansible/molecule/default/molecule.yml index 4546c17..1bbd498 100644 --- a/roles/ansible/molecule/default/molecule.yml +++ b/roles/ansible/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,19 @@ lint: driver: name: docker platforms: - - name: ansible-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: ansible-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: ansible-archlinux - image: archlinux/base - pre_build_image: yes - - name: ansible-centos-6 - image: centos:6 - pre_build_image: yes - - name: ansible-centos-latest - image: centos:latest - pre_build_image: yes - - name: ansible-debian-stable - image: debian:stable - pre_build_image: yes - - name: ansible-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: ansible-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: ansible-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: ansible-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: ansible-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: ansible-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: ansible-ubuntu-devel - image: ubuntu:devel + - name: "ansible-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml +verifier: + name: ansible lint: name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ansible-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - ansible-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 + enabled: no scenario: name: default diff --git a/roles/ansible/molecule/resources/playbook.yml b/roles/ansible/molecule/default/playbook.yml similarity index 100% rename from roles/ansible/molecule/resources/playbook.yml rename to roles/ansible/molecule/default/playbook.yml diff --git a/roles/vagrant/molecule/resources/prepare.yml b/roles/ansible/molecule/default/prepare.yml similarity index 100% rename from roles/vagrant/molecule/resources/prepare.yml rename to roles/ansible/molecule/default/prepare.yml index a44724a..fcdc074 100644 --- a/roles/vagrant/molecule/resources/prepare.yml +++ b/roles/ansible/molecule/default/prepare.yml @@ -6,6 +6,6 @@ roles: - role: robertdebock.bootstrap - - role: robertdebock.buildtools - role: robertdebock.epel + - role: robertdebock.buildtools - role: robertdebock.python_pip diff --git a/roles/ansible/molecule/default/verify.yml b/roles/ansible/molecule/default/verify.yml new file mode 100644 index 0000000..4733d21 --- /dev/null +++ b/roles/ansible/molecule/default/verify.yml @@ -0,0 +1,11 @@ +--- +- name: Verify + hosts: all + become: no + gather_facts: no + + tasks: + - name: run ansible + shell: ansible --version > ansible.version + args: + creates: ansible.version diff --git a/roles/ansible/molecule/ec2/README.md b/roles/ansible/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/ansible/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/ansible/molecule/ec2/create.yml b/roles/ansible/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/ansible/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/ansible/molecule/ec2/destroy.yml b/roles/ansible/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/ansible/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/ansible/molecule/ec2/molecule.yml b/roles/ansible/molecule/ec2/molecule.yml deleted file mode 100644 index 4832cdd..0000000 --- a/roles/ansible/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: ansible-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ansible-ubuntu-18.04: - ansible_user: ubuntu - ansible-centos-7: - ansible_user: centos - ansible-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/ansible/molecule/fedora-latest/molecule.yml b/roles/ansible/molecule/fedora-latest/molecule.yml deleted file mode 100644 index c4ea18b..0000000 --- a/roles/ansible/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/ansible/molecule/fedora-rawhide/molecule.yml b/roles/ansible/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index bd15d88..0000000 --- a/roles/ansible/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/ansible/molecule/opensuse-leap/molecule.yml b/roles/ansible/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index a982469..0000000 --- a/roles/ansible/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/ansible/molecule/ubuntu-devel/molecule.yml b/roles/ansible/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 5c09eaf..0000000 --- a/roles/ansible/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/ansible/molecule/ubuntu-latest/molecule.yml b/roles/ansible/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 434cf03..0000000 --- a/roles/ansible/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/ansible/molecule/ubuntu-rolling/molecule.yml b/roles/ansible/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index ddc5f08..0000000 --- a/roles/ansible/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/ansible/molecule/vagrant/molecule.yml b/roles/ansible/molecule/vagrant/molecule.yml deleted file mode 100644 index da480d7..0000000 --- a/roles/ansible/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: ansible-debian - box: debian/stretch64 - - name: ansible-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ansible-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/ansible/requirements.yml b/roles/ansible/requirements.yml index cecd945..0c03c19 100644 --- a/roles/ansible/requirements.yml +++ b/roles/ansible/requirements.yml @@ -1,3 +1,5 @@ --- - robertdebock.bootstrap - robertdebock.epel +- robertdebock.buildtools +- robertdebock.python_pip diff --git a/roles/ansible/tasks/main.yml b/roles/ansible/tasks/main.yml index ac111e6..d3d0e73 100644 --- a/roles/ansible/tasks/main.yml +++ b/roles/ansible/tasks/main.yml @@ -1,12 +1,22 @@ --- # tasks file for ansible - name: install ansible - package: - name: "{{ ansible_packages }}" - state: present - register: ansible_install_ansible - until: ansible_install_ansible is succeeded - retries: 3 + block: + - name: install ansible package (allowed to fail) + package: + name: "{{ ansible_packages }}" + state: present + register: ansible_install_ansible_package + until: ansible_install_ansible_package is succeeded + retries: 3 + rescue: + - name: install ansible pip + pip: + name: ansible + state: present + register: ansible_install_ansible_pip + until: ansible_install_ansible_pip is succeeded + retries: 3 - name: ensure the ansible directory exists file: diff --git a/roles/ansible/tox.ini b/roles/ansible/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/ansible/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/ansible_lint/.ansible-lint b/roles/ansible_lint/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/ansible_lint/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/ansible_lint/.github/ISSUE_TEMPLATE/bug_report.md b/roles/ansible_lint/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/ansible_lint/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/ansible_lint/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/ansible_lint/.github/settings.yml b/roles/ansible_lint/.github/settings.yml index 00c0616..2ae14d3 100644 --- a/roles/ansible_lint/.github/settings.yml +++ b/roles/ansible_lint/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install ansible-lint on your system. homepage: https://robertdebock.nl/ diff --git a/roles/ansible_lint/.gitignore b/roles/ansible_lint/.gitignore index 47cf7b9..982db11 100644 --- a/roles/ansible_lint/.gitignore +++ b/roles/ansible_lint/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log -*.swp \ No newline at end of file +*.swp +.tox diff --git a/roles/ansible_lint/.travis.yml b/roles/ansible_lint/.travis.yml index 766597e..8e2040d 100644 --- a/roles/ansible_lint/.travis.yml +++ b/roles/ansible_lint/.travis.yml @@ -1,85 +1,42 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" expectation="fail" - - version="" distro="centos-6" expectation="fail" - - version="devel" distro="centos-6" expectation="fail" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" expectation="fail" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/ansible_lint/README.md b/roles/ansible_lint/README.md index 64d9e67..b3ce189 100644 --- a/roles/ansible_lint/README.md +++ b/roles/ansible_lint/README.md @@ -2,14 +2,14 @@ ansible_lint ========= Ansible logo -Build status + Build status Install ansible-lint on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.ansible_lint ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -36,6 +36,7 @@ The machine you are running this on, may need to be prepared. - role: robertdebock.python_pip ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -76,42 +77,78 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|no|no|no*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|debian|unstable|yes| +|debian|latest|no| +|centos|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| amazonlinux:1 | No package matching 'python3-pip' | +| amazonlinux | No module named pkg_resources | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-ansible_lint) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-ansible_lint) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-ansible_lint/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- pip +``` License ------- diff --git a/roles/ansible_lint/meta/.galaxy_install_info b/roles/ansible_lint/meta/.galaxy_install_info index 8107c79..3ac83e0 100644 --- a/roles/ansible_lint/meta/.galaxy_install_info +++ b/roles/ansible_lint/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:07 2019', version: 2.0.6} +install_date: Mon Dec 16 06:44:26 2019 +version: 2.2.2 diff --git a/roles/ansible_lint/meta/exception.yml b/roles/ansible_lint/meta/exception.yml new file mode 100644 index 0000000..0f73f3c --- /dev/null +++ b/roles/ansible_lint/meta/exception.yml @@ -0,0 +1,6 @@ +--- +exceptions: + - variation: amazonlinux:1 + reason: "No package matching 'python3-pip'" + - variation: amazonlinux + reason: "No module named pkg_resources" diff --git a/roles/ansible_lint/meta/main.yml b/roles/ansible_lint/meta/main.yml index 92d991e..f05d0fa 100644 --- a/roles/ansible_lint/meta/main.yml +++ b/roles/ansible_lint/meta/main.yml @@ -5,21 +5,18 @@ galaxy_info: description: Install ansible-lint on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - - name: Alpine - versions: - - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 7 + versions: + - 8 - name: Fedora versions: - all @@ -33,14 +30,8 @@ galaxy_info: galaxy_tags: - ansiblelint - - alpine - archlinux - centos - - debian - - el - - fedora - - opensuse - rhel - - ubuntu dependencies: [] diff --git a/roles/ansible_lint/molecule/alpine-edge/molecule.yml b/roles/ansible_lint/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 047a5c1..0000000 --- a/roles/ansible_lint/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/ansible_lint/molecule/alpine-latest/molecule.yml b/roles/ansible_lint/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 9da7a77..0000000 --- a/roles/ansible_lint/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/ansible_lint/molecule/archlinux/molecule.yml b/roles/ansible_lint/molecule/archlinux/molecule.yml deleted file mode 100644 index fe5ab63..0000000 --- a/roles/ansible_lint/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/ansible_lint/molecule/centos-6/molecule.yml b/roles/ansible_lint/molecule/centos-6/molecule.yml deleted file mode 100644 index 94986b6..0000000 --- a/roles/ansible_lint/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/ansible_lint/molecule/centos-latest/molecule.yml b/roles/ansible_lint/molecule/centos-latest/molecule.yml deleted file mode 100644 index 478647f..0000000 --- a/roles/ansible_lint/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/ansible_lint/molecule/debian-stable/molecule.yml b/roles/ansible_lint/molecule/debian-stable/molecule.yml deleted file mode 100644 index 1699ad4..0000000 --- a/roles/ansible_lint/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/ansible_lint/molecule/debian-unstable/molecule.yml b/roles/ansible_lint/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 4ef4ed4..0000000 --- a/roles/ansible_lint/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/ansible_lint/molecule/default/molecule.yml b/roles/ansible_lint/molecule/default/molecule.yml index 32ae6c0..2660bc8 100644 --- a/roles/ansible_lint/molecule/default/molecule.yml +++ b/roles/ansible_lint/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: ansible_lint-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: ansible_lint-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: ansible_lint-archlinux - image: archlinux/base - pre_build_image: yes - - name: ansible_lint-centos-6 - image: centos:6 - pre_build_image: yes - - name: ansible_lint-centos-latest - image: centos:latest - pre_build_image: yes - - name: ansible_lint-debian-stable - image: debian:stable - pre_build_image: yes - - name: ansible_lint-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: ansible_lint-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: ansible_lint-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: ansible_lint-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: ansible_lint-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: ansible_lint-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: ansible_lint-ubuntu-devel - image: ubuntu:devel + - name: "ansible_lint-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ansible_lint-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - ansible_lint-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/ansible_lint/molecule/resources/playbook.yml b/roles/ansible_lint/molecule/default/playbook.yml similarity index 100% rename from roles/ansible_lint/molecule/resources/playbook.yml rename to roles/ansible_lint/molecule/default/playbook.yml diff --git a/roles/ansible_lint/molecule/resources/prepare.yml b/roles/ansible_lint/molecule/default/prepare.yml similarity index 100% rename from roles/ansible_lint/molecule/resources/prepare.yml rename to roles/ansible_lint/molecule/default/prepare.yml diff --git a/roles/ansible_lint/molecule/ec2/README.md b/roles/ansible_lint/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/ansible_lint/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/ansible_lint/molecule/ec2/create.yml b/roles/ansible_lint/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/ansible_lint/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/ansible_lint/molecule/ec2/destroy.yml b/roles/ansible_lint/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/ansible_lint/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/ansible_lint/molecule/ec2/molecule.yml b/roles/ansible_lint/molecule/ec2/molecule.yml deleted file mode 100644 index 98e9e4c..0000000 --- a/roles/ansible_lint/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: ansible_lint-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible_lint-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible_lint-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible_lint-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible_lint-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ansible_lint-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ansible_lint-ubuntu-18.04: - ansible_user: ubuntu - ansible_lint-centos-7: - ansible_user: centos - ansible_lint-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/ansible_lint/molecule/fedora-latest/molecule.yml b/roles/ansible_lint/molecule/fedora-latest/molecule.yml deleted file mode 100644 index a3120a5..0000000 --- a/roles/ansible_lint/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/ansible_lint/molecule/fedora-rawhide/molecule.yml b/roles/ansible_lint/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 92eabdb..0000000 --- a/roles/ansible_lint/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/ansible_lint/molecule/opensuse-leap/molecule.yml b/roles/ansible_lint/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 392f30a..0000000 --- a/roles/ansible_lint/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/ansible_lint/molecule/ubuntu-devel/molecule.yml b/roles/ansible_lint/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 7cb3a10..0000000 --- a/roles/ansible_lint/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/ansible_lint/molecule/ubuntu-latest/molecule.yml b/roles/ansible_lint/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 7b8dedf..0000000 --- a/roles/ansible_lint/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/ansible_lint/molecule/ubuntu-rolling/molecule.yml b/roles/ansible_lint/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 98c720c..0000000 --- a/roles/ansible_lint/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ansible_lint-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/ansible_lint/molecule/vagrant/molecule.yml b/roles/ansible_lint/molecule/vagrant/molecule.yml deleted file mode 100644 index f6541b1..0000000 --- a/roles/ansible_lint/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: ansible_lint-debian - box: debian/stretch64 - - name: ansible_lint-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ansible_lint-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/ansible_lint/tasks/main.yml b/roles/ansible_lint/tasks/main.yml index a8d0812..31d7fcc 100644 --- a/roles/ansible_lint/tasks/main.yml +++ b/roles/ansible_lint/tasks/main.yml @@ -1,9 +1,5 @@ --- # tasks file for ansible_lint -- name: test veriables and environment - assert: - that: - - name: install ansible_lint pip: name: "{{ ansible_lint_packages }}" diff --git a/roles/ansible_lint/tox.ini b/roles/ansible_lint/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/ansible_lint/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/ara/.ansible-lint b/roles/ara/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/ara/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/ara/.github/ISSUE_TEMPLATE/bug_report.md b/roles/ara/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/ara/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/ara/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/ara/.github/settings.yml b/roles/ara/.github/settings.yml index 582014f..e9e274a 100644 --- a/roles/ara/.github/settings.yml +++ b/roles/ara/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install and configure ara on your system. homepage: https://robertdebock.nl/ diff --git a/roles/ara/.gitignore b/roles/ara/.gitignore index 10b26d1..982db11 100644 --- a/roles/ara/.gitignore +++ b/roles/ara/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/ara/.travis.yml b/roles/ara/.travis.yml index 5e0e84c..dcd5894 100644 --- a/roles/ara/.travis.yml +++ b/roles/ara/.travis.yml @@ -1,85 +1,41 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" expectation="fail" - - version="" distro="alpine-latest" expectation="fail" - - version="devel" distro="alpine-latest" expectation="fail" - - version=">=2.7,<2.8" distro="alpine-edge" expectation="fail" - - version="" distro="alpine-edge" expectation="fail" - - version="devel" distro="alpine-edge" expectation="fail" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" expectation="fail" - - version="" distro="centos-6" expectation="fail" - - version="devel" distro="centos-6" expectation="fail" - - version=">=2.7,<2.8" distro="centos-latest" expectation="fail" - - version="" distro="centos-latest" expectation="fail" - - version="devel" distro="centos-latest" expectation="fail" - - version=">=2.7,<2.8" distro="debian-stable" expectation="fail" - - version="" distro="debian-stable" expectation="fail" - - version="devel" distro="debian-stable" expectation="fail" - - version=">=2.7,<2.8" distro="debian-unstable" expectation="fail" - - version="" distro="debian-unstable" expectation="fail" - - version="devel" distro="debian-unstable" expectation="fail" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" expectation="fail" - - version="" distro="opensuse-leap" expectation="fail" - - version="devel" distro="opensuse-leap" expectation="fail" - - version=">=2.7,<2.8" distro="ubuntu-rolling" expectation="fail" - - version="" distro="ubuntu-rolling" expectation="fail" - - version="devel" distro="ubuntu-rolling" expectation="fail" - - version=">=2.7,<2.8" distro="ubuntu-latest" expectation="fail" - - version="" distro="ubuntu-latest" expectation="fail" - - version="devel" distro="ubuntu-latest" expectation="fail" - - version=">=2.7,<2.8" distro="ubuntu-devel" expectation="fail" - - version="" distro="ubuntu-devel" expectation="fail" - - version="devel" distro="ubuntu-devel" expectation="fail" + global: + namespace="robertdebock" + matrix: + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" + - image="fedora" + - image="fedora" tag="rawhide" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" expectation="fail" - - env: version="" distro="alpine-edge" expectation="fail" - - env: version="devel" distro="alpine-edge" expectation="fail" - - env: version="devel" distro="alpine-latest" expectation="fail" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" expectation="fail" - - env: version="devel" distro="centos-latest" expectation="fail" - - env: version="devel" distro="debian-stable" expectation="fail" - - env: version=">=2.7,<2.8" distro="debian-unstable" expectation="fail" - - env: version="" distro="debian-unstable" expectation="fail" - - env: version="devel" distro="debian-unstable" expectation="fail" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" expectation="fail" - - env: version="devel" distro="ubuntu-rolling" expectation="fail" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" expectation="fail" - - env: version="" distro="ubuntu-devel" expectation="fail" - - env: version="devel" distro="ubuntu-devel" expectation="fail" - - env: version="devel" distro="ubuntu-latest" expectation="fail" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/ara/README.md b/roles/ara/README.md index 1151c2a..d03d282 100644 --- a/roles/ara/README.md +++ b/roles/ara/README.md @@ -2,14 +2,14 @@ ara ========= Ansible logo -Build status + Build status Install and configure ara on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.ara ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -36,6 +36,7 @@ The machine you are running this on, may need to be prepared. - robertdebock.python_pip ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -96,42 +97,83 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|no|no|no*| -|alpine-latest|no|no|no*| -|archlinux|yes|yes|yes*| -|centos-6|no|no|no*| -|centos-latest|no|no|no*| -|debian-stable|no|no|no*| -|debian-unstable*|no|no|no*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|no|no|no*| -|ubuntu-devel*|no|no|no*| -|ubuntu-latest|no|no|no*| -|ubuntu-rolling|no|no|no*| +|container|tag|allow_failures| +|---------|---|--------------| +|debian|unstable|yes| +|debian|latest|no| +|centos|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| Alpine | Could not find a version that satisfies the requirement Django>=2.1.5 | +| CentOS | No matching distribution found for Django>=2.1.5 | +| amazonlinux:1 | No package matching 'python3-pip' | +| amazonlinux | No module named pkg_resources | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-ara) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-ara) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-ara/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- import_role +- ini_file +- pip +- service +- systemd +``` License ------- diff --git a/roles/ara/handlers/main.yml b/roles/ara/handlers/main.yml index 424876d..f9f1544 100644 --- a/roles/ara/handlers/main.yml +++ b/roles/ara/handlers/main.yml @@ -4,8 +4,6 @@ service: name: ara state: restarted - when: - - ansible_virtualization_type != "docker" become: yes - name: systemctl daemon-reload diff --git a/roles/ara/meta/.galaxy_install_info b/roles/ara/meta/.galaxy_install_info index c20f4e4..4d0e4a0 100644 --- a/roles/ara/meta/.galaxy_install_info +++ b/roles/ara/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:10 2019', version: 2.1.1} +install_date: Mon Dec 16 06:44:30 2019 +version: 2.3.2 diff --git a/roles/ara/meta/exception.yml b/roles/ara/meta/exception.yml new file mode 100644 index 0000000..1cb5a7c --- /dev/null +++ b/roles/ara/meta/exception.yml @@ -0,0 +1,10 @@ +--- +exceptions: + - variation: Alpine + reason: "Could not find a version that satisfies the requirement Django>=2.1.5" + - variation: CentOS + reason: No matching distribution found for Django>=2.1.5 + - variation: amazonlinux:1 + reason: "No package matching 'python3-pip'" + - variation: amazonlinux + reason: "No module named pkg_resources" diff --git a/roles/ara/meta/main.yml b/roles/ara/meta/main.yml index 0a8aa7f..ffc8449 100644 --- a/roles/ara/meta/main.yml +++ b/roles/ara/meta/main.yml @@ -5,25 +5,19 @@ galaxy_info: description: Install and configure ara on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - - name: Alpine - versions: - - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 7 - - name: Fedora versions: - - all - - name: OpenSUSE + - 8 + - name: Fedora versions: - all - name: Ubuntu @@ -32,21 +26,14 @@ galaxy_info: - bionic galaxy_tags: - - alpine - ansiblerecordsansible - ara - arareportsansible - - archlinux - - centos - cloud - - debian + - centos - development - - fedora - monitoring - - opensuse - - reporting - rhel - - ubuntu - - web + - reporting dependencies: [] diff --git a/roles/ara/molecule/alpine-edge/molecule.yml b/roles/ara/molecule/alpine-edge/molecule.yml deleted file mode 100644 index d5e65a4..0000000 --- a/roles/ara/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/ara/molecule/alpine-latest/molecule.yml b/roles/ara/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 6405a69..0000000 --- a/roles/ara/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/ara/molecule/archlinux/molecule.yml b/roles/ara/molecule/archlinux/molecule.yml deleted file mode 100644 index 71eb85c..0000000 --- a/roles/ara/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/ara/molecule/centos-6/molecule.yml b/roles/ara/molecule/centos-6/molecule.yml deleted file mode 100644 index dfd8d57..0000000 --- a/roles/ara/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/ara/molecule/centos-latest/molecule.yml b/roles/ara/molecule/centos-latest/molecule.yml deleted file mode 100644 index 0398aae..0000000 --- a/roles/ara/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/ara/molecule/debian-stable/molecule.yml b/roles/ara/molecule/debian-stable/molecule.yml deleted file mode 100644 index 1d0052c..0000000 --- a/roles/ara/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/ara/molecule/debian-unstable/molecule.yml b/roles/ara/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 1322617..0000000 --- a/roles/ara/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/ara/molecule/default/molecule.yml b/roles/ara/molecule/default/molecule.yml index 892fef2..a5e309a 100644 --- a/roles/ara/molecule/default/molecule.yml +++ b/roles/ara/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: ara-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: ara-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: ara-archlinux - image: archlinux/base - pre_build_image: yes - # - name: ara-centos-6 - # image: centos:6 - # pre_build_image: yes - - name: ara-centos-latest - image: centos:latest - pre_build_image: yes - - name: ara-debian-stable - image: debian:stable - pre_build_image: yes - - name: ara-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: ara-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: ara-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: ara-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: ara-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: ara-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: ara-ubuntu-devel - image: ubuntu:devel + - name: "ara-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ara-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - ara-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/ara/molecule/resources/playbook.yml b/roles/ara/molecule/default/playbook.yml similarity index 100% rename from roles/ara/molecule/resources/playbook.yml rename to roles/ara/molecule/default/playbook.yml diff --git a/roles/ara/molecule/resources/prepare.yml b/roles/ara/molecule/default/prepare.yml similarity index 100% rename from roles/ara/molecule/resources/prepare.yml rename to roles/ara/molecule/default/prepare.yml diff --git a/roles/ara/molecule/ec2/README.md b/roles/ara/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/ara/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/ara/molecule/ec2/create.yml b/roles/ara/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/ara/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/ara/molecule/ec2/destroy.yml b/roles/ara/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/ara/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/ara/molecule/ec2/molecule.yml b/roles/ara/molecule/ec2/molecule.yml deleted file mode 100644 index 2bae6e8..0000000 --- a/roles/ara/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: ara-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ara-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ara-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ara-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ara-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ara-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ara-ubuntu-18.04: - ansible_user: ubuntu - ara-centos-7: - ansible_user: centos - ara-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/ara/molecule/fedora-latest/molecule.yml b/roles/ara/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 240ac41..0000000 --- a/roles/ara/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/ara/molecule/fedora-rawhide/molecule.yml b/roles/ara/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 7d061e6..0000000 --- a/roles/ara/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/ara/molecule/opensuse-leap/molecule.yml b/roles/ara/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 966c824..0000000 --- a/roles/ara/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/ara/molecule/ubuntu-devel/molecule.yml b/roles/ara/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 50b885e..0000000 --- a/roles/ara/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/ara/molecule/ubuntu-latest/molecule.yml b/roles/ara/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 3c45b5e..0000000 --- a/roles/ara/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/ara/molecule/ubuntu-rolling/molecule.yml b/roles/ara/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index a5cdd6a..0000000 --- a/roles/ara/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ara-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/ara/molecule/vagrant/INSTALL.rst b/roles/ara/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/ara/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/ara/molecule/vagrant/molecule.yml b/roles/ara/molecule/vagrant/molecule.yml deleted file mode 100644 index f3d2829..0000000 --- a/roles/ara/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: ara-debian - box: debian/stretch64 - - name: ara-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ara-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/ara/tasks/main.yml b/roles/ara/tasks/main.yml index 2a2b731..852af9b 100644 --- a/roles/ara/tasks/main.yml +++ b/roles/ara/tasks/main.yml @@ -1,13 +1,5 @@ --- # tasks file for ara -- name: install required packages - package: - name: "{{ ara_packages }}" - state: present - register: ara_install_required_packages - until: ara_install_required_packages is succeeded - retries: 3 - - name: install ara pip: name: ara[server] @@ -18,7 +10,7 @@ - name: create ara service import_role: - name: service + name: robertdebock.service - name: find callback_plugins path block: @@ -65,5 +57,3 @@ name: ara state: started enabled: yes - when: - - ansible_virtualization_type != "docker" diff --git a/roles/ara/tox.ini b/roles/ara/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/ara/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/ara/vars/main.yml b/roles/ara/vars/main.yml index b8abd41..16e1359 100644 --- a/roles/ara/vars/main.yml +++ b/roles/ara/vars/main.yml @@ -1,44 +1,11 @@ --- # vars file for ara -_ara_packages: - default: - - gcc - Alpine: - - linux-headers - CentOS: - - gcc - - python-devel - - libffi-devel - - openssl-devel - - redhat-rpm-config - Debian: - - gcc - - python-dev - - libffi-dev - - libssl-dev - Fedora: - - gcc - - python-devel - - libffi-devel - - openssl-devel - - redhat-rpm-config - openSUSE Leap: - - gcc - - python-devel - Ubuntu: - - gcc - - python-dev - - libffi-dev - - libssl-dev - -ara_packages: "{{ _ara_packages[ansible_distribution] | default (_ara_packages['default'] ) }}" - _ara_binary_location: default: /usr/bin Debian: /usr/local/bin - Ubuntu: /usr/local/bin + RedHat: /usr/local/bin -ara_binary_location: "{{ _ara_binary_location[ansible_distribution] | default(_ara_binary_location['default']) }}" +ara_binary_location: "{{ _ara_binary_location[ansible_os_family] | default(_ara_binary_location['default']) }}" ara_setup_command_python2: python -m ara.setup.callback_plugins ara_setup_command_python3: python3 -m ara.setup.callback_plugins diff --git a/roles/atom/.ansible-lint b/roles/atom/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/atom/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/atom/.github/ISSUE_TEMPLATE/bug_report.md b/roles/atom/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/atom/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/atom/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/atom/.github/settings.yml b/roles/atom/.github/settings.yml index ae357a2..45c678d 100644 --- a/roles/atom/.github/settings.yml +++ b/roles/atom/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install atom on your system. homepage: https://robertdebock.nl/ diff --git a/roles/atom/.gitignore b/roles/atom/.gitignore index 47cf7b9..982db11 100644 --- a/roles/atom/.gitignore +++ b/roles/atom/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log -*.swp \ No newline at end of file +*.swp +.tox diff --git a/roles/atom/.travis.yml b/roles/atom/.travis.yml index 98e6d72..4c4ff64 100644 --- a/roles/atom/.travis.yml +++ b/roles/atom/.travis.yml @@ -1,85 +1,45 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" expectation="fail" - - version="" distro="alpine-latest" expectation="fail" - - version="devel" distro="alpine-latest" expectation="fail" - - version=">=2.7,<2.8" distro="alpine-edge" expectation="fail" - - version="" distro="alpine-edge" expectation="fail" - - version="devel" distro="alpine-edge" expectation="fail" - - version=">=2.7,<2.8" distro="archlinux" expectation="fail" - - version="" distro="archlinux" expectation="fail" - - version="devel" distro="archlinux" expectation="fail" - - version=">=2.7,<2.8" distro="centos-6" expectation="fail" - - version="" distro="centos-6" expectation="fail" - - version="devel" distro="centos-6" expectation="fail" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" expectation="fail" - - env: version="" distro="alpine-edge" expectation="fail" - - env: version="devel" distro="alpine-edge" expectation="fail" - - env: version="devel" distro="alpine-latest" expectation="fail" - - env: version="devel" distro="archlinux" expectation="fail" - - env: version="devel" distro="centos-6" expectation="fail" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/atom/README.md b/roles/atom/README.md index 6e59c8a..ae6750f 100644 --- a/roles/atom/README.md +++ b/roles/atom/README.md @@ -2,14 +2,14 @@ atom ========= Ansible logo -Build status + Build status Install atom on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.atom ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -33,6 +33,7 @@ The machine you are running this on, may need to be prepared. - role: robertdebock.bootstrap ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -70,42 +71,84 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|no|no|no*| -|alpine-latest|no|no|no*| -|archlinux|no|no|no*| -|centos-6|no|no|no*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|latest|no| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| amazonlinux:1 | Package: atom ... Requires: libsecret-1.so.0 ... and ... polkit | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-atom) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-atom) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-atom/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- apt +- dnf +- get_url +- package +- yum +- zypper +``` License ------- diff --git a/roles/atom/meta/.galaxy_install_info b/roles/atom/meta/.galaxy_install_info index 1f0d903..2cd8902 100644 --- a/roles/atom/meta/.galaxy_install_info +++ b/roles/atom/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:13 2019', version: 2.0.6} +install_date: Mon Dec 16 06:44:34 2019 +version: 2.2.2 diff --git a/roles/atom/meta/exception.yml b/roles/atom/meta/exception.yml new file mode 100644 index 0000000..dbb2862 --- /dev/null +++ b/roles/atom/meta/exception.yml @@ -0,0 +1,4 @@ +--- +exceptions: + - variation: amazonlinux:1 + reason: "Package: atom ... Requires: libsecret-1.so.0 ... and ... polkit" diff --git a/roles/atom/meta/main.yml b/roles/atom/meta/main.yml index 608bdc3..f97195c 100644 --- a/roles/atom/meta/main.yml +++ b/roles/atom/meta/main.yml @@ -5,22 +5,21 @@ galaxy_info: description: Install atom on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - Candidate - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - - name: EL - version: - - 6 - - 7 - name: Fedora versions: - all @@ -34,14 +33,8 @@ galaxy_info: galaxy_tags: - atom - - alpine - archlinux - centos - - debian - - el - - fedora - - opensuse - rhel - - ubuntu dependencies: [] diff --git a/roles/atom/molecule/alpine-edge/molecule.yml b/roles/atom/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 4c2b2cf..0000000 --- a/roles/atom/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/atom/molecule/alpine-latest/molecule.yml b/roles/atom/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 9fb38d2..0000000 --- a/roles/atom/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/atom/molecule/archlinux/molecule.yml b/roles/atom/molecule/archlinux/molecule.yml deleted file mode 100644 index d64b2f7..0000000 --- a/roles/atom/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/atom/molecule/centos-6/molecule.yml b/roles/atom/molecule/centos-6/molecule.yml deleted file mode 100644 index 275026e..0000000 --- a/roles/atom/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/atom/molecule/centos-latest/molecule.yml b/roles/atom/molecule/centos-latest/molecule.yml deleted file mode 100644 index ae878ac..0000000 --- a/roles/atom/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/atom/molecule/debian-stable/molecule.yml b/roles/atom/molecule/debian-stable/molecule.yml deleted file mode 100644 index 42d0d0b..0000000 --- a/roles/atom/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/atom/molecule/debian-unstable/molecule.yml b/roles/atom/molecule/debian-unstable/molecule.yml deleted file mode 100644 index ed276ae..0000000 --- a/roles/atom/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/atom/molecule/default/molecule.yml b/roles/atom/molecule/default/molecule.yml index 9ade336..bb9e5d7 100644 --- a/roles/atom/molecule/default/molecule.yml +++ b/roles/atom/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: atom-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: atom-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: atom-archlinux - image: archlinux/base - pre_build_image: yes - - name: atom-centos-6 - image: centos:6 - pre_build_image: yes - - name: atom-centos-latest - image: centos:latest - pre_build_image: yes - - name: atom-debian-stable - image: debian:stable - pre_build_image: yes - - name: atom-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: atom-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: atom-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: atom-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: atom-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: atom-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: atom-ubuntu-devel - image: ubuntu:devel + - name: "atom-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - atom-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - atom-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/atom/molecule/resources/playbook.yml b/roles/atom/molecule/default/playbook.yml similarity index 100% rename from roles/atom/molecule/resources/playbook.yml rename to roles/atom/molecule/default/playbook.yml diff --git a/roles/atom/molecule/resources/prepare.yml b/roles/atom/molecule/default/prepare.yml similarity index 100% rename from roles/atom/molecule/resources/prepare.yml rename to roles/atom/molecule/default/prepare.yml diff --git a/roles/atom/molecule/ec2/README.md b/roles/atom/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/atom/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/atom/molecule/ec2/create.yml b/roles/atom/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/atom/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/atom/molecule/ec2/destroy.yml b/roles/atom/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/atom/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/atom/molecule/ec2/molecule.yml b/roles/atom/molecule/ec2/molecule.yml deleted file mode 100644 index 068614b..0000000 --- a/roles/atom/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: atom-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: atom-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: atom-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: atom-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: atom-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: atom-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - atom-ubuntu-18.04: - ansible_user: ubuntu - atom-centos-7: - ansible_user: centos - atom-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/atom/molecule/fedora-latest/molecule.yml b/roles/atom/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 241c699..0000000 --- a/roles/atom/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/atom/molecule/fedora-rawhide/molecule.yml b/roles/atom/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index dfa047c..0000000 --- a/roles/atom/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/atom/molecule/opensuse-leap/molecule.yml b/roles/atom/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 11c2dd4..0000000 --- a/roles/atom/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/atom/molecule/ubuntu-devel/molecule.yml b/roles/atom/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 0ee1efe..0000000 --- a/roles/atom/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/atom/molecule/ubuntu-latest/molecule.yml b/roles/atom/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 8deac3d..0000000 --- a/roles/atom/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/atom/molecule/ubuntu-rolling/molecule.yml b/roles/atom/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 80b1495..0000000 --- a/roles/atom/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: atom-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/atom/molecule/vagrant/molecule.yml b/roles/atom/molecule/vagrant/molecule.yml deleted file mode 100644 index 23b9703..0000000 --- a/roles/atom/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: atom-debian - box: debian/stretch64 - - name: atom-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - atom-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/atom/tasks/main.yml b/roles/atom/tasks/main.yml index 6501832..b5497ee 100644 --- a/roles/atom/tasks/main.yml +++ b/roles/atom/tasks/main.yml @@ -1,16 +1,5 @@ --- # tasks file for atom -- name: test veriables and environment - assert: - that: - - ansible_pkg_mgr is defined - - ansible_pkg_mgr == "yum" or - ansible_pkg_mgr == "dnf" or - ansible_pkg_mgr == "apt" or - ansible_pkg_mgr == "zypper" - - atom_package_url is defined - - atom_package is defined - - name: install requirements package: name: "{{ atom_requirements }}" diff --git a/roles/atom/tox.ini b/roles/atom/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/atom/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/bootstrap/.ansible-lint b/roles/bootstrap/.ansible-lint new file mode 100644 index 0000000..788f1ce --- /dev/null +++ b/roles/bootstrap/.ansible-lint @@ -0,0 +1,3 @@ +# +# Ansible managed +# diff --git a/roles/bootstrap/.github/ISSUE_TEMPLATE/bug_report.md b/roles/bootstrap/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/bootstrap/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/bootstrap/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/bootstrap/.github/settings.yml b/roles/bootstrap/.github/settings.yml index 7377564..eaf6fb8 100644 --- a/roles/bootstrap/.github/settings.yml +++ b/roles/bootstrap/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Prepare your system to be managed by Ansible. homepage: https://robertdebock.nl/ diff --git a/roles/bootstrap/.gitignore b/roles/bootstrap/.gitignore index 2ba7fd3..982db11 100644 --- a/roles/bootstrap/.gitignore +++ b/roles/bootstrap/.gitignore @@ -1,5 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp -*_ssh_key -*_ssh_key.pub +.tox diff --git a/roles/bootstrap/.travis.yml b/roles/bootstrap/.travis.yml index a78ecb5..41c7894 100644 --- a/roles/bootstrap/.travis.yml +++ b/roles/bootstrap/.travis.yml @@ -1,101 +1,50 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="kali" - - version="" distro="kali" - - version="devel" distro="kali" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - # - version=">=2.7,<2.8" distro="redhat-7" - # - version="" distro="redhat-7" - # - version="devel" distro="redhat-7" - # - version=">=2.7,<2.8" distro="redhat-latest" - # - version="" distro="redhat-latest" - # - version="devel" distro="redhat-latest" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="oraclelinux" tag="7" + - image="centos" + - image="oraclelinux" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version=">=2.7,<2.8" distro="gentoo" - - env: version="" distro="gentoo" - - env: version="devel" distro="gentoo" - - env: version="devel" distro="gentoo" - - env: version="devel" distro="kali" - - env: version="devel" distro="opensuse-leap" - # - version="devel" distro="redhat-7" - # - version="devel" distro="redhat-latest" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/bootstrap/CONTRIBUTING.md b/roles/bootstrap/CONTRIBUTING.md index 3209430..71d0749 100644 --- a/roles/bootstrap/CONTRIBUTING.md +++ b/roles/bootstrap/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/bootstrap/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/bootstrap), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/bootstrap.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/bootstrap/README.md b/roles/bootstrap/README.md index 19957ac..fcfa0d2 100644 --- a/roles/bootstrap/README.md +++ b/roles/bootstrap/README.md @@ -2,14 +2,14 @@ bootstrap ========= Ansible logo -Build status + Build status Prepare your system to be managed by Ansible. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -19,17 +19,26 @@ This example is taken from `molecule/resources/playbook.yml`: roles: - robertdebock.bootstrap +``` + +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. +```yaml +No preparation required. +``` + +After running this role, this playbook runs to verify that everything works, this may be a good example how you can use this role. +```yaml +--- +- name: Verify + hosts: all + become: no + gather_facts: yes tasks: - name: test connection ping: ``` -The machine you are running this on, may need to be prepared. -```yaml -No preparation required. -``` - Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -43,10 +52,6 @@ These variables are set in `defaults/main.yml`: # The user to use to connect to machines. bootstrap_user: root -# Installed software to support modules flagged as "preview" (i.e. mysql_db). -# "yes", "no" or unset are valid. -bootstrap_preview: yes - # Do you want to wait for the host to be available? bootstrap_wait_for_host: no @@ -81,46 +86,62 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|kali|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tags| +|---------|----| +|amazon|all| +|alpine|all| +|archlinux|all| +|debian|all| +|el|7, 8| +|fedora|all| +|opensuse|all| +|sles|all| +|ubuntu|artful, bionic| -A single star means the build may fail, it's marked as an experimental build. +The minimum version of Ansible required is 2.8 but tests have been done to: +- The previous version, on version lower. +- The current version. +- The development version. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-bootstrap) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-bootstrap) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-bootstrap/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` License ------- diff --git a/roles/bootstrap/defaults/main.yml b/roles/bootstrap/defaults/main.yml index 1bc6c52..4e0673c 100644 --- a/roles/bootstrap/defaults/main.yml +++ b/roles/bootstrap/defaults/main.yml @@ -4,10 +4,6 @@ # The user to use to connect to machines. bootstrap_user: root -# Installed software to support modules flagged as "preview" (i.e. mysql_db). -# "yes", "no" or unset are valid. -bootstrap_preview: yes - # Do you want to wait for the host to be available? bootstrap_wait_for_host: no diff --git a/roles/bootstrap/handlers/main.yml b/roles/bootstrap/handlers/main.yml deleted file mode 100644 index 7e42611..0000000 --- a/roles/bootstrap/handlers/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -# handlers file for bootstrap -- name: gather facts - setup: - become: no - -- name: add community repository for apk - lineinfile: - path: /etc/apk/repositories - line: "{{ bootstrap_alpine_community_repo }}" diff --git a/roles/bootstrap/meta/.galaxy_install_info b/roles/bootstrap/meta/.galaxy_install_info index 8b6458c..858d9c6 100644 --- a/roles/bootstrap/meta/.galaxy_install_info +++ b/roles/bootstrap/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:18 2019', version: 3.4.4} +install_date: Mon Dec 16 06:44:42 2019 +version: 4.0.2 diff --git a/roles/bootstrap/meta/main.yml b/roles/bootstrap/meta/main.yml index 50ebcc2..b776686 100644 --- a/roles/bootstrap/meta/main.yml +++ b/roles/bootstrap/meta/main.yml @@ -5,40 +5,33 @@ galaxy_info: description: Prepare your system to be managed by Ansible. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - - name: Alpine - versions: - - all - name: Amazon versions: - all + - name: Alpine + versions: + - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all - - name: FreeBSD - versions: - - 10.4 - - 11.2 - - name: OpenBSD - versions: - - all - name: OpenSUSE versions: - all - name: SLES - verions: + versions: - all - name: Ubuntu versions: @@ -46,22 +39,11 @@ galaxy_info: - bionic galaxy_tags: - - alpine - bootstrap - centos - - debian - - el - - fedora - - freebsd - - gentoo - installer - - kali - - openbsd - - opensuse - - rhel - server - - sudo - system - - ubuntu + - oraclelinux dependencies: [] diff --git a/roles/bootstrap/molecule/alpine-edge/molecule.yml b/roles/bootstrap/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 929f360..0000000 --- a/roles/bootstrap/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/bootstrap/molecule/alpine-latest/molecule.yml b/roles/bootstrap/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 8839da5..0000000 --- a/roles/bootstrap/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/bootstrap/molecule/archlinux/molecule.yml b/roles/bootstrap/molecule/archlinux/molecule.yml deleted file mode 100644 index 36965c5..0000000 --- a/roles/bootstrap/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/bootstrap/molecule/centos-6/molecule.yml b/roles/bootstrap/molecule/centos-6/molecule.yml deleted file mode 100644 index 642b8af..0000000 --- a/roles/bootstrap/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/bootstrap/molecule/centos-latest/molecule.yml b/roles/bootstrap/molecule/centos-latest/molecule.yml deleted file mode 100644 index 6cb7429..0000000 --- a/roles/bootstrap/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/bootstrap/molecule/debian-stable/molecule.yml b/roles/bootstrap/molecule/debian-stable/molecule.yml deleted file mode 100644 index 0786804..0000000 --- a/roles/bootstrap/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/bootstrap/molecule/debian-unstable/molecule.yml b/roles/bootstrap/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 8345e2b..0000000 --- a/roles/bootstrap/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/bootstrap/molecule/default/molecule.yml b/roles/bootstrap/molecule/default/molecule.yml index c1dd6ab..fe7eb98 100644 --- a/roles/bootstrap/molecule/default/molecule.yml +++ b/roles/bootstrap/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,77 +11,19 @@ lint: driver: name: docker platforms: - - name: bootstrap-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: bootstrap-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: bootstrap-archlinux - image: archlinux/base - pre_build_image: yes - - name: bootstrap-centos-6 - image: centos:6 - pre_build_image: yes - - name: bootstrap-centos-latest - image: centos:latest - pre_build_image: yes - - name: bootstrap-debian-stable - image: debian:stable - pre_build_image: yes - - name: bootstrap-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: bootstrap-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: bootstrap-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org - - name: bootstrap-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: bootstrap-rhel-7 - image: ubi7/ubi - pre_build_image: yes - registry: - url: registry.access.redhat.com - credentials: - username: $registryredhatiousername - password: $registryredhatiopassword - - name: bootstrap-rhel-latest - image: ubi8/ubi - pre_build_image: yes - registry: - url: registry.access.redhat.com - - name: bootstrap-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: bootstrap-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: bootstrap-ubuntu-devel - image: ubuntu:devel + - name: "bootstrap-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - converge: ../resources/playbook.yml +verifier: + name: ansible lint: name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - bootstrap-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - bootstrap-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 + enabled: no scenario: name: default diff --git a/roles/bootstrap/molecule/resources/playbook.yml b/roles/bootstrap/molecule/default/playbook.yml similarity index 67% rename from roles/bootstrap/molecule/resources/playbook.yml rename to roles/bootstrap/molecule/default/playbook.yml index 55a1344..f74ea59 100644 --- a/roles/bootstrap/molecule/resources/playbook.yml +++ b/roles/bootstrap/molecule/default/playbook.yml @@ -6,7 +6,3 @@ roles: - ansible-role-bootstrap - - tasks: - - name: test connection - ping: diff --git a/roles/bootstrap/molecule/default/verify.yml b/roles/bootstrap/molecule/default/verify.yml new file mode 100644 index 0000000..e7ef038 --- /dev/null +++ b/roles/bootstrap/molecule/default/verify.yml @@ -0,0 +1,9 @@ +--- +- name: Verify + hosts: all + become: no + gather_facts: yes + + tasks: + - name: test connection + ping: diff --git a/roles/bootstrap/molecule/digitalocean/README.md b/roles/bootstrap/molecule/digitalocean/README.md deleted file mode 100644 index e8f9e1f..0000000 --- a/roles/bootstrap/molecule/digitalocean/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Testing on Digitalocean - -In order to test on Digitalocean, set the `DO_API_TOKEN`: - -``` -export DO_API_TOKEN=abcdefghijklmnopqrstuvwxyz0123456789 -``` - -Run the tests: - -``` -molecule test --scenario-name digitalocean -``` diff --git a/roles/bootstrap/molecule/digitalocean/create.yml b/roles/bootstrap/molecule/digitalocean/create.yml deleted file mode 100644 index c0e412b..0000000 --- a/roles/bootstrap/molecule/digitalocean/create.yml +++ /dev/null @@ -1,84 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - - vars: - ssh_user: root - ssh_port: 22 - ssh_identity_file: /tmp/molecule_ssh_key - - tasks: - - name: create ssh key - command: ssh-keygen -f {{ ssh_identity_file }} - args: - creates: "{{ ssh_identity_file }}" - - - name: save ssh key into a variable - command: cat {{ ssh_identity_file }}.pub - register: molecule_ssh_key - changed_when: no - - - name: upload digitalocean ssh key - digital_ocean_sshkey: - name: "{{ ssh_identity_file }}" - state: present - ssh_pub_key: "{{ molecule_ssh_key.stdout }}" - register: digital_ocean_ssh_key - - - name: start digitalocean droplet - digital_ocean: - name: "{{ item.name }}" - state: present - size_id: "{{ item.size_id | default('2gb') }}" - region_id: "{{ item.region_id | default('ams3') }}" - image_id: "{{ item.image_id | default('centos-7-x64') }}" - unique_name: yes - ssh_key_ids: - - "{{ digital_ocean_ssh_key.data.ssh_key.id }}" - register: server - with_items: - - "{{ molecule_yml.platforms }}" - - - name: render sshd_config for instances - template: - src: sshd_config.j2 - dest: "{{ molecule_ephemeral_directory }}/sshd_config" - when: server.changed | bool - - - name: wait for ssh_port to be available - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.droplet.ip_address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: - - "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.droplet.id }}", - 'address': "{{ item.droplet.ip_address}}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ ssh_identity_file }}", } - with_items: "{{ server.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/bootstrap/molecule/digitalocean/destroy.yml b/roles/bootstrap/molecule/digitalocean/destroy.yml deleted file mode 100644 index 57a35da..0000000 --- a/roles/bootstrap/molecule/digitalocean/destroy.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - - tasks: - - name: destroy digitalocean droplet - digital_ocean: - name: "{{ item.name }}" - state: absent - unique_name: yes - with_items: - - "{{ molecule_yml.platforms }}" - register: server - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/bootstrap/molecule/digitalocean/molecule.yml b/roles/bootstrap/molecule/digitalocean/molecule.yml deleted file mode 100644 index 245e963..0000000 --- a/roles/bootstrap/molecule/digitalocean/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -driver: - name: delegated -lint: - name: yamllint -platforms: - - name: bootstrap-fedora - image_id: fedora-28-x64 -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - ssh_connection: - host_key_checking: no - ssh_args: -C -o ControlMaster=auto -o ControlPersist=60s -F ${MOLECULE_EPHEMERAL_DIRECTORY}/sshd_config -scenario: - name: digitalocean diff --git a/roles/bootstrap/molecule/digitalocean/sshd_config.j2 b/roles/bootstrap/molecule/digitalocean/sshd_config.j2 deleted file mode 100644 index a204f33..0000000 --- a/roles/bootstrap/molecule/digitalocean/sshd_config.j2 +++ /dev/null @@ -1,10 +0,0 @@ -{% for platform in molecule_yml.platforms %} -{% for host in server.results %} -Host {{ platform.name }} - HostName {{ host.droplet.ip_address }} - Port {{ ssh_port }} - IdentityFile {{ ssh_identity_file }} - PreferredAuthentications publickey - User {{ ssh_user }} -{% endfor %} -{% endfor %} diff --git a/roles/bootstrap/molecule/ec2/README.md b/roles/bootstrap/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/bootstrap/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/bootstrap/molecule/ec2/create.yml b/roles/bootstrap/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/bootstrap/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/bootstrap/molecule/ec2/destroy.yml b/roles/bootstrap/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/bootstrap/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/bootstrap/molecule/ec2/molecule.yml b/roles/bootstrap/molecule/ec2/molecule.yml deleted file mode 100644 index b5efc7a..0000000 --- a/roles/bootstrap/molecule/ec2/molecule.yml +++ /dev/null @@ -1,80 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: bootstrap-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: bootstrap-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: bootstrap-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: bootstrap-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: bootstrap-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: bootstrap-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - bootstrap-ubuntu-18.04: - ansible_user: ubuntu - bootstrap-centos-7: - ansible_user: centos - bootstrap-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/bootstrap/molecule/fedora-latest/molecule.yml b/roles/bootstrap/molecule/fedora-latest/molecule.yml deleted file mode 100644 index da4942d..0000000 --- a/roles/bootstrap/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/bootstrap/molecule/fedora-rawhide/molecule.yml b/roles/bootstrap/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 71c82d4..0000000 --- a/roles/bootstrap/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/bootstrap/molecule/gentoo/molecule.yml b/roles/bootstrap/molecule/gentoo/molecule.yml deleted file mode 100644 index 026f1c7..0000000 --- a/roles/bootstrap/molecule/gentoo/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -driver: - name: docker -lint: - name: yamllint -platforms: - - name: bootstrap-gentoo - image: gentoo/stage3-amd64 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: gentoo diff --git a/roles/bootstrap/molecule/kali/molecule.yml b/roles/bootstrap/molecule/kali/molecule.yml deleted file mode 100644 index f07e4f7..0000000 --- a/roles/bootstrap/molecule/kali/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -driver: - name: docker -lint: - name: yamllint -platforms: - - name: bootstrap-kali - image: kalilinux/kali-linux-docker - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: kali diff --git a/roles/bootstrap/molecule/opensuse-leap/molecule.yml b/roles/bootstrap/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 645bf44..0000000 --- a/roles/bootstrap/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/bootstrap/molecule/redhat-7/molecule.yml b/roles/bootstrap/molecule/redhat-7/molecule.yml deleted file mode 100644 index 9a528bf..0000000 --- a/roles/bootstrap/molecule/redhat-7/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-rhel-7 - image: ubi7/ubi - pre_build_image: yes - registry: - url: registry.access.redhat.com - credentials: - username: $registryredhatiousername - password: $registryredhatiopassword -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: redhat-7 diff --git a/roles/bootstrap/molecule/redhat-latest/molecule.yml b/roles/bootstrap/molecule/redhat-latest/molecule.yml deleted file mode 100644 index 21363db..0000000 --- a/roles/bootstrap/molecule/redhat-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-rhel-latest - image: ubi8/ubi - pre_build_image: yes - registry: - url: registry.access.redhat.com - credentials: - username: $registryredhatiousername - password: $registryredhatiopassword -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: redhat-latest diff --git a/roles/bootstrap/molecule/rhel-latest/molecule.yml b/roles/bootstrap/molecule/rhel-latest/molecule.yml deleted file mode 100644 index 5e77cea..0000000 --- a/roles/bootstrap/molecule/rhel-latest/molecule.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-rhel-latest - image: ubi8/ubi - pre_build_image: yes - registry: - url: registry.access.redhat.com -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: rhel-latest diff --git a/roles/bootstrap/molecule/ubuntu-devel/molecule.yml b/roles/bootstrap/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index bdc686d..0000000 --- a/roles/bootstrap/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/bootstrap/molecule/ubuntu-latest/molecule.yml b/roles/bootstrap/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index c8b8b5b..0000000 --- a/roles/bootstrap/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/bootstrap/molecule/ubuntu-rolling/molecule.yml b/roles/bootstrap/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 9ae56d6..0000000 --- a/roles/bootstrap/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: bootstrap-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/bootstrap/molecule/vagrant/INSTALL.rst b/roles/bootstrap/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/bootstrap/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/bootstrap/molecule/vagrant/molecule.yml b/roles/bootstrap/molecule/vagrant/molecule.yml deleted file mode 100644 index 9e3a4b5..0000000 --- a/roles/bootstrap/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: bootstrap-debian - box: debian/stretch64 - - name: bootstrap-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - bootstrap-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/bootstrap/tasks/gather_facts.yml b/roles/bootstrap/tasks/gather_facts.yml new file mode 100644 index 0000000..c2f35c7 --- /dev/null +++ b/roles/bootstrap/tasks/gather_facts.yml @@ -0,0 +1,27 @@ +--- +- name: Lookup bootstrap facts + become: no + raw: "cat /etc/os-release" + register: bootstrap_facts + changed_when: no + vars: + ansible_user: "{{ bootstrap_user }}" + +- name: Set bootstrap facts (I) + set_fact: + bootstrap_distribution: "{{ item }}" + bootstrap_distribution_major_version: "{{ bootstrap_facts.stdout_lines | join(',') | regex_replace( + '^.*VERSION_ID=\"(\\d{1,2})(\\.\\d{1,4})*?\".*$','\\1') | default('NA') }}" + loop: "{{ bootstrap_os_family_map | dict2items | map(attribute='value') | flatten }}" + when: + - bootstrap_facts.rc == 0 + - bootstrap_distribution is not defined + - bootstrap_facts.stdout is regex('PRETTY_NAME=.'~ bootstrap_search[item] | default(item) ~'.*') + +- name: Set bootstrap facts (II) + set_fact: + bootstrap_os_family: "{{ item.key }}" + loop: "{{ bootstrap_os_family_map | dict2items }}" + loop_control: + label: "{{ item.key }}" + when: bootstrap_distribution in item.value diff --git a/roles/bootstrap/tasks/install.yml b/roles/bootstrap/tasks/install.yml deleted file mode 100644 index dfc2354..0000000 --- a/roles/bootstrap/tasks/install.yml +++ /dev/null @@ -1,101 +0,0 @@ ---- -- name: install using registered package manager - remote_user: "{{ bootstrap_remote_user | default(omit) }}" - block: - - name: install software with apk - raw: "apk update ; apk add {{ bootstrap_apk_packages }}" - when: - - apk.rc == 0 - register: apkresult - changed_when: - - "'Installing' in apkresult.stdout" - until: apkresult is succeeded - retries: "{{ bootstrap_retries }}" - notify: - - add community repository for apk - - - name: install software with apt-get - raw: "apt-get update ; LANG=C apt-get -y install {{ bootstrap_apt_packages }}" - when: - - apt_get.rc == 0 - - zypper.rc != 0 - register: apt_getresult - changed_when: - - "' 0 newly installed' not in apt_getresult.stdout" - until: apt_getresult is succeeded - retries: "{{ bootstrap_retries }}" - - - name: install software with dnf - raw: "LANG=C dnf -y install {{ bootstrap_dnf_packages }}" - when: - - dnf.rc == 0 - register: dnfresult - changed_when: - - "'Nothing' not in dnfresult.stdout" - until: dnfresult is succeeded - retries: "{{ bootstrap_retries }}" - - - name: install software with emerge - raw: "{{ bootstrap_emerge_command }}" - when: - - emerge.rc == 0 - register: emergeresult - changed_when: - - "'changed' in emergeresult.stdout" - until: emergeresult is succeeded - retries: "{{ bootstrap_retries }}" - - - name: install software with pacman - raw: "pacman -Sy ; pacman -T {{ bootstrap_pacman_packages }} || LANG=C pacman -S --noconfirm {{ bootstrap_pacman_packages }}" - when: - - pacman.rc == 0 - register: pacmanresult - changed_when: - - "' installing python' in pacmanresult.stdout" - until: pacmanresult is succeeded - retries: "{{ bootstrap_retries }}" - - - name: install software with pkg - raw: > - ASSUME_ALWAYS_YES=YES LANG=C - pkg install {{ bootstrap_pkg_packages }} - ; ln -s /usr/local/bin/python /usr/bin/python - || exit 0 - when: - - pkg.rc == 0 - register: pkgresult - changed_when: - - "'Extracting python' in pkgresult.stdout" - until: pkgresult is succeeded - retries: "{{ bootstrap_retries }}" - - - name: install software with pkg_add - raw: LANG=C pkg_add -Iz {{ bootstrap_pkg_add_packages }} - when: - - pkg_add.rc == 0 - register: pkg_add_getresult - changed_when: - - "': ok' in pkg_add_getresult.stdout" - until: pkg_add_getresult is succeeded - retries: "{{ bootstrap_retries }}" - - - name: install software with yum - raw: "LANG=C yum -y install {{ bootstrap_yum_packages }}" - when: - - yum.rc == 0 - register: yumresult - changed_when: - - "'Nothing' not in yumresult.stdout" - until: yumresult is succeeded - retries: "{{ bootstrap_retries }}" - - - name: install software with zypper - raw: "LANG=C zypper -n install {{ bootstrap_zypper_packages }}" - when: - - zypper.rc == 0 - register: zypperresult - changed_when: - - "'Nothing' not in zypperresult.stdout" - failed_when: no - until: zypperresult is succeeded - retries: "{{ bootstrap_retries }}" diff --git a/roles/bootstrap/tasks/main.yml b/roles/bootstrap/tasks/main.yml index 5ba01f7..8408a16 100644 --- a/roles/bootstrap/tasks/main.yml +++ b/roles/bootstrap/tasks/main.yml @@ -1,6 +1,6 @@ --- # tasks file for bootstrap -- name: wait for the host +- name: Wait for host wait_for: port: "{{ ansible_port | default('22') }}" host: "{{ (ansible_ssh_host | default(ansible_host) | default(inventory_hostname)) }}" @@ -11,54 +11,46 @@ - ansible_connection != "docker" - bootstrap_wait_for_host | bool -- name: test connection, otherwise register package manager +- name: Prepare system block: - - name: test connection (allowed to fail) + - name: Test connection wait_for_connection: timeout: "{{ bootstrap_timeout }}" register: bootstrap_connect changed_when: no - rescue: - - name: register package manager - include_tasks: register.yml + - name: Gather bootstrap facts + include_tasks: "gather_facts.yml" - - name: install using registered package manager - include_tasks: install.yml + - name: Install bootstrap packages + raw: "{{ bootstrap_install.raw }}" + register: bootstrap_install_packages + changed_when: (bootstrap_install.stdout_regex in bootstrap_install_packages.stdout and + bootstrap_os_family in ['Alpine', 'Archlinux', 'Gentoo']) or ( + bootstrap_install.stdout_regex not in bootstrap_install_packages.stdout and + bootstrap_os_family in ['Debian', 'RedHat', 'Suse']) + until: bootstrap_install_packages is succeeded + retries: "{{ bootstrap_retries }}" + vars: + ansible_user: "{{ bootstrap_user }}" + always: + - name: Set bootstrap ansible_user + set_fact: + bootstrap_ansible_user: "{{ ansible_user | default(omit) if bootstrap_connect is succeeded else bootstrap_user }}" + changed_when: no -- name: gather facts - setup: - become: no +- name: Ensure system is prepared + block: + - name: Gather ansible facts + setup: -- name: install bootstrap packages - package: - name: "{{ bootstrap_packages }}" - state: present - register: packageresult - until: packageresult is succeeded - -- name: install software to support stable modules - package: - name: "{{ bootstrap_stable_packages }}" - state: present - when: - - bootstrap_stable_packages is defined - register: packagestableresult - until: packagestableresult is succeeded - notify: - - gather facts - -- name: install software to support preview modules - package: - name: "{{ bootstrap_preview_packages }}" - state: present - when: - - bootstrap_preview | bool - - bootstrap_preview_packages is defined - register: packagepreviewresult - until: packagepreviewresult is succeeded - notify: - - gather facts - -- name: flush handlers - meta: flush_handlers + - name: Install bootstrap packages + package: + name: "{{ item }}" + state: present + loop: "{{ bootstrap_facts_packages.split() }}" + register: bootstrap_install_facts_packages + until: bootstrap_install_facts_packages is succeeded + retries: "{{ bootstrap_retries }}" + vars: + ansible_user: "{{ bootstrap_ansible_user | default(omit) }}" diff --git a/roles/bootstrap/tasks/register.yml b/roles/bootstrap/tasks/register.yml deleted file mode 100644 index 2fb48e5..0000000 --- a/roles/bootstrap/tasks/register.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- -- name: register package manager - remote_user: "{{ bootstrap_remote_user | default(omit) }}" - become: no - check_mode: no - block: - - - name: register apk - raw: apk --version - register: apk - changed_when: no - failed_when: no - - - name: register apt_get - raw: apt-get --version - register: apt_get - changed_when: no - failed_when: no - - - name: register dnf - raw: dnf --version - register: dnf - changed_when: no - failed_when: no - - - name: register emerge - raw: emerge --version - register: emerge - changed_when: no - failed_when: no - - - name: register pacman - raw: pacman --version - register: pacman - changed_when: no - failed_when: no - - - name: register pkg - raw: pkg --version - register: pkg - changed_when: no - failed_when: no - - - name: register pkg_add - raw: pkg_info - register: pkg_add - changed_when: no - failed_when: no - - - name: register yum - raw: yum --version - register: yum - changed_when: no - failed_when: no - - - name: register zypper - raw: zypper --version - register: zypper - changed_when: no - failed_when: no diff --git a/roles/bootstrap/tox.ini b/roles/bootstrap/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/bootstrap/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/bootstrap/vars/main.yml b/roles/bootstrap/vars/main.yml index cb0c35b..874becf 100644 --- a/roles/bootstrap/vars/main.yml +++ b/roles/bootstrap/vars/main.yml @@ -1,189 +1,69 @@ --- # vars file for bootstrap - -bootstrap_remote_user: "{{ (ansible_user | default(omit, true)) if bootstrap_connect is succeeded else bootstrap_user }}" - -# A string containing all packages required to be installed using the `raw` -# module, separated by a space. -bootstrap_apk_packages: python sudo -bootstrap_apt_packages: python sudo -bootstrap_dnf_packages: python3 sudo -bootstrap_emerge_packages: python sudo gentoolkit -bootstrap_pacman_packages: python sudo -bootstrap_pkg_add_packages: python-3* sudo-- -bootstrap_pkg_packages: python sudo -bootstrap_yum_packages: python2 sudo -bootstrap_zypper_packages: python python-xml sudo - -bootstrap_alpine_community_repo: "http://dl-cdn.alpinelinux.org/alpine/v{{ ansible_distribution_version.split('.')[0] }}.{{ ansible_distribution_version.split('.')[1] }}/community" - -# Some distributions do not have the fact `ansible_distribution_major_version`, -# as a workaround it's determined here, saved to another variable and used -# later. - -bootstrap_ansible_distribution_major_version: ansible_distibution_major_version | default('none') - -# A dictionary based on Ansible facts `ansible_distribution` and -# `ansible_distribution_major_version` containing a list of packages. -# This list is very similar to the `boostrap_{{ ansible_pkg_mgr }}_package` -# list. This dictionary is used to be able to update these packages. _bootstrap_packages: - default: - - python - - sudo + Alpine: python3 sudo + Archlinux: python sudo + Debian: python3 sudo gnupg python3-apt + Gentoo: python sudo gentoolkit + RedHat: python3 sudo + Suse: python python-xml sudo + Amazon: python sudo + CentOS_7: python sudo + Debian_8: python sudo gnupg + Debian_9: python sudo gnupg + RedHat_7: python sudo + +_bootstrap_install: Alpine: - - python - - sudo - - shadow + raw: "LANG=C apk update ; apk add {{ bootstrap_packages }}" + stdout_regex: 'Installing' Archlinux: - - iproute2 - - python - - sudo - CentOS: - - iproute - - python2 - - sudo + raw: "LANG=C pacman -Sy --noconfirm {{ bootstrap_packages }}" + stdout_regex: ' installing python' Debian: - - aptitude - - python - - sudo - Fedora: - - iproute - - python3 - - python3-dnf - - sudo - FreeBSD: - - python - - sudo + raw: "LANG=C apt-get update && apt-get install -y {{ bootstrap_packages }}" + stdout_regex: ' 0 newly installed' Gentoo: - - python - - sudo - - gentoolkit - OpenBSD: - - python%3 - - sudo-- - openSUSE Leap: - - iproute2 - - python - - python-xml - - sudo - RedHat-7: - - iproute - - python - - sudo + raw: "LANG=C equery l {{ bootstrap_packages }} || + (emaint -a sync ; emerge -qkv {{ bootstrap_packages }} ; echo 'changed')" + stdout_regex: 'changed' RedHat: - - iproute - - python3 - - sudo - Ubuntu: - - iproute2 - - python3 - - sudo + raw: "LANG=C yum -y install {{ bootstrap_packages }}" + stdout_regex: 'Nothing' + Suse: + raw: "LANG=C zypper -n install {{ bootstrap_packages }}" + stdout_regex: 'Nothing' -bootstrap_packages: "{{ _bootstrap_packages[ansible_distribution ~ '-' ~ ansible_distribution_major_version] | default(_bootstrap_packages[ansible_distribution] | default(_bootstrap_packages['default'])) }}" +# See URL for available OS families and search queries +# https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/distribution.py +bootstrap_os_family_map: + Alpine: [Alpine] + Archlinux: [Archlinux, Antergos, Manjaro] + Debian: [Debian, Ubuntu, Raspbian, Neon, KDE neon, + Linux Mint, SteamOS, Devuan, Kali, 'Cumulus Linux'] + Gentoo: [Gentoo, Funtoo] + RedHat: [RedHat, Fedora, CentOS, Scientific, SLC, + Ascendos, CloudLinux, PSBM, OracleLinux, OVS, + OEL, Amazon, Virtuozzo, XenServer, Alibaba] + Suse: [SLED, 'openSUSE Tumbleweed', 'openSUSE Leap', + SLES_SAP, SUSE_LINUX, SLES, openSUSE, SuSE] -# A dictionary based on Ansible facts `ansible_distribution` and -# `ansible_distribution_major_version` containing a list of packages. The -# packages in these lists support modules marked as `stable`. -_bootstrap_stable_packages: - default: - - python - Alpine: - - acl - - ca-certificates - - py-simplejson - CentOS-6: - - acl - - python-simplejson - - yum-plugin-ovl - CentOS-7: - - acl - - yum-plugin-ovl - Debian: - - acl - - ca-certificates - - python-apt - - python-simplejson - Fedora: - - acl - - polkit - - python-devel - - python-simplejson - OpenBSD: - - py-simplejson-- - openSUSE Leap: - - acl - - ca-certificates - RedHat: - - acl - Ubuntu: - - acl - - ca-certificates - - python3-apt - - python3-simplejson +bootstrap_search: + Archlinux: 'Arch Linux' + OracleLinux: 'Oracle Linux' + RedHat: 'Red Hat' -bootstrap_stable_packages: "{{ _bootstrap_stable_packages[ansible_distribution ~ '-' ~ bootstrap_ansible_distribution_major_version] | default(_bootstrap_stable_packages[ansible_distribution] | default(_bootstrap_stable_packages['default'])) }}" +# Map the right set of packages, based on gathered bootstrap facts. +bootstrap_packages: "{{ _bootstrap_packages[bootstrap_distribution ~'_'~ bootstrap_distribution_major_version]|default( + _bootstrap_packages[bootstrap_distribution])|default( + _bootstrap_packages[bootstrap_os_family]) }}" -# A dictionary based on Ansible facts `ansible_distribution` and -# `ansible_distribution_major_version` containing a list of packages. The -# packages in these lists support modules marked as `preview`. -_bootstrap_preview_packages: - default: - - lvm2 - - tar - - unzip - - gzip - - xz - CentOS: - - lvm2 - - tar - - unzip - - gzip - - xz - Debian: - - apt-transport-https - - gzip - - lvm2 - - tar - - unzip - - xz-utils - Fedora: - - lvm2 - - tar - - unzip - - gzip - - xz - FreeBSD: - - unzip - - gzip - - xz - Gentoo: - - gzip - - tar - - unzip - Kali: - - lvm2 - - tar - - unzip - - gzip - - xz-utils - Kali GNU/Linux: - - lvm2 - - tar - - unzip - - gzip - - xz-utils - OpenBSD: - - unzip-- - - xz - Ubuntu: - - apt-transport-https - - gzip - - lvm2 - - tar - - unzip - - xz-utils +# Map the right install command, based on gathered bootstrap facts. +bootstrap_install: "{{ _bootstrap_install[bootstrap_distribution ~'_'~ bootstrap_distribution_major_version]|default( + _bootstrap_install[bootstrap_distribution])|default( + _bootstrap_install[bootstrap_os_family]) }}" -bootstrap_preview_packages: "{{ _bootstrap_preview_packages[ansible_distribution] | default(_bootstrap_preview_packages['default']) }}" - -bootstrap_emerge_command: equery l {{ bootstrap_emerge_packages }} || (emaint -a sync ; emerge -qkv {{ bootstrap_emerge_packages }} ; echo "changed") +# Map the right set of packages, based on gathered ansible_facts. +bootstrap_facts_packages: "{{ _bootstrap_packages[ansible_distribution ~'_'~ ansible_distribution_major_version]|default( + _bootstrap_packages[ansible_distribution])|default( + _bootstrap_packages[ansible_os_family]) }}" diff --git a/roles/buildtools/.ansible-lint b/roles/buildtools/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/buildtools/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/buildtools/.github/ISSUE_TEMPLATE/bug_report.md b/roles/buildtools/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/buildtools/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/buildtools/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/buildtools/.github/settings.yml b/roles/buildtools/.github/settings.yml index 8896cbe..4d5d933 100644 --- a/roles/buildtools/.github/settings.yml +++ b/roles/buildtools/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install buildtools on your system. homepage: https://robertdebock.nl/ diff --git a/roles/buildtools/.gitignore b/roles/buildtools/.gitignore index 10b26d1..982db11 100644 --- a/roles/buildtools/.gitignore +++ b/roles/buildtools/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/buildtools/.travis.yml b/roles/buildtools/.travis.yml index 84dc64d..f7d782c 100644 --- a/roles/buildtools/.travis.yml +++ b/roles/buildtools/.travis.yml @@ -1,85 +1,48 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="centos" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/buildtools/CONTRIBUTING.md b/roles/buildtools/CONTRIBUTING.md index 3209430..bfbf40f 100644 --- a/roles/buildtools/CONTRIBUTING.md +++ b/roles/buildtools/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/buildtools/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/buildtools), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/buildtools.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/buildtools/README.md b/roles/buildtools/README.md index 239b381..b2b09ce 100644 --- a/roles/buildtools/README.md +++ b/roles/buildtools/README.md @@ -2,14 +2,14 @@ buildtools ========= Ansible logo -Build status + Build status Install buildtools on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -19,15 +19,9 @@ This example is taken from `molecule/resources/playbook.yml`: roles: - robertdebock.buildtools - - tasks: - - name: run gcc - shell: gcc --version > gcc.version - args: - creates: gcc.version ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -39,6 +33,41 @@ The machine you are running this on, may need to be prepared. - robertdebock.bootstrap ``` +After running this role, this playbook runs to verify that everything works, this may be a good example how you can use this role. +```yaml +--- +- name: Verify + hosts: all + become: no + gather_facts: no + + tasks: + - name: run gcc + command: gcc --version + + - name: run make + command: make --version + + - name: run shasum + command: shasum --version + + - name: run bison + command: bison --version + + - name: find libelf + find: + paths: /usr + patterns: libelf.so.1 + register: buildtools_find_libelf + + - name: assert the results + assert: + that: + - buildtools_find_libelf.matched >= 0 + msg: could not find libelf.so.1 in /usr +``` +``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -76,42 +105,69 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tags| +|---------|----| +|amazon|all| +|alpine|all| +|archlinux|all| +|debian|all| +|el|7, 8| +|fedora|all| +|opensuse|all| +|ubuntu|artful, bionic| + +The minimum version of Ansible required is 2.8 but tests have been done to: + +- The previous version, on version lower. +- The current version. +- The development version. + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| EL | No package matching 'bison' found available, installed or updated | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-buildtools) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-buildtools) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-buildtools/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` License ------- diff --git a/roles/buildtools/meta/.galaxy_install_info b/roles/buildtools/meta/.galaxy_install_info index a36db21..7b9674b 100644 --- a/roles/buildtools/meta/.galaxy_install_info +++ b/roles/buildtools/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:22 2019', version: 2.0.9} +install_date: Mon Dec 16 06:44:47 2019 +version: 2.2.5 diff --git a/roles/buildtools/meta/exception.yml b/roles/buildtools/meta/exception.yml new file mode 100644 index 0000000..02f8e69 --- /dev/null +++ b/roles/buildtools/meta/exception.yml @@ -0,0 +1,4 @@ +--- +exceptions: + - variation: EL + reason: "No package matching 'bison' found available, installed or updated" diff --git a/roles/buildtools/meta/main.yml b/roles/buildtools/meta/main.yml index 2aa73e2..665023a 100644 --- a/roles/buildtools/meta/main.yml +++ b/roles/buildtools/meta/main.yml @@ -5,22 +5,25 @@ galaxy_info: description: Install buildtools on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -33,17 +36,10 @@ galaxy_info: - bionic galaxy_tags: - - alpine - - archlinux - centos - - debian - development - - fedora - installer - - opensuse - packages - - rhel - system - - ubuntu dependencies: [] diff --git a/roles/buildtools/molecule/alpine-edge/molecule.yml b/roles/buildtools/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 4c5e816..0000000 --- a/roles/buildtools/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/buildtools/molecule/alpine-latest/molecule.yml b/roles/buildtools/molecule/alpine-latest/molecule.yml deleted file mode 100644 index b0a5312..0000000 --- a/roles/buildtools/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/buildtools/molecule/archlinux/molecule.yml b/roles/buildtools/molecule/archlinux/molecule.yml deleted file mode 100644 index 1e59e31..0000000 --- a/roles/buildtools/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/buildtools/molecule/centos-6/molecule.yml b/roles/buildtools/molecule/centos-6/molecule.yml deleted file mode 100644 index fcfa3e7..0000000 --- a/roles/buildtools/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/buildtools/molecule/centos-latest/molecule.yml b/roles/buildtools/molecule/centos-latest/molecule.yml deleted file mode 100644 index 2170624..0000000 --- a/roles/buildtools/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/buildtools/molecule/debian-stable/molecule.yml b/roles/buildtools/molecule/debian-stable/molecule.yml deleted file mode 100644 index 085a31c..0000000 --- a/roles/buildtools/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/buildtools/molecule/debian-unstable/molecule.yml b/roles/buildtools/molecule/debian-unstable/molecule.yml deleted file mode 100644 index ffd0d30..0000000 --- a/roles/buildtools/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/buildtools/molecule/default/molecule.yml b/roles/buildtools/molecule/default/molecule.yml index da143ac..ebe4a40 100644 --- a/roles/buildtools/molecule/default/molecule.yml +++ b/roles/buildtools/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,19 @@ lint: driver: name: docker platforms: - - name: buildtools-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: buildtools-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: buildtools-archlinux - image: archlinux/base - pre_build_image: yes - - name: buildtools-centos-6 - image: centos:6 - pre_build_image: yes - - name: buildtools-centos-latest - image: centos:latest - pre_build_image: yes - - name: buildtools-debian-stable - image: debian:stable - pre_build_image: yes - - name: buildtools-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: buildtools-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: buildtools-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: buildtools-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: buildtools-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: buildtools-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: buildtools-ubuntu-devel - image: ubuntu:devel + - name: "buildtools-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml +verifier: + name: ansible lint: name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - buildtools-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - buildtools-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 + enabled: no scenario: name: default diff --git a/roles/reboot/robertdebock.reboot/molecule/resources/playbook.yml b/roles/buildtools/molecule/default/playbook.yml similarity index 72% rename from roles/reboot/robertdebock.reboot/molecule/resources/playbook.yml rename to roles/buildtools/molecule/default/playbook.yml index 1a33108..4ddc089 100644 --- a/roles/reboot/robertdebock.reboot/molecule/resources/playbook.yml +++ b/roles/buildtools/molecule/default/playbook.yml @@ -5,4 +5,4 @@ gather_facts: yes roles: - - ansible-role-reboot + - ansible-role-buildtools diff --git a/roles/buildtools/molecule/resources/prepare.yml b/roles/buildtools/molecule/default/prepare.yml similarity index 100% rename from roles/buildtools/molecule/resources/prepare.yml rename to roles/buildtools/molecule/default/prepare.yml diff --git a/roles/buildtools/molecule/default/verify.yml b/roles/buildtools/molecule/default/verify.yml new file mode 100644 index 0000000..23cf6b8 --- /dev/null +++ b/roles/buildtools/molecule/default/verify.yml @@ -0,0 +1,30 @@ +--- +- name: Verify + hosts: all + become: no + gather_facts: no + + tasks: + - name: run gcc + command: gcc --version + + - name: run make + command: make --version + + - name: run shasum + command: shasum --version + + - name: run bison + command: bison --version + + - name: find libelf + find: + paths: /usr + patterns: libelf.so.1 + register: buildtools_find_libelf + + - name: assert the results + assert: + that: + - buildtools_find_libelf.matched >= 0 + msg: could not find libelf.so.1 in /usr diff --git a/roles/buildtools/molecule/ec2/README.md b/roles/buildtools/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/buildtools/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/buildtools/molecule/ec2/create.yml b/roles/buildtools/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/buildtools/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/buildtools/molecule/ec2/destroy.yml b/roles/buildtools/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/buildtools/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/buildtools/molecule/ec2/molecule.yml b/roles/buildtools/molecule/ec2/molecule.yml deleted file mode 100644 index 27ceea3..0000000 --- a/roles/buildtools/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: buildtools-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: buildtools-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: buildtools-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: buildtools-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: buildtools-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: buildtools-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - buildtools-ubuntu-18.04: - ansible_user: ubuntu - buildtools-centos-7: - ansible_user: centos - buildtools-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/buildtools/molecule/fedora-latest/molecule.yml b/roles/buildtools/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 90243ea..0000000 --- a/roles/buildtools/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/buildtools/molecule/fedora-rawhide/molecule.yml b/roles/buildtools/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 016d926..0000000 --- a/roles/buildtools/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/buildtools/molecule/opensuse-leap/molecule.yml b/roles/buildtools/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 06aab77..0000000 --- a/roles/buildtools/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/buildtools/molecule/resources/playbook.yml b/roles/buildtools/molecule/resources/playbook.yml deleted file mode 100644 index c232e99..0000000 --- a/roles/buildtools/molecule/resources/playbook.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: Converge - hosts: all - become: yes - gather_facts: yes - - roles: - - ansible-role-buildtools - - tasks: - - name: run gcc - shell: gcc --version > gcc.version - args: - creates: gcc.version diff --git a/roles/buildtools/molecule/ubuntu-devel/molecule.yml b/roles/buildtools/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 1e96658..0000000 --- a/roles/buildtools/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/buildtools/molecule/ubuntu-latest/molecule.yml b/roles/buildtools/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 4431e67..0000000 --- a/roles/buildtools/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/buildtools/molecule/ubuntu-rolling/molecule.yml b/roles/buildtools/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index bf97896..0000000 --- a/roles/buildtools/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: buildtools-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/buildtools/molecule/vagrant/INSTALL.rst b/roles/buildtools/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/buildtools/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/buildtools/molecule/vagrant/molecule.yml b/roles/buildtools/molecule/vagrant/molecule.yml deleted file mode 100644 index b6a8e7f..0000000 --- a/roles/buildtools/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: buildtools-debian - box: debian/stretch64 - - name: buildtools-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - buildtools-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/buildtools/tox.ini b/roles/buildtools/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/buildtools/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/buildtools/vars/main.yml b/roles/buildtools/vars/main.yml index b4ee8ca..3f9961e 100644 --- a/roles/buildtools/vars/main.yml +++ b/roles/buildtools/vars/main.yml @@ -5,56 +5,40 @@ _buildtools_packages: - build-essential Alpine: - alpine-sdk + - bison + - elfutils-libelf - libffi-dev - openssl-dev - perl-utils - Amazon: - - gcc - - make + - python3-dev Archlinux: - base-devel - CentOS: - - "@Development tools" - - perl-Digest-SHA - Fedora: - - "@Development tools" - - perl-Digest-SHA - - libffi-devel - openSUSE Leap: - - autoconf - - automake - - binutils + - libelf + Debian: - bison - - cpp - - cvs - - flex + - build-essential + - libelf-dev + CentOS-7: + - "@Development Tools" + - elfutils-libelf-devel + - perl-Digest-SHA + - python-devel + CentOS: + - "@Development Tools" + - elfutils-libelf-devel + - perl-Digest-SHA + - python3-devel + RedHat: + - bison + - elfutils-libelf-devel - gcc - - gdbm-devel - - gettext-tools - - glibc-devel - - libtool - - m4 - make - - makeinfo - - patch - - zlib-devel - - bin86 - - binutils-devel - - fdupes - - gcc-c++ - - gcc-info - - glibc-info - - gmp-devel - - gperf - - libaio-devel - - libapparmor-devel - - libdb-4_8-devel - - libosip2-devel - - libstdc++-devel - - openldap2-devel - - pam-devel - - patch - - pkg-config - - subversion + - perl-Digest-SHA + Suse: + - bison + - gcc + - libelf-devel + - make + - perl-Digest-SHA1 -buildtools_packages: "{{ _buildtools_packages[ansible_distribution] | default (_buildtools_packages['default'] ) }}" +buildtools_packages: "{{ _buildtools_packages[ansible_distribution ~ '-' ~ ansible_distribution_major_version] | default(_buildtools_packages[ansible_distribution] | default(_buildtools_packages[ansible_os_family] | default (_buildtools_packages['default']))) }}" diff --git a/roles/common/.ansible-lint b/roles/common/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/common/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/common/.github/ISSUE_TEMPLATE/bug_report.md b/roles/common/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/common/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/common/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/common/.github/settings.yml b/roles/common/.github/settings.yml index b0e93f9..54f4b17 100644 --- a/roles/common/.github/settings.yml +++ b/roles/common/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: The purpose of this role is to configure common things on your system. homepage: https://robertdebock.nl/ diff --git a/roles/common/.gitignore b/roles/common/.gitignore index 10b26d1..982db11 100644 --- a/roles/common/.gitignore +++ b/roles/common/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/common/.travis.yml b/roles/common/.travis.yml index 4e300de..8c46a77 100644 --- a/roles/common/.travis.yml +++ b/roles/common/.travis.yml @@ -1,85 +1,50 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" expectation="fail" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="redhat" tag="7" + - image="centos" + - image="redhat" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/common/CONTRIBUTING.md b/roles/common/CONTRIBUTING.md index 3209430..7ce3b8d 100644 --- a/roles/common/CONTRIBUTING.md +++ b/roles/common/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/common/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/common), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/common.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/common/README.md b/roles/common/README.md index 09fb2d5..8fb6625 100644 --- a/roles/common/README.md +++ b/roles/common/README.md @@ -2,14 +2,14 @@ common ========= Ansible logo -Build status + Build status The purpose of this role is to configure common things on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.common ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -33,6 +33,7 @@ The machine you are running this on, may need to be prepared. - robertdebock.bootstrap ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -85,25 +86,30 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|no|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|1|no| +|amazonlinux|latest|no| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|redhat|7|no| +|centos|latest|no| +|redhat|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| -A single star means the build may fail, it's marked as an experimental build. +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel Exceptions ---------- @@ -115,23 +121,58 @@ Some variarations of the build matrix do not work. These are the variations and | Archlinux & Ansible 2.7 | New-style module did not handle its own exit | - Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-common) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-common) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-common/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- hostname +- include_role +- ini_file +- lineinfile +- meta +- package +- service +- setup +- stat +- template +``` License ------- diff --git a/roles/common/meta/.galaxy_install_info b/roles/common/meta/.galaxy_install_info index eb741f4..6bcee6e 100644 --- a/roles/common/meta/.galaxy_install_info +++ b/roles/common/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:25 2019', version: 3.0.7} +install_date: Mon Dec 16 06:44:52 2019 +version: 3.1.3 diff --git a/roles/common/meta/main.yml b/roles/common/meta/main.yml index e8b8e75..70c3410 100644 --- a/roles/common/meta/main.yml +++ b/roles/common/meta/main.yml @@ -5,22 +5,25 @@ galaxy_info: description: The purpose of this role is to configure common things on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -34,16 +37,10 @@ galaxy_info: galaxy_tags: - common - - alpine - centos - - debian - - el - - fedora - - opensuse - - rhel + - redhat - server - system - - ubuntu dependencies: - robertdebock.reboot diff --git a/roles/common/molecule/alpine-edge/molecule.yml b/roles/common/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 4f5c8f5..0000000 --- a/roles/common/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/common/molecule/alpine-latest/molecule.yml b/roles/common/molecule/alpine-latest/molecule.yml deleted file mode 100644 index ca7ba03..0000000 --- a/roles/common/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/common/molecule/archlinux/molecule.yml b/roles/common/molecule/archlinux/molecule.yml deleted file mode 100644 index e0101be..0000000 --- a/roles/common/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/common/molecule/centos-6/molecule.yml b/roles/common/molecule/centos-6/molecule.yml deleted file mode 100644 index e5f1b01..0000000 --- a/roles/common/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/common/molecule/centos-latest/molecule.yml b/roles/common/molecule/centos-latest/molecule.yml deleted file mode 100644 index 08e5bd9..0000000 --- a/roles/common/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/common/molecule/debian-stable/molecule.yml b/roles/common/molecule/debian-stable/molecule.yml deleted file mode 100644 index 097a648..0000000 --- a/roles/common/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/common/molecule/debian-unstable/molecule.yml b/roles/common/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 74c846f..0000000 --- a/roles/common/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/common/molecule/default/molecule.yml b/roles/common/molecule/default/molecule.yml index 5757c2e..4d303b7 100644 --- a/roles/common/molecule/default/molecule.yml +++ b/roles/common/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: common-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: common-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: common-archlinux - image: archlinux/base - pre_build_image: yes - - name: common-centos-6 - image: centos:6 - pre_build_image: yes - - name: common-centos-latest - image: centos:latest - pre_build_image: yes - - name: common-debian-stable - image: debian:stable - pre_build_image: yes - - name: common-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: common-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: common-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: common-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: common-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: common-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: common-ubuntu-devel - image: ubuntu:devel + - name: "common-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - common-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - common-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/common/molecule/resources/playbook.yml b/roles/common/molecule/default/playbook.yml similarity index 100% rename from roles/common/molecule/resources/playbook.yml rename to roles/common/molecule/default/playbook.yml diff --git a/roles/common/molecule/resources/prepare.yml b/roles/common/molecule/default/prepare.yml similarity index 100% rename from roles/common/molecule/resources/prepare.yml rename to roles/common/molecule/default/prepare.yml diff --git a/roles/common/molecule/ec2/README.md b/roles/common/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/common/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/common/molecule/ec2/create.yml b/roles/common/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/common/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/common/molecule/ec2/destroy.yml b/roles/common/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/common/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/common/molecule/ec2/molecule.yml b/roles/common/molecule/ec2/molecule.yml deleted file mode 100644 index 2e45030..0000000 --- a/roles/common/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: common-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: common-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: common-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: common-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: common-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: common-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - common-ubuntu-18.04: - ansible_user: ubuntu - common-centos-7: - ansible_user: centos - common-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/common/molecule/fedora-latest/molecule.yml b/roles/common/molecule/fedora-latest/molecule.yml deleted file mode 100644 index c198c86..0000000 --- a/roles/common/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/common/molecule/fedora-rawhide/molecule.yml b/roles/common/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index af0c508..0000000 --- a/roles/common/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/common/molecule/opensuse-leap/molecule.yml b/roles/common/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 8590da3..0000000 --- a/roles/common/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/common/molecule/ubuntu-devel/molecule.yml b/roles/common/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 215bcac..0000000 --- a/roles/common/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/common/molecule/ubuntu-latest/molecule.yml b/roles/common/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 2088452..0000000 --- a/roles/common/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/common/molecule/ubuntu-rolling/molecule.yml b/roles/common/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 946ded3..0000000 --- a/roles/common/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: common-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/common/molecule/vagrant/INSTALL.rst b/roles/common/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/common/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/common/molecule/vagrant/molecule.yml b/roles/common/molecule/vagrant/molecule.yml deleted file mode 100644 index 213a0c9..0000000 --- a/roles/common/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: common-debian - box: debian/stretch64 - - name: common-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - common-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index a217b03..32ea262 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -50,7 +50,7 @@ - name: reboot for hostname include_role: - name: reboot + name: robertdebock.reboot when: - set_hostname.changed - common_reboot | bool diff --git a/roles/common/tox.ini b/roles/common/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/common/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/common/vars/main.yml b/roles/common/vars/main.yml index ce8aa80..3323bfd 100644 --- a/roles/common/vars/main.yml +++ b/roles/common/vars/main.yml @@ -3,11 +3,13 @@ _common_requirements: default: - hostname + Amazon-2018: + - net-tools Alpine: - net-tools Archlinux: - net-tools - CentOS-6: - - net-tools + CentOS: + - dbus common_requirements: "{{ _common_requirements[ansible_distribution ~ '-' ~ ansible_distribution_major_version] | default(_common_requirements[ansible_distribution] | default(_common_requirements['default'])) }}" diff --git a/roles/docker/.ansible-lint b/roles/docker/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/docker/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/docker/.github/ISSUE_TEMPLATE/bug_report.md b/roles/docker/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/docker/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/docker/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/docker/.github/settings.yml b/roles/docker/.github/settings.yml index 34a20b0..059ae76 100644 --- a/roles/docker/.github/settings.yml +++ b/roles/docker/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install and configure Docker (non-CE) on your system. homepage: https://robertdebock.nl/ diff --git a/roles/docker/.gitignore b/roles/docker/.gitignore index 10b26d1..982db11 100644 --- a/roles/docker/.gitignore +++ b/roles/docker/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/docker/.travis.yml b/roles/docker/.travis.yml index b2a8a3b..d8dface 100644 --- a/roles/docker/.travis.yml +++ b/roles/docker/.travis.yml @@ -1,85 +1,45 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" expectation="fail" - - version="" distro="centos-6" expectation="fail" - - version="devel" distro="centos-6" expectation="fail" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="centos" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" expectation="fail" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/docker/README.md b/roles/docker/README.md index 3b6b354..fb3dad1 100644 --- a/roles/docker/README.md +++ b/roles/docker/README.md @@ -2,14 +2,14 @@ docker ========= Ansible logo -Build status + Build status Install and configure Docker (non-CE) on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -31,7 +31,7 @@ This example is taken from `molecule/resources/playbook.yml`: - ansible_virtualization_type != "docker" ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -41,10 +41,13 @@ The machine you are running this on, may need to be prepared. roles: - robertdebock.bootstrap + - robertdebock.core_dependencies + - robertdebock.buildtools - robertdebock.epel - robertdebock.python_pip ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -67,6 +70,8 @@ The following roles can be installed to ensure all requirements are met, using ` ```yaml --- - robertdebock.bootstrap +- robertdebock.buildtools +- robertdebock.core_dependencies - robertdebock.epel - robertdebock.python_pip @@ -84,45 +89,84 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|no|no|no*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|centos|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| -A single star means the build may fail, it's marked as an experimental build. +This role has been tested on these Ansible versions: +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| Ubuntu | Unable to find any of pip2, pip to use. | +| amazonlinux | Required dependency (python_pip) does not work on amazonlinux. | Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-docker) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-docker) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-docker/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- file +- group +- package +- pip +- service +``` License ------- diff --git a/roles/docker/meta/.galaxy_install_info b/roles/docker/meta/.galaxy_install_info index ab62e3b..bfba71c 100644 --- a/roles/docker/meta/.galaxy_install_info +++ b/roles/docker/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:28 2019', version: 2.1.2} +install_date: Mon Dec 16 06:44:57 2019 +version: 2.3.2 diff --git a/roles/docker/meta/exception.yml b/roles/docker/meta/exception.yml new file mode 100644 index 0000000..774cd36 --- /dev/null +++ b/roles/docker/meta/exception.yml @@ -0,0 +1,6 @@ +--- +exceptions: + - variation: Ubuntu + reason: "Unable to find any of pip2, pip to use." + - variation: amazonlinux + reason: "Required dependency (python_pip) does not work on amazonlinux." diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml index ca2d0dc..c7b2ff6 100644 --- a/roles/docker/meta/main.yml +++ b/roles/docker/meta/main.yml @@ -5,39 +5,32 @@ galaxy_info: description: Install and configure Docker (non-CE) on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all - name: OpenSUSE versions: - all - - name: Ubuntu - versions: - - artful - - bionic galaxy_tags: - docker - - alpine - centos - rhel - - ubuntu - - fedora dependencies: [] diff --git a/roles/docker/molecule/alpine-edge/molecule.yml b/roles/docker/molecule/alpine-edge/molecule.yml deleted file mode 100644 index fbe97e1..0000000 --- a/roles/docker/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/docker/molecule/alpine-latest/molecule.yml b/roles/docker/molecule/alpine-latest/molecule.yml deleted file mode 100644 index c0939bb..0000000 --- a/roles/docker/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/docker/molecule/archlinux/molecule.yml b/roles/docker/molecule/archlinux/molecule.yml deleted file mode 100644 index 48e28d9..0000000 --- a/roles/docker/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/docker/molecule/centos-6/molecule.yml b/roles/docker/molecule/centos-6/molecule.yml deleted file mode 100644 index 12e4c18..0000000 --- a/roles/docker/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/docker/molecule/centos-latest/molecule.yml b/roles/docker/molecule/centos-latest/molecule.yml deleted file mode 100644 index 4454f71..0000000 --- a/roles/docker/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/docker/molecule/debian-stable/molecule.yml b/roles/docker/molecule/debian-stable/molecule.yml deleted file mode 100644 index 60818c7..0000000 --- a/roles/docker/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/docker/molecule/debian-unstable/molecule.yml b/roles/docker/molecule/debian-unstable/molecule.yml deleted file mode 100644 index c3da954..0000000 --- a/roles/docker/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/docker/molecule/default/molecule.yml b/roles/docker/molecule/default/molecule.yml index 4896a57..1fe77d6 100644 --- a/roles/docker/molecule/default/molecule.yml +++ b/roles/docker/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: docker-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: docker-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: docker-archlinux - image: archlinux/base - pre_build_image: yes - - name: docker-centos-6 - image: centos:6 - pre_build_image: yes - - name: docker-centos-latest - image: centos:latest - pre_build_image: yes - - name: docker-debian-stable - image: debian:stable - pre_build_image: yes - - name: docker-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: docker-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: docker-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: docker-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: docker-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: docker-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: docker-ubuntu-devel - image: ubuntu:devel + - name: "docker-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - docker-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - docker-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/docker/molecule/resources/playbook.yml b/roles/docker/molecule/default/playbook.yml similarity index 100% rename from roles/docker/molecule/resources/playbook.yml rename to roles/docker/molecule/default/playbook.yml diff --git a/roles/docker/molecule/resources/prepare.yml b/roles/docker/molecule/default/prepare.yml similarity index 70% rename from roles/docker/molecule/resources/prepare.yml rename to roles/docker/molecule/default/prepare.yml index a5ff972..32a00e0 100644 --- a/roles/docker/molecule/resources/prepare.yml +++ b/roles/docker/molecule/default/prepare.yml @@ -6,5 +6,7 @@ roles: - robertdebock.bootstrap + - robertdebock.core_dependencies + - robertdebock.buildtools - robertdebock.epel - robertdebock.python_pip diff --git a/roles/docker/molecule/ec2/README.md b/roles/docker/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/docker/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/docker/molecule/ec2/create.yml b/roles/docker/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/docker/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/docker/molecule/ec2/destroy.yml b/roles/docker/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/docker/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/docker/molecule/ec2/molecule.yml b/roles/docker/molecule/ec2/molecule.yml deleted file mode 100644 index 1a4dd3b..0000000 --- a/roles/docker/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: docker-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: docker-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: docker-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: docker-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: docker-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: docker-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - docker-ubuntu-18.04: - ansible_user: ubuntu - docker-centos-7: - ansible_user: centos - docker-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/docker/molecule/fedora-latest/molecule.yml b/roles/docker/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 9fb1481..0000000 --- a/roles/docker/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/docker/molecule/fedora-rawhide/molecule.yml b/roles/docker/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index a8c3d4f..0000000 --- a/roles/docker/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/docker/molecule/opensuse-leap/molecule.yml b/roles/docker/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 562805e..0000000 --- a/roles/docker/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/docker/molecule/ubuntu-devel/molecule.yml b/roles/docker/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index b7f44f3..0000000 --- a/roles/docker/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/docker/molecule/ubuntu-latest/molecule.yml b/roles/docker/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 7c21229..0000000 --- a/roles/docker/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/docker/molecule/ubuntu-rolling/molecule.yml b/roles/docker/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 14f4667..0000000 --- a/roles/docker/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: docker-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/docker/molecule/vagrant/INSTALL.rst b/roles/docker/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/docker/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/docker/molecule/vagrant/molecule.yml b/roles/docker/molecule/vagrant/molecule.yml deleted file mode 100644 index 07c6d55..0000000 --- a/roles/docker/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: docker-debian - box: debian/stretch64 - - name: docker-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - docker-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/docker/requirements.yml b/roles/docker/requirements.yml index d47836a..38b9b85 100644 --- a/roles/docker/requirements.yml +++ b/roles/docker/requirements.yml @@ -1,4 +1,6 @@ --- - robertdebock.bootstrap +- robertdebock.buildtools +- robertdebock.core_dependencies - robertdebock.epel - robertdebock.python_pip diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index a27a336..887bebd 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -26,7 +26,7 @@ name: "{{ docker_service }}" state: started enabled: yes - when: - - ansible_virtualization_type != "docker" notify: - change owner for docker socket + when: + - ansible_virtualization_type != "docker" diff --git a/roles/docker/tox.ini b/roles/docker/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/docker/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/docker/vars/main.yml b/roles/docker/vars/main.yml index 7fd9a99..dfdd674 100644 --- a/roles/docker/vars/main.yml +++ b/roles/docker/vars/main.yml @@ -1,36 +1,28 @@ --- # vars file for docker -_docker_requirements: - default: [] - Debian: - - ca-certificates - - curl - - gnupg2 - - software-properties-common - -docker_requirements: "{{ _docker_requirements[ansible_distribution] | default(_docker_requirements['default']) }}" - _docker_packages: default: - docker - docker-compose Alpine: - docker - CentOS: + RedHat-7: - docker-io - docker-compose + RedHat-8: + - podman-docker Debian: - docker.io - docker-compose - Ubuntu: - - docker.io - - docker-compose - -docker_packages: "{{ _docker_packages[ansible_distribution] | default(_docker_packages['default']) }}" +docker_packages: "{{ _docker_packages[ansible_os_family ~ '-' ~ ansible_distribution_major_version] | default(_docker_packages[ansible_os_family] | default(_docker_packages['default'])) }}" docker_pip_packages: - docker - docker-compose -docker_service: docker +_docker_service: + default: docker + RedHat-8: io.podman + +docker_service: "{{ _docker_service[ansible_os_family ~ '-' ~ ansible_distribution_major_version] | default(_docker_service['default']) }}" diff --git a/roles/epel/.ansible-lint b/roles/epel/.ansible-lint new file mode 100644 index 0000000..788f1ce --- /dev/null +++ b/roles/epel/.ansible-lint @@ -0,0 +1,3 @@ +# +# Ansible managed +# diff --git a/roles/epel/.github/ISSUE_TEMPLATE/bug_report.md b/roles/epel/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/epel/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/epel/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/epel/.github/settings.yml b/roles/epel/.github/settings.yml index 75c1660..491309e 100644 --- a/roles/epel/.github/settings.yml +++ b/roles/epel/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install epel on your system. homepage: https://robertdebock.nl/ diff --git a/roles/epel/.gitignore b/roles/epel/.gitignore index 10b26d1..982db11 100644 --- a/roles/epel/.gitignore +++ b/roles/epel/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/epel/.travis.yml b/roles/epel/.travis.yml index 86282d1..b1153b6 100644 --- a/roles/epel/.travis.yml +++ b/roles/epel/.travis.yml @@ -1,33 +1,38 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="centos" tag="7" + - image="redhat" tag="7" + - image="centos" + - image="redhat" matrix: allow_failures: - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/epel/CONTRIBUTING.md b/roles/epel/CONTRIBUTING.md index 3209430..cd7db35 100644 --- a/roles/epel/CONTRIBUTING.md +++ b/roles/epel/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/epel/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/epel), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/epel.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/epel/README.md b/roles/epel/README.md index f93f12d..9fc0ea4 100644 --- a/roles/epel/README.md +++ b/roles/epel/README.md @@ -2,14 +2,14 @@ epel ========= Ansible logo -Build status + Build status Install epel on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.epel ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -33,6 +33,22 @@ The machine you are running this on, may need to be prepared. - robertdebock.bootstrap ``` +After running this role, this playbook runs to verify that everything works, this may be a good example how you can use this role. +```yaml +--- +- name: Verify + hosts: all + become: yes + gather_facts: yes + + tasks: + - name: install a package from epel + package: + name: zstd + state: present + +``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -70,31 +86,68 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): + +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|1|no| +|amazonlinux|latest|no| +|centos|7|no| +|redhat|7|no| +|centos|latest|no| +|redhat|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-epel) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-epel) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-epel/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- package +``` License ------- diff --git a/roles/epel/meta/.galaxy_install_info b/roles/epel/meta/.galaxy_install_info index 8b45915..f8c8190 100644 --- a/roles/epel/meta/.galaxy_install_info +++ b/roles/epel/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:32 2019', version: 2.0.6} +install_date: Mon Dec 16 06:45:01 2019 +version: 2.3.3 diff --git a/roles/epel/meta/main.yml b/roles/epel/meta/main.yml index d11c9d6..21a1647 100644 --- a/roles/epel/meta/main.yml +++ b/roles/epel/meta/main.yml @@ -5,13 +5,16 @@ galaxy_info: description: Install epel on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: EL - version: - - 6 + versions: - 7 + - 8 galaxy_tags: - epel @@ -19,6 +22,6 @@ galaxy_info: - installer - packages - centos - - rhel + - redhat dependencies: [] diff --git a/roles/epel/molecule/centos-6/molecule.yml b/roles/epel/molecule/centos-6/molecule.yml deleted file mode 100644 index c74ebdd..0000000 --- a/roles/epel/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: epel-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/epel/molecule/centos-latest/molecule.yml b/roles/epel/molecule/centos-latest/molecule.yml deleted file mode 100644 index 84f4986..0000000 --- a/roles/epel/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: epel-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/epel/molecule/default/molecule.yml b/roles/epel/molecule/default/molecule.yml index 07e40d8..368b999 100644 --- a/roles/epel/molecule/default/molecule.yml +++ b/roles/epel/molecule/default/molecule.yml @@ -1,30 +1,29 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: role-file: requirements.yml -driver: - name: docker lint: name: yamllint +driver: + name: docker platforms: - - name: epel-centos-6 - image: centos:6 - - name: epel-centos-latest - image: centos:latest + - name: "epel-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes provisioner: name: ansible +verifier: + name: ansible lint: name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - epel-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - epel-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 + enabled: no scenario: name: default diff --git a/roles/epel/molecule/resources/playbook.yml b/roles/epel/molecule/default/playbook.yml similarity index 100% rename from roles/epel/molecule/resources/playbook.yml rename to roles/epel/molecule/default/playbook.yml diff --git a/roles/epel/molecule/resources/prepare.yml b/roles/epel/molecule/default/prepare.yml similarity index 100% rename from roles/epel/molecule/resources/prepare.yml rename to roles/epel/molecule/default/prepare.yml diff --git a/roles/epel/molecule/default/verify.yml b/roles/epel/molecule/default/verify.yml new file mode 100644 index 0000000..a959086 --- /dev/null +++ b/roles/epel/molecule/default/verify.yml @@ -0,0 +1,11 @@ +--- +- name: Verify + hosts: all + become: yes + gather_facts: yes + + tasks: + - name: install a package from epel + package: + name: zstd + state: present diff --git a/roles/epel/molecule/ec2/README.md b/roles/epel/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/epel/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/epel/molecule/ec2/create.yml b/roles/epel/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/epel/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/epel/molecule/ec2/destroy.yml b/roles/epel/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/epel/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/epel/molecule/ec2/molecule.yml b/roles/epel/molecule/ec2/molecule.yml deleted file mode 100644 index a366dca..0000000 --- a/roles/epel/molecule/ec2/molecule.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -driver: - name: ec2 -lint: - name: yamllint -platforms: - - name: rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: epel-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: epel-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: epel-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: epel-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - epel-ubuntu-18.04: - ansible_user: ubuntu - epel-centos-7: - ansible_user: centos - epel-fedora-29: - ansible_user: fedora -scenario: - name: ec2 diff --git a/roles/epel/molecule/vagrant/INSTALL.rst b/roles/epel/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/epel/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/epel/molecule/vagrant/molecule.yml b/roles/epel/molecule/vagrant/molecule.yml deleted file mode 100644 index 0485fc6..0000000 --- a/roles/epel/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -driver: - name: vagrant - provider: - name: virtualbox -lint: - name: yamllint -platforms: - - name: epel-debian - box: debian/stretch64 - - name: epel-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - epel-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/epel/tasks/main.yml b/roles/epel/tasks/main.yml index e6ef57c..08627c8 100644 --- a/roles/epel/tasks/main.yml +++ b/roles/epel/tasks/main.yml @@ -2,10 +2,10 @@ # tasks file for epel - name: install epel-release package: - name: epel-release + name: "{{ epel_url }}" state: present when: - - ansible_distribution in [ "CentOS", "RedHat" ] + - ansible_distribution in [ "CentOS", "RedHat", "Amazon" ] register: epel_install_epel_release until: epel_install_epel_release is succeeded retries: 3 diff --git a/roles/epel/tox.ini b/roles/epel/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/epel/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/epel/vars/main.yml b/roles/epel/vars/main.yml new file mode 100644 index 0000000..31f59c9 --- /dev/null +++ b/roles/epel/vars/main.yml @@ -0,0 +1,10 @@ +--- +# vars file for epel +_epel_version: + default: "{{ ansible_distribution_major_version }}" + Amazon-2018: 6 + Amazon-2: 7 + +epel_version: "{{ _epel_version[ansible_distribution ~ '-' ~ ansible_distribution_major_version] | default(_epel_version['default']) }}" + +epel_url: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ epel_version }}.noarch.rpm" diff --git a/roles/fail2ban/.ansible-lint b/roles/fail2ban/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/fail2ban/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/fail2ban/.github/ISSUE_TEMPLATE/bug_report.md b/roles/fail2ban/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/fail2ban/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/fail2ban/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/fail2ban/.github/settings.yml b/roles/fail2ban/.github/settings.yml index 85cf34b..577ba15 100644 --- a/roles/fail2ban/.github/settings.yml +++ b/roles/fail2ban/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install and configure fail2ban on your system. homepage: https://robertdebock.nl/ diff --git a/roles/fail2ban/.gitignore b/roles/fail2ban/.gitignore index 10b26d1..982db11 100644 --- a/roles/fail2ban/.gitignore +++ b/roles/fail2ban/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/fail2ban/.travis.yml b/roles/fail2ban/.travis.yml index b93270a..3494ac4 100644 --- a/roles/fail2ban/.travis.yml +++ b/roles/fail2ban/.travis.yml @@ -1,85 +1,45 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="centos" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/fail2ban/README.md b/roles/fail2ban/README.md index 40638ab..dbd5cf8 100644 --- a/roles/fail2ban/README.md +++ b/roles/fail2ban/README.md @@ -2,14 +2,14 @@ fail2ban ========= Ansible logo -Build status + Build status Install and configure fail2ban on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.fail2ban ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -34,6 +34,7 @@ The machine you are running this on, may need to be prepared. - robertdebock.epel ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -53,7 +54,17 @@ fail2ban_bantime: 10m fail2ban_findtime: 10m fail2ban_maxretry: 5 fail2ban_destemail: root@localhost -fail2ban_sender: root@{{ ansible_fqdn}} +fail2ban_sender: root@{{ ansible_fqdn }} + +fail2ban_configuration: [] +# - option: loglevel +# value: "INFO" +# section: Definition + +fail2ban_jail_configuration: [] +# - option: ignoreself +# value: "true" +# section: DEFAULT ``` Requirements @@ -83,42 +94,84 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|1|no| +|amazonlinux|latest|no| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|centos|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| alpine | Service `fail2ban' needs non existent service `logger' | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-fail2ban) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-fail2ban) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-fail2ban/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- file +- ini_file +- package +- service +- stat +``` License ------- diff --git a/roles/fail2ban/defaults/main.yml b/roles/fail2ban/defaults/main.yml index ad82cfa..c47b67a 100644 --- a/roles/fail2ban/defaults/main.yml +++ b/roles/fail2ban/defaults/main.yml @@ -10,4 +10,14 @@ fail2ban_bantime: 10m fail2ban_findtime: 10m fail2ban_maxretry: 5 fail2ban_destemail: root@localhost -fail2ban_sender: root@{{ ansible_fqdn}} +fail2ban_sender: root@{{ ansible_fqdn }} + +fail2ban_configuration: [] +# - option: loglevel +# value: "INFO" +# section: Definition + +fail2ban_jail_configuration: [] +# - option: ignoreself +# value: "true" +# section: DEFAULT diff --git a/roles/fail2ban/handlers/main.yml b/roles/fail2ban/handlers/main.yml index 5c3d436..433500e 100644 --- a/roles/fail2ban/handlers/main.yml +++ b/roles/fail2ban/handlers/main.yml @@ -4,5 +4,3 @@ service: name: "{{ fail2ban_service }}" state: restarted - when: - - ansible_virtualization_type != "docker" diff --git a/roles/fail2ban/meta/.galaxy_install_info b/roles/fail2ban/meta/.galaxy_install_info index 0faf3c2..70f447d 100644 --- a/roles/fail2ban/meta/.galaxy_install_info +++ b/roles/fail2ban/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:36 2019', version: 2.0.7} +install_date: Mon Dec 16 06:45:06 2019 +version: 2.1.1 diff --git a/roles/fail2ban/meta/exception.yml b/roles/fail2ban/meta/exception.yml new file mode 100644 index 0000000..cd1683d --- /dev/null +++ b/roles/fail2ban/meta/exception.yml @@ -0,0 +1,4 @@ +--- +exceptions: + - variation: alpine + reason: "Service `fail2ban' needs non existent service `logger'" diff --git a/roles/fail2ban/meta/main.yml b/roles/fail2ban/meta/main.yml index e4e5218..d1de857 100644 --- a/roles/fail2ban/meta/main.yml +++ b/roles/fail2ban/meta/main.yml @@ -5,22 +5,22 @@ galaxy_info: description: Install and configure fail2ban on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - - name: Alpine + - name: Amazon versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -36,11 +36,7 @@ galaxy_info: - fail2ban - installer - package - - alpine - centos - - debian - - fedora - rhel - - ubuntu dependencies: [] diff --git a/roles/fail2ban/molecule/alpine-edge/molecule.yml b/roles/fail2ban/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 332bc49..0000000 --- a/roles/fail2ban/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/fail2ban/molecule/alpine-latest/molecule.yml b/roles/fail2ban/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 0a957f9..0000000 --- a/roles/fail2ban/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/fail2ban/molecule/archlinux/molecule.yml b/roles/fail2ban/molecule/archlinux/molecule.yml deleted file mode 100644 index aceb50c..0000000 --- a/roles/fail2ban/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/fail2ban/molecule/centos-6/molecule.yml b/roles/fail2ban/molecule/centos-6/molecule.yml deleted file mode 100644 index df47e8c..0000000 --- a/roles/fail2ban/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/fail2ban/molecule/centos-latest/molecule.yml b/roles/fail2ban/molecule/centos-latest/molecule.yml deleted file mode 100644 index d38fbfe..0000000 --- a/roles/fail2ban/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/fail2ban/molecule/debian-stable/molecule.yml b/roles/fail2ban/molecule/debian-stable/molecule.yml deleted file mode 100644 index fdf5235..0000000 --- a/roles/fail2ban/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/fail2ban/molecule/debian-unstable/molecule.yml b/roles/fail2ban/molecule/debian-unstable/molecule.yml deleted file mode 100644 index d6a77e2..0000000 --- a/roles/fail2ban/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/fail2ban/molecule/default/molecule.yml b/roles/fail2ban/molecule/default/molecule.yml index 7a4826f..b20bc00 100644 --- a/roles/fail2ban/molecule/default/molecule.yml +++ b/roles/fail2ban/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: fail2ban-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: fail2ban-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: fail2ban-archlinux - image: archlinux/base - pre_build_image: yes - - name: fail2ban-centos-6 - image: centos:6 - pre_build_image: yes - - name: fail2ban-centos-latest - image: centos:latest - pre_build_image: yes - - name: fail2ban-debian-stable - image: debian:stable - pre_build_image: yes - - name: fail2ban-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: fail2ban-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: fail2ban-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: fail2ban-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: fail2ban-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: fail2ban-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: fail2ban-ubuntu-devel - image: ubuntu:devel + - name: "fail2ban-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - fail2ban-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - fail2ban-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/fail2ban/molecule/resources/playbook.yml b/roles/fail2ban/molecule/default/playbook.yml similarity index 100% rename from roles/fail2ban/molecule/resources/playbook.yml rename to roles/fail2ban/molecule/default/playbook.yml diff --git a/roles/fail2ban/molecule/resources/prepare.yml b/roles/fail2ban/molecule/default/prepare.yml similarity index 100% rename from roles/fail2ban/molecule/resources/prepare.yml rename to roles/fail2ban/molecule/default/prepare.yml diff --git a/roles/fail2ban/molecule/ec2/README.md b/roles/fail2ban/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/fail2ban/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/fail2ban/molecule/ec2/create.yml b/roles/fail2ban/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/fail2ban/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/fail2ban/molecule/ec2/destroy.yml b/roles/fail2ban/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/fail2ban/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/fail2ban/molecule/ec2/molecule.yml b/roles/fail2ban/molecule/ec2/molecule.yml deleted file mode 100644 index 5d6db2c..0000000 --- a/roles/fail2ban/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: fail2ban-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: fail2ban-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: fail2ban-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: fail2ban-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: fail2ban-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: fail2ban-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - fail2ban-ubuntu-18.04: - ansible_user: ubuntu - fail2ban-centos-7: - ansible_user: centos - fail2ban-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/fail2ban/molecule/fedora-latest/molecule.yml b/roles/fail2ban/molecule/fedora-latest/molecule.yml deleted file mode 100644 index f6997d5..0000000 --- a/roles/fail2ban/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/fail2ban/molecule/fedora-rawhide/molecule.yml b/roles/fail2ban/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 092d6a9..0000000 --- a/roles/fail2ban/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/fail2ban/molecule/opensuse-leap/molecule.yml b/roles/fail2ban/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index e226b4a..0000000 --- a/roles/fail2ban/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/fail2ban/molecule/ubuntu-devel/molecule.yml b/roles/fail2ban/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 4dc5734..0000000 --- a/roles/fail2ban/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/fail2ban/molecule/ubuntu-latest/molecule.yml b/roles/fail2ban/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 6c9e44d..0000000 --- a/roles/fail2ban/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/fail2ban/molecule/ubuntu-rolling/molecule.yml b/roles/fail2ban/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 5e28b7e..0000000 --- a/roles/fail2ban/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: fail2ban-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/fail2ban/molecule/vagrant/INSTALL.rst b/roles/fail2ban/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/fail2ban/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/fail2ban/molecule/vagrant/molecule.yml b/roles/fail2ban/molecule/vagrant/molecule.yml deleted file mode 100644 index e519a77..0000000 --- a/roles/fail2ban/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: fail2ban-debian - box: debian/stretch64 - - name: fail2ban-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - fail2ban-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/fail2ban/tasks/main.yml b/roles/fail2ban/tasks/main.yml index 7be514e..17b6621 100644 --- a/roles/fail2ban/tasks/main.yml +++ b/roles/fail2ban/tasks/main.yml @@ -15,7 +15,7 @@ option: "{{ item.option }}" value: "{{ item.value }}" with_items: - - "{{ fail2ban_configuration }}" + - "{{ fail2ban_base_configuration + fail2ban_configuration }}" notify: - restart fail2ban loop_control: @@ -28,12 +28,23 @@ option: "{{ item.option }}" value: "{{ item.value }}" with_items: - - "{{ fail2ban_jail_configuration }}" + - "{{ fail2ban_base_jail_configuration + fail2ban_jail_configuration }}" notify: - restart fail2ban loop_control: label: "{{ item.option }}" +- name: stat auth log file + stat: + path: /var/log/auth.log + register: auth + +- name: touch auth log file + file: + path: /var/log/auth.log + state: touch + when: auth.stat.exists is defined and not auth.stat.exists + - name: start and enable fail2ban service: name: "{{ item }}" @@ -41,5 +52,3 @@ enabled: yes with_items: - "{{ fail2ban_service }}" - when: - - ansible_virtualization_type != "docker" diff --git a/roles/fail2ban/tox.ini b/roles/fail2ban/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/fail2ban/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/fail2ban/vars/main.yml b/roles/fail2ban/vars/main.yml index 07184af..fde306a 100644 --- a/roles/fail2ban/vars/main.yml +++ b/roles/fail2ban/vars/main.yml @@ -5,7 +5,7 @@ fail2ban_packages: fail2ban_service: fail2ban -fail2ban_configuration: +fail2ban_base_configuration: - option: loglevel value: "{{ fail2ban_loglevel }}" section: Definition @@ -13,7 +13,7 @@ fail2ban_configuration: value: "{{ fail2ban_logtarget }}" section: Definition -fail2ban_jail_configuration: +fail2ban_base_jail_configuration: - option: ignoreself value: "{{ fail2ban_ignoreself }}" section: DEFAULT diff --git a/roles/git/.ansible-lint b/roles/git/.ansible-lint new file mode 100644 index 0000000..788f1ce --- /dev/null +++ b/roles/git/.ansible-lint @@ -0,0 +1,3 @@ +# +# Ansible managed +# diff --git a/roles/git/.github/ISSUE_TEMPLATE/bug_report.md b/roles/git/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/git/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/git/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/git/.github/settings.yml b/roles/git/.github/settings.yml index 848d749..041c2ef 100644 --- a/roles/git/.github/settings.yml +++ b/roles/git/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install and configure git on your system. homepage: https://robertdebock.nl/ diff --git a/roles/git/.gitignore b/roles/git/.gitignore index 47cf7b9..982db11 100644 --- a/roles/git/.gitignore +++ b/roles/git/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log -*.swp \ No newline at end of file +*.swp +.tox diff --git a/roles/git/.travis.yml b/roles/git/.travis.yml index 46fbb8a..0c2f8ab 100644 --- a/roles/git/.travis.yml +++ b/roles/git/.travis.yml @@ -1,85 +1,50 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="redhat" tag="7" + - image="centos" + - image="redhat" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/git/CONTRIBUTING.md b/roles/git/CONTRIBUTING.md index 3209430..11becd9 100644 --- a/roles/git/CONTRIBUTING.md +++ b/roles/git/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/git/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/git), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/git.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/git/README.md b/roles/git/README.md index 340c282..9a5e6f3 100644 --- a/roles/git/README.md +++ b/roles/git/README.md @@ -2,14 +2,14 @@ git ========= Ansible logo -Build status + Build status Install and configure git on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -35,7 +35,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.git ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -48,6 +48,7 @@ The machine you are running this on, may need to be prepared. - role: robertdebock.bootstrap ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -114,42 +115,80 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): + +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|1|no| +|amazonlinux|latest|no| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|redhat|7|no| +|centos|latest|no| +|redhat|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-git) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-git) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-git/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- file +- getent +- git +- package +- template +``` License ------- diff --git a/roles/git/meta/.galaxy_install_info b/roles/git/meta/.galaxy_install_info index f259d3d..7fbab8a 100644 --- a/roles/git/meta/.galaxy_install_info +++ b/roles/git/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:38 2019', version: 3.0.5} +install_date: Mon Dec 16 06:45:11 2019 +version: 3.1.3 diff --git a/roles/git/meta/main.yml b/roles/git/meta/main.yml index 1a6aaef..219412a 100644 --- a/roles/git/meta/main.yml +++ b/roles/git/meta/main.yml @@ -5,22 +5,25 @@ galaxy_info: description: Install and configure git on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -34,14 +37,8 @@ galaxy_info: galaxy_tags: - git - - alpine - archlinux - centos - - debian - - el - - fedora - - opensuse - - rhel - - ubuntu + - redhat dependencies: [] diff --git a/roles/git/molecule/alpine-edge/molecule.yml b/roles/git/molecule/alpine-edge/molecule.yml deleted file mode 100644 index ae88b92..0000000 --- a/roles/git/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/git/molecule/alpine-latest/molecule.yml b/roles/git/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 54c768b..0000000 --- a/roles/git/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/git/molecule/archlinux/molecule.yml b/roles/git/molecule/archlinux/molecule.yml deleted file mode 100644 index 3d43b54..0000000 --- a/roles/git/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/git/molecule/centos-6/molecule.yml b/roles/git/molecule/centos-6/molecule.yml deleted file mode 100644 index 0d28eb0..0000000 --- a/roles/git/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/git/molecule/centos-latest/molecule.yml b/roles/git/molecule/centos-latest/molecule.yml deleted file mode 100644 index 53487ba..0000000 --- a/roles/git/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/git/molecule/debian-stable/molecule.yml b/roles/git/molecule/debian-stable/molecule.yml deleted file mode 100644 index 472ca4b..0000000 --- a/roles/git/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/git/molecule/debian-unstable/molecule.yml b/roles/git/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 7174fc7..0000000 --- a/roles/git/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/git/molecule/default/molecule.yml b/roles/git/molecule/default/molecule.yml index e4d5816..e30303f 100644 --- a/roles/git/molecule/default/molecule.yml +++ b/roles/git/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: git-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: git-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: git-archlinux - image: archlinux/base - pre_build_image: yes - - name: git-centos-6 - image: centos:6 - pre_build_image: yes - - name: git-centos-latest - image: centos:latest - pre_build_image: yes - - name: git-debian-stable - image: debian:stable - pre_build_image: yes - - name: git-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: git-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: git-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: git-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: git-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: git-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: git-ubuntu-devel - image: ubuntu:devel + - name: "git-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - git-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - git-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/git/molecule/resources/playbook.yml b/roles/git/molecule/default/playbook.yml similarity index 100% rename from roles/git/molecule/resources/playbook.yml rename to roles/git/molecule/default/playbook.yml diff --git a/roles/git/molecule/resources/prepare.yml b/roles/git/molecule/default/prepare.yml similarity index 100% rename from roles/git/molecule/resources/prepare.yml rename to roles/git/molecule/default/prepare.yml diff --git a/roles/git/molecule/ec2/README.md b/roles/git/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/git/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/git/molecule/ec2/create.yml b/roles/git/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/git/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/git/molecule/ec2/destroy.yml b/roles/git/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/git/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/git/molecule/ec2/molecule.yml b/roles/git/molecule/ec2/molecule.yml deleted file mode 100644 index 02f535d..0000000 --- a/roles/git/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: git-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: git-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: git-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: git-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: git-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: git-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - git-ubuntu-18.04: - ansible_user: ubuntu - git-centos-7: - ansible_user: centos - git-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/git/molecule/fedora-latest/molecule.yml b/roles/git/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 3e1a985..0000000 --- a/roles/git/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/git/molecule/fedora-rawhide/molecule.yml b/roles/git/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index c70073a..0000000 --- a/roles/git/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/git/molecule/opensuse-leap/molecule.yml b/roles/git/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 5f66c38..0000000 --- a/roles/git/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/git/molecule/ubuntu-devel/molecule.yml b/roles/git/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 631ea13..0000000 --- a/roles/git/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/git/molecule/ubuntu-latest/molecule.yml b/roles/git/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 2eb70d9..0000000 --- a/roles/git/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/git/molecule/ubuntu-rolling/molecule.yml b/roles/git/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 216a4b3..0000000 --- a/roles/git/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: git-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/git/molecule/vagrant/molecule.yml b/roles/git/molecule/vagrant/molecule.yml deleted file mode 100644 index 23211e9..0000000 --- a/roles/git/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: git-debian - box: debian/stretch64 - - name: git-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - git-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/git/tox.ini b/roles/git/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/git/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/git/vars/main.yml b/roles/git/vars/main.yml index 4af23a4..68dafa3 100644 --- a/roles/git/vars/main.yml +++ b/roles/git/vars/main.yml @@ -1,7 +1,4 @@ --- # vars file for git -_git_packages: - default: - - git - -git_packages: "{{ _git_packages[ansible_distribution] | default(_git_packages['default']) }}" +git_packages: + - git diff --git a/roles/investigate/.ansible-lint b/roles/investigate/.ansible-lint new file mode 100644 index 0000000..788f1ce --- /dev/null +++ b/roles/investigate/.ansible-lint @@ -0,0 +1,3 @@ +# +# Ansible managed +# diff --git a/roles/investigate/.github/ISSUE_TEMPLATE/bug_report.md b/roles/investigate/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/investigate/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/investigate/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/investigate/.github/settings.yml b/roles/investigate/.github/settings.yml index 75f7e20..373a9a0 100644 --- a/roles/investigate/.github/settings.yml +++ b/roles/investigate/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install and configure investigation tools on your system. homepage: https://robertdebock.nl/ diff --git a/roles/investigate/.gitignore b/roles/investigate/.gitignore index 47cf7b9..982db11 100644 --- a/roles/investigate/.gitignore +++ b/roles/investigate/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log -*.swp \ No newline at end of file +*.swp +.tox diff --git a/roles/investigate/.travis.yml b/roles/investigate/.travis.yml index d235a79..5ec0492 100644 --- a/roles/investigate/.travis.yml +++ b/roles/investigate/.travis.yml @@ -1,85 +1,48 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="centos" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/investigate/README.md b/roles/investigate/README.md index 71b9230..6cf8dbc 100644 --- a/roles/investigate/README.md +++ b/roles/investigate/README.md @@ -2,14 +2,14 @@ investigate ========= Ansible logo -Build status + Build status Install and configure investigation tools on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.investigate ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -34,16 +34,9 @@ The machine you are running this on, may need to be prepared. - role: robertdebock.epel ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. -Role Variables --------------- - -These variables are set in `defaults/main.yml`: -```yaml ---- -# defaults file for investigate -``` Requirements ------------ @@ -72,42 +65,75 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): + +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|1|no| +|amazonlinux|latest|no| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|centos|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-investigate) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-investigate) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-investigate/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- package +- service +``` License ------- diff --git a/roles/investigate/defaults/main.yml b/roles/investigate/defaults/main.yml deleted file mode 100644 index 68d56d4..0000000 --- a/roles/investigate/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# defaults file for investigate diff --git a/roles/investigate/meta/.galaxy_install_info b/roles/investigate/meta/.galaxy_install_info index adffe45..97ab5b9 100644 --- a/roles/investigate/meta/.galaxy_install_info +++ b/roles/investigate/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:41 2019', version: 2.0.6} +install_date: Mon Dec 16 06:45:17 2019 +version: 2.1.3 diff --git a/roles/investigate/meta/main.yml b/roles/investigate/meta/main.yml index 365e9e5..63eed57 100644 --- a/roles/investigate/meta/main.yml +++ b/roles/investigate/meta/main.yml @@ -5,22 +5,25 @@ galaxy_info: description: Install and configure investigation tools on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -34,14 +37,8 @@ galaxy_info: galaxy_tags: - investigate - - alpine - archlinux - centos - - debian - - el - - fedora - - opensuse - rhel - - ubuntu dependencies: [] diff --git a/roles/investigate/molecule/alpine-edge/molecule.yml b/roles/investigate/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 93547f8..0000000 --- a/roles/investigate/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/investigate/molecule/alpine-latest/molecule.yml b/roles/investigate/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 1208c45..0000000 --- a/roles/investigate/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/investigate/molecule/archlinux/molecule.yml b/roles/investigate/molecule/archlinux/molecule.yml deleted file mode 100644 index 0d768e4..0000000 --- a/roles/investigate/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/investigate/molecule/centos-6/molecule.yml b/roles/investigate/molecule/centos-6/molecule.yml deleted file mode 100644 index f0fde52..0000000 --- a/roles/investigate/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/investigate/molecule/centos-latest/molecule.yml b/roles/investigate/molecule/centos-latest/molecule.yml deleted file mode 100644 index 26af666..0000000 --- a/roles/investigate/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/investigate/molecule/debian-stable/molecule.yml b/roles/investigate/molecule/debian-stable/molecule.yml deleted file mode 100644 index 9756e21..0000000 --- a/roles/investigate/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/investigate/molecule/debian-unstable/molecule.yml b/roles/investigate/molecule/debian-unstable/molecule.yml deleted file mode 100644 index bf59f8c..0000000 --- a/roles/investigate/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/investigate/molecule/default/molecule.yml b/roles/investigate/molecule/default/molecule.yml index b3a4fbd..6b3973f 100644 --- a/roles/investigate/molecule/default/molecule.yml +++ b/roles/investigate/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: investigate-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: investigate-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: investigate-archlinux - image: archlinux/base - pre_build_image: yes - - name: investigate-centos-6 - image: centos:6 - pre_build_image: yes - - name: investigate-centos-latest - image: centos:latest - pre_build_image: yes - - name: investigate-debian-stable - image: debian:stable - pre_build_image: yes - - name: investigate-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: investigate-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: investigate-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: investigate-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: investigate-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: investigate-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: investigate-ubuntu-devel - image: ubuntu:devel + - name: "investigate-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - investigate-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - investigate-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/investigate/molecule/resources/playbook.yml b/roles/investigate/molecule/default/playbook.yml similarity index 100% rename from roles/investigate/molecule/resources/playbook.yml rename to roles/investigate/molecule/default/playbook.yml diff --git a/roles/ansible/molecule/resources/prepare.yml b/roles/investigate/molecule/default/prepare.yml similarity index 100% rename from roles/ansible/molecule/resources/prepare.yml rename to roles/investigate/molecule/default/prepare.yml diff --git a/roles/investigate/molecule/ec2/README.md b/roles/investigate/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/investigate/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/investigate/molecule/ec2/create.yml b/roles/investigate/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/investigate/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/investigate/molecule/ec2/destroy.yml b/roles/investigate/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/investigate/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/investigate/molecule/ec2/molecule.yml b/roles/investigate/molecule/ec2/molecule.yml deleted file mode 100644 index 223c040..0000000 --- a/roles/investigate/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: investigate-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: investigate-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: investigate-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: investigate-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: investigate-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: investigate-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - investigate-ubuntu-18.04: - ansible_user: ubuntu - investigate-centos-7: - ansible_user: centos - investigate-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/investigate/molecule/fedora-latest/molecule.yml b/roles/investigate/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 438b0a0..0000000 --- a/roles/investigate/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/investigate/molecule/fedora-rawhide/molecule.yml b/roles/investigate/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 01dede0..0000000 --- a/roles/investigate/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/investigate/molecule/opensuse-leap/molecule.yml b/roles/investigate/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 4a9a386..0000000 --- a/roles/investigate/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/investigate/molecule/ubuntu-devel/molecule.yml b/roles/investigate/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 671e7c5..0000000 --- a/roles/investigate/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/investigate/molecule/ubuntu-latest/molecule.yml b/roles/investigate/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 59cf035..0000000 --- a/roles/investigate/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/investigate/molecule/ubuntu-rolling/molecule.yml b/roles/investigate/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 06042ef..0000000 --- a/roles/investigate/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: investigate-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/investigate/molecule/vagrant/molecule.yml b/roles/investigate/molecule/vagrant/molecule.yml deleted file mode 100644 index 79aef0e..0000000 --- a/roles/investigate/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: investigate-debian - box: debian/stretch64 - - name: investigate-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - investigate-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/investigate/tox.ini b/roles/investigate/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/investigate/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/investigate/vars/main.yml b/roles/investigate/vars/main.yml index e18b311..83b6869 100644 --- a/roles/investigate/vars/main.yml +++ b/roles/investigate/vars/main.yml @@ -24,7 +24,7 @@ _investigate_packages: - bash-completion - curl - screen - CentOS: + RedHat: - net-tools - tcpdump - telnet @@ -32,23 +32,7 @@ _investigate_packages: - bash-completion - curl - screen - Fedora: - - net-tools - - tcpdump - - telnet - - bash - - bash-completion - - curl - - screen - openSUSE Leap: - - net-tools - - tcpdump - - telnet - - bash - - bash-completion - - curl - - screen - Ubuntu: + Suse: - net-tools - tcpdump - telnet @@ -57,4 +41,4 @@ _investigate_packages: - curl - screen -investigate_packages: "{{ _investigate_packages[ansible_distribution] }}" +investigate_packages: "{{ _investigate_packages[ansible_os_family] }}" diff --git a/roles/molecule/.ansible-lint b/roles/molecule/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/molecule/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/molecule/.github/ISSUE_TEMPLATE/bug_report.md b/roles/molecule/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/molecule/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/molecule/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/molecule/.github/settings.yml b/roles/molecule/.github/settings.yml index dc97e42..c7caec3 100644 --- a/roles/molecule/.github/settings.yml +++ b/roles/molecule/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install Molecule on your system. homepage: https://robertdebock.nl/ diff --git a/roles/molecule/.gitignore b/roles/molecule/.gitignore index 47cf7b9..982db11 100644 --- a/roles/molecule/.gitignore +++ b/roles/molecule/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log -*.swp \ No newline at end of file +*.swp +.tox diff --git a/roles/molecule/.travis.yml b/roles/molecule/.travis.yml index ac7a749..87021fa 100644 --- a/roles/molecule/.travis.yml +++ b/roles/molecule/.travis.yml @@ -1,85 +1,44 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" expectation="fail" - - version="" distro="centos-6" expectation="fail" - - version="devel" distro="centos-6" expectation="fail" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" expectation="fail" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/molecule/README.md b/roles/molecule/README.md index 570b517..6343538 100644 --- a/roles/molecule/README.md +++ b/roles/molecule/README.md @@ -2,14 +2,14 @@ molecule ========= Ansible logo -Build status + Build status Install Molecule on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.molecule ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -36,6 +36,7 @@ The machine you are running this on, may need to be prepared. - role: robertdebock.python_pip ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -45,6 +46,9 @@ These variables are set in `defaults/main.yml`: ```yaml --- # defaults file for molecule +# If you need to give extra options to pip, use `molecule_extra_args`. For +# example: +# molecule_extra_args: "--user" ``` Requirements @@ -76,42 +80,81 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|no|no|no*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| CentOS 7 | error in click-completion setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers | +| amazonlinux | Dependency (python_pip) not available | +| ubuntu | Not idempotent on install stratis | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-molecule) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-molecule) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-molecule/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- package +- pip +``` License ------- diff --git a/roles/molecule/defaults/main.yml b/roles/molecule/defaults/main.yml index 6669d52..7605a69 100644 --- a/roles/molecule/defaults/main.yml +++ b/roles/molecule/defaults/main.yml @@ -1,2 +1,5 @@ --- # defaults file for molecule +# If you need to give extra options to pip, use `molecule_extra_args`. For +# example: +# molecule_extra_args: "--user" diff --git a/roles/molecule/meta/.galaxy_install_info b/roles/molecule/meta/.galaxy_install_info index 8d65470..3a68e08 100644 --- a/roles/molecule/meta/.galaxy_install_info +++ b/roles/molecule/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:44 2019', version: 2.0.4} +install_date: Mon Dec 16 06:45:23 2019 +version: 2.1.1 diff --git a/roles/molecule/meta/exception.yml b/roles/molecule/meta/exception.yml new file mode 100644 index 0000000..9e8a710 --- /dev/null +++ b/roles/molecule/meta/exception.yml @@ -0,0 +1,8 @@ +--- +exceptions: + - variation: CentOS 7 + reason: "error in click-completion setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers" + - variation: amazonlinux + reason: Dependency (python_pip) not available + - variation: ubuntu + reason: "Not idempotent on install stratis" diff --git a/roles/molecule/meta/main.yml b/roles/molecule/meta/main.yml index 0565736..a67cfd5 100644 --- a/roles/molecule/meta/main.yml +++ b/roles/molecule/meta/main.yml @@ -5,42 +5,32 @@ galaxy_info: description: Install Molecule on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 7 + versions: + - 8 - name: Fedora versions: - all - name: OpenSUSE versions: - all - - name: Ubuntu - versions: - - artful - - bionic galaxy_tags: - molecule - - alpine - archlinux - centos - - debian - - el - - fedora - - opensuse - rhel - - ubuntu dependencies: [] diff --git a/roles/molecule/molecule/alpine-edge/molecule.yml b/roles/molecule/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 4c30d40..0000000 --- a/roles/molecule/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/molecule/molecule/alpine-latest/molecule.yml b/roles/molecule/molecule/alpine-latest/molecule.yml deleted file mode 100644 index c35ac53..0000000 --- a/roles/molecule/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/molecule/molecule/archlinux/molecule.yml b/roles/molecule/molecule/archlinux/molecule.yml deleted file mode 100644 index 787e31f..0000000 --- a/roles/molecule/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/molecule/molecule/centos-6/molecule.yml b/roles/molecule/molecule/centos-6/molecule.yml deleted file mode 100644 index 299330c..0000000 --- a/roles/molecule/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/molecule/molecule/centos-latest/molecule.yml b/roles/molecule/molecule/centos-latest/molecule.yml deleted file mode 100644 index 996e0f1..0000000 --- a/roles/molecule/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/molecule/molecule/debian-stable/molecule.yml b/roles/molecule/molecule/debian-stable/molecule.yml deleted file mode 100644 index 484cc41..0000000 --- a/roles/molecule/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/molecule/molecule/debian-unstable/molecule.yml b/roles/molecule/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 90841f8..0000000 --- a/roles/molecule/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/molecule/molecule/default/molecule.yml b/roles/molecule/molecule/default/molecule.yml index ec60d03..af4a783 100644 --- a/roles/molecule/molecule/default/molecule.yml +++ b/roles/molecule/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: molecule-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: molecule-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: molecule-archlinux - image: archlinux/base - pre_build_image: yes - - name: molecule-centos-6 - image: centos:6 - pre_build_image: yes - - name: molecule-centos-latest - image: centos:latest - pre_build_image: yes - - name: molecule-debian-stable - image: debian:stable - pre_build_image: yes - - name: molecule-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: molecule-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: molecule-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: molecule-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: molecule-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: molecule-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: molecule-ubuntu-devel - image: ubuntu:devel + - name: "molecule-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - molecule-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - molecule-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/molecule/molecule/resources/playbook.yml b/roles/molecule/molecule/default/playbook.yml similarity index 100% rename from roles/molecule/molecule/resources/playbook.yml rename to roles/molecule/molecule/default/playbook.yml diff --git a/roles/molecule/molecule/resources/prepare.yml b/roles/molecule/molecule/default/prepare.yml similarity index 100% rename from roles/molecule/molecule/resources/prepare.yml rename to roles/molecule/molecule/default/prepare.yml diff --git a/roles/molecule/molecule/ec2/README.md b/roles/molecule/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/molecule/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/molecule/molecule/ec2/create.yml b/roles/molecule/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/molecule/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/molecule/molecule/ec2/destroy.yml b/roles/molecule/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/molecule/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/molecule/molecule/ec2/molecule.yml b/roles/molecule/molecule/ec2/molecule.yml deleted file mode 100644 index 46b80cb..0000000 --- a/roles/molecule/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: molecule-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: molecule-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: molecule-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: molecule-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: molecule-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: molecule-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - molecule-ubuntu-18.04: - ansible_user: ubuntu - molecule-centos-7: - ansible_user: centos - molecule-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/molecule/molecule/fedora-latest/molecule.yml b/roles/molecule/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 32e67c3..0000000 --- a/roles/molecule/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/molecule/molecule/fedora-rawhide/molecule.yml b/roles/molecule/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 0cc8537..0000000 --- a/roles/molecule/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/molecule/molecule/opensuse-leap/molecule.yml b/roles/molecule/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index bfee466..0000000 --- a/roles/molecule/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/molecule/molecule/ubuntu-devel/molecule.yml b/roles/molecule/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index fca66ae..0000000 --- a/roles/molecule/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/molecule/molecule/ubuntu-latest/molecule.yml b/roles/molecule/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index a63e24b..0000000 --- a/roles/molecule/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/molecule/molecule/ubuntu-rolling/molecule.yml b/roles/molecule/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 7de025a..0000000 --- a/roles/molecule/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: molecule-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/molecule/molecule/vagrant/molecule.yml b/roles/molecule/molecule/vagrant/molecule.yml deleted file mode 100644 index aea86a9..0000000 --- a/roles/molecule/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: molecule-debian - box: debian/stretch64 - - name: molecule-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - molecule-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/molecule/tasks/main.yml b/roles/molecule/tasks/main.yml index c90971b..d124dd9 100644 --- a/roles/molecule/tasks/main.yml +++ b/roles/molecule/tasks/main.yml @@ -7,19 +7,13 @@ register: molecule_install_requirements until: molecule_install_requirements is succeeded retries: 3 - -- name: register molecule state - stat: - path: /usr/local/bin/molecule - register: register_molecule_state + become: true - name: install molecule pip: - name: "{{ molecule_packages }}" + name: molecule state: present extra_args: "{{ molecule_extra_args | default(omit) }}" register: molecule_install_molecule until: molecule_install_molecule is succeeded retries: 3 - when: - - not register_molecule_state.stat.exists diff --git a/roles/molecule/tox.ini b/roles/molecule/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/molecule/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/molecule/vars/main.yml b/roles/molecule/vars/main.yml index b856594..68ebfb2 100644 --- a/roles/molecule/vars/main.yml +++ b/roles/molecule/vars/main.yml @@ -6,25 +6,15 @@ _molecule_requirements: - bash Alpine: - linux-headers - CentOS: + CentOS-7: - python-devel - openssl-devel Debian: - libssl-dev - Fedora: + RedHat: - python3-devel - openssl-devel - openSUSE Leap: + Suse: - python-devel - Ubuntu: - - libssl-dev -molecule_requirements: "{{ _molecule_requirements[ansible_distribution] | default(_molecule_requirements['default']) }}" - -molecule_packages: - - molecule - -# _molecule_extra_args: -# Ubuntu: "--ignore-installed entrypoints" -# -# molecule_extra_args: "{{ _molecule_extra_args[ansible_distribution] | default(omit) }}" +molecule_requirements: "{{ _molecule_requirements[ansible_distribution ~ '-' ~ ansible_distribution_major_version] | default(_molecule_requirements[ansible_os_family] | default(_molecule_requirements['default'])) }}" diff --git a/roles/postfix/.ansible-lint b/roles/postfix/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/postfix/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/postfix/.github/ISSUE_TEMPLATE/bug_report.md b/roles/postfix/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/postfix/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/postfix/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/postfix/.github/settings.yml b/roles/postfix/.github/settings.yml index 71b1b62..ae4da49 100644 --- a/roles/postfix/.github/settings.yml +++ b/roles/postfix/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install and configure postfix on your system. homepage: https://robertdebock.nl/ diff --git a/roles/postfix/.gitignore b/roles/postfix/.gitignore index 10b26d1..982db11 100644 --- a/roles/postfix/.gitignore +++ b/roles/postfix/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/postfix/.travis.yml b/roles/postfix/.travis.yml index 77889bc..674a815 100644 --- a/roles/postfix/.travis.yml +++ b/roles/postfix/.travis.yml @@ -1,85 +1,47 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="redhat" tag="7" + - image="centos" + - image="redhat" + - image="fedora" + - image="fedora" tag="rawhide" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/postfix/CONTRIBUTING.md b/roles/postfix/CONTRIBUTING.md index 3209430..fa765a3 100644 --- a/roles/postfix/CONTRIBUTING.md +++ b/roles/postfix/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/postfix/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/postfix), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/postfix.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/postfix/README.md b/roles/postfix/README.md index c0019d8..63c23d9 100644 --- a/roles/postfix/README.md +++ b/roles/postfix/README.md @@ -2,14 +2,14 @@ postfix ========= Ansible logo -Build status + Build status Install and configure postfix on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -26,7 +26,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.postfix ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -36,8 +36,10 @@ The machine you are running this on, may need to be prepared. roles: - robertdebock.bootstrap + - robertdebock.core_dependencies ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -113,6 +115,7 @@ The following roles can be installed to ensure all requirements are met, using ` ```yaml --- - robertdebock.bootstrap +- robertdebock.core_dependencies ``` @@ -128,42 +131,87 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|redhat|7|no| +|centos|latest|no| +|redhat|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| opensuse | Not idempotent on configure postfix (main.cf) and configure postfix | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-postfix) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-postfix) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-postfix/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- command +- file +- group +- lineinfile +- package +- service +- template +``` License ------- diff --git a/roles/postfix/handlers/main.yml b/roles/postfix/handlers/main.yml index b909f7c..c632d52 100644 --- a/roles/postfix/handlers/main.yml +++ b/roles/postfix/handlers/main.yml @@ -4,8 +4,6 @@ service: name: "{{ postfix_service }}" state: restarted - when: - - ansible_virtualization_type != "docker" - name: rebuild alias database command: postmap "{{ postfix_alias_path }}" diff --git a/roles/postfix/meta/.galaxy_install_info b/roles/postfix/meta/.galaxy_install_info index 6d44755..078660c 100644 --- a/roles/postfix/meta/.galaxy_install_info +++ b/roles/postfix/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:48 2019', version: 2.0.9} +install_date: Mon Dec 16 06:45:28 2019 +version: 2.1.1 diff --git a/roles/postfix/meta/exception.yml b/roles/postfix/meta/exception.yml new file mode 100644 index 0000000..5f0d574 --- /dev/null +++ b/roles/postfix/meta/exception.yml @@ -0,0 +1,4 @@ +--- +exceptions: + - variation: opensuse + reason: "Not idempotent on configure postfix (main.cf) and configure postfix" diff --git a/roles/postfix/meta/main.yml b/roles/postfix/meta/main.yml index c1ff8ce..f29dc3d 100644 --- a/roles/postfix/meta/main.yml +++ b/roles/postfix/meta/main.yml @@ -5,26 +5,23 @@ galaxy_info: description: Install and configure postfix on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 - - 7 - - name: Fedora versions: - - all - - name: OpenSUSE + - 7 + - 8 + - name: Fedora versions: - all - name: Ubuntu @@ -33,19 +30,13 @@ galaxy_info: - bionic galaxy_tags: - - alpine - - archlinux - centos - - debian - - fedora - installer - mailserver - - opensuse - package - postfix - - rhel + - redhat - security - system - - ubuntu dependencies: [] diff --git a/roles/postfix/molecule/alpine-edge/molecule.yml b/roles/postfix/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 849a90f..0000000 --- a/roles/postfix/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/postfix/molecule/alpine-latest/molecule.yml b/roles/postfix/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 9194b00..0000000 --- a/roles/postfix/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/postfix/molecule/archlinux/molecule.yml b/roles/postfix/molecule/archlinux/molecule.yml deleted file mode 100644 index cbeec55..0000000 --- a/roles/postfix/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/postfix/molecule/centos-6/molecule.yml b/roles/postfix/molecule/centos-6/molecule.yml deleted file mode 100644 index 6784148..0000000 --- a/roles/postfix/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/postfix/molecule/centos-latest/molecule.yml b/roles/postfix/molecule/centos-latest/molecule.yml deleted file mode 100644 index 07cd895..0000000 --- a/roles/postfix/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/postfix/molecule/debian-stable/molecule.yml b/roles/postfix/molecule/debian-stable/molecule.yml deleted file mode 100644 index 948bf26..0000000 --- a/roles/postfix/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/postfix/molecule/debian-unstable/molecule.yml b/roles/postfix/molecule/debian-unstable/molecule.yml deleted file mode 100644 index c96f395..0000000 --- a/roles/postfix/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/postfix/molecule/default/molecule.yml b/roles/postfix/molecule/default/molecule.yml index 85d55bf..5306639 100644 --- a/roles/postfix/molecule/default/molecule.yml +++ b/roles/postfix/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: postfix-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: postfix-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: postfix-archlinux - image: archlinux/base - pre_build_image: yes - - name: postfix-centos-6 - image: centos:6 - pre_build_image: yes - - name: postfix-centos-latest - image: centos:latest - pre_build_image: yes - - name: postfix-debian-stable - image: debian:stable - pre_build_image: yes - - name: postfix-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: postfix-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: postfix-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: postfix-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: postfix-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: postfix-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: postfix-ubuntu-devel - image: ubuntu:devel + - name: "postfix-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - postfix-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - postfix-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/postfix/molecule/resources/playbook.yml b/roles/postfix/molecule/default/playbook.yml similarity index 100% rename from roles/postfix/molecule/resources/playbook.yml rename to roles/postfix/molecule/default/playbook.yml diff --git a/roles/users/molecule/resources/prepare.yml b/roles/postfix/molecule/default/prepare.yml similarity index 73% rename from roles/users/molecule/resources/prepare.yml rename to roles/postfix/molecule/default/prepare.yml index 1cda60c..ca6c748 100644 --- a/roles/users/molecule/resources/prepare.yml +++ b/roles/postfix/molecule/default/prepare.yml @@ -1,8 +1,9 @@ --- - name: Prepare hosts: all - gather_facts: no become: yes + gather_facts: no roles: - robertdebock.bootstrap + - robertdebock.core_dependencies diff --git a/roles/postfix/molecule/ec2/README.md b/roles/postfix/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/postfix/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/postfix/molecule/ec2/create.yml b/roles/postfix/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/postfix/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/postfix/molecule/ec2/destroy.yml b/roles/postfix/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/postfix/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/postfix/molecule/ec2/molecule.yml b/roles/postfix/molecule/ec2/molecule.yml deleted file mode 100644 index 67a8812..0000000 --- a/roles/postfix/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: postfix-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: postfix-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: postfix-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: postfix-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: postfix-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: postfix-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - postfix-ubuntu-18.04: - ansible_user: ubuntu - postfix-centos-7: - ansible_user: centos - postfix-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/postfix/molecule/fedora-latest/molecule.yml b/roles/postfix/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 4acfe16..0000000 --- a/roles/postfix/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/postfix/molecule/fedora-rawhide/molecule.yml b/roles/postfix/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 3c7a9e7..0000000 --- a/roles/postfix/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/postfix/molecule/opensuse-leap/molecule.yml b/roles/postfix/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index cfb324a..0000000 --- a/roles/postfix/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/postfix/molecule/ubuntu-devel/molecule.yml b/roles/postfix/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 9621ac4..0000000 --- a/roles/postfix/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/postfix/molecule/ubuntu-latest/molecule.yml b/roles/postfix/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 785b14d..0000000 --- a/roles/postfix/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/postfix/molecule/ubuntu-rolling/molecule.yml b/roles/postfix/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 148734c..0000000 --- a/roles/postfix/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: postfix-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/postfix/molecule/vagrant/INSTALL.rst b/roles/postfix/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/postfix/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/postfix/molecule/vagrant/molecule.yml b/roles/postfix/molecule/vagrant/molecule.yml deleted file mode 100644 index 98862da..0000000 --- a/roles/postfix/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: postfix-debian - box: debian/stretch64 - - name: postfix-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - postfix-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/postfix/requirements.yml b/roles/postfix/requirements.yml index 46dec9d..e531325 100644 --- a/roles/postfix/requirements.yml +++ b/roles/postfix/requirements.yml @@ -1,2 +1,3 @@ --- - robertdebock.bootstrap +- robertdebock.core_dependencies diff --git a/roles/postfix/tasks/main.yml b/roles/postfix/tasks/main.yml index 04a3999..2cdd152 100644 --- a/roles/postfix/tasks/main.yml +++ b/roles/postfix/tasks/main.yml @@ -1,15 +1,5 @@ --- # tasks file for postfix -- name: check postfix_aliases - assert: - that: - - item.name is defined - - item.destination is defined - when: - - postfix_aliases is defined - with_items: - - "{{ postfix_aliases }}" - - name: install postfix package: name: "{{ postfix_packages }}" @@ -53,10 +43,18 @@ loop_control: label: "{{ item.name }}" +- name: set group owner + file: + path: "{{ item }}" + group: "{{ postfix_group }}" + with_items: + - /usr/sbin/postqueue + - /usr/sbin/postdrop + - /var/spool/postfix/public + - /var/spool/postfix/maildrop + - name: start and enable postfix service: name: "{{ postfix_service }}" state: started enabled: yes - when: - - ansible_virtualization_type != "docker" diff --git a/roles/postfix/templates/main.cf.j2 b/roles/postfix/templates/main.cf.j2 index bbe5b54..676d9cb 100644 --- a/roles/postfix/templates/main.cf.j2 +++ b/roles/postfix/templates/main.cf.j2 @@ -40,7 +40,7 @@ command_directory = /usr/sbin # daemon programs (i.e. programs listed in the master.cf file). This # directory must be owned by root. # -daemon_directory = {{ postfix_daemon_directory[ansible_distribution] | default(postfix_daemon_directory['default']) }} +daemon_directory = {{ postfix_daemon_directory }} # The data_directory parameter specifies the location of Postfix-writable # data files (caches, random numbers). This directory must be owned diff --git a/roles/postfix/tox.ini b/roles/postfix/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/postfix/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/postfix/vars/main.yml b/roles/postfix/vars/main.yml index c46cfe2..94afd64 100644 --- a/roles/postfix/vars/main.yml +++ b/roles/postfix/vars/main.yml @@ -5,11 +5,12 @@ postfix_packages: postfix_service: postfix -postfix_daemon_directory: +_postfix_daemon_directory: default: /usr/libexec/postfix Debian: /usr/lib/postfix/sbin - Ubuntu: /usr/lib/postfix/sbin - openSUSE Leap: /usr/lib/postfix + Suse: /usr/lib/postfix/bin + +postfix_daemon_directory: "{{_postfix_daemon_directory[ansible_os_family] | default(_postfix_daemon_directory['default']) }}" postfix_group: postdrop @@ -18,4 +19,4 @@ _postfix_alias_path: Alpine: /etc/postfix/aliases Archlinux: /etc/postfix/aliases -postfix_alias_path: "{{ _postfix_alias_path[ansible_distribution] | default(_postfix_alias_path['default']) }}" +postfix_alias_path: "{{ _postfix_alias_path[ansible_os_family] | default(_postfix_alias_path['default']) }}" diff --git a/roles/python_pip/.ansible-lint b/roles/python_pip/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/python_pip/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/python_pip/.github/ISSUE_TEMPLATE/bug_report.md b/roles/python_pip/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/python_pip/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/python_pip/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/python_pip/.github/settings.yml b/roles/python_pip/.github/settings.yml index 7613060..98dbddf 100644 --- a/roles/python_pip/.github/settings.yml +++ b/roles/python_pip/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install pythons pip on your system. homepage: https://robertdebock.nl/ diff --git a/roles/python_pip/.gitignore b/roles/python_pip/.gitignore index 10b26d1..982db11 100644 --- a/roles/python_pip/.gitignore +++ b/roles/python_pip/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/python_pip/.travis.yml b/roles/python_pip/.travis.yml index 40eeb48..b1421c7 100644 --- a/roles/python_pip/.travis.yml +++ b/roles/python_pip/.travis.yml @@ -1,85 +1,46 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" expectation="fail" - - version="" distro="centos-6" expectation="fail" - - version="devel" distro="centos-6" expectation="fail" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="centos" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" expectation="fail" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/python_pip/CONTRIBUTING.md b/roles/python_pip/CONTRIBUTING.md index 3209430..6f436d4 100644 --- a/roles/python_pip/CONTRIBUTING.md +++ b/roles/python_pip/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/python_pip/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/python_pip), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/python_pip.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/python_pip/README.md b/roles/python_pip/README.md index 86d6b19..e7d96a4 100644 --- a/roles/python_pip/README.md +++ b/roles/python_pip/README.md @@ -2,14 +2,14 @@ python_pip ========= Ansible logo -Build status + Build status Install pythons pip on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -17,16 +17,11 @@ This example is taken from `molecule/resources/playbook.yml`: become: yes gather_facts: yes - vars: - python_pip_modules: - - name: jinja2 - - name: ansible - roles: - robertdebock.python_pip ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -40,6 +35,22 @@ The machine you are running this on, may need to be prepared. - robertdebock.buildtools ``` +After running this role, this playbook runs to verify that everything works, this may be a good example how you can use this role. +```yaml +--- +- name: Verify + hosts: all + become: yes + gather_facts: yes + + tasks: + - name: install pip module + pip: + name: ansible + state: present +``` +``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -49,13 +60,6 @@ These variables are set in `defaults/main.yml`: ```yaml --- # defaults file for python_pip - -# The version of pip to update to. -python_pip_version: 19.2.3 - -# The version of setuptools to update to. -python_pip_setuptools_version: 41.2.0 - # By default no modules should be installed. python_pip_modules: [] @@ -76,7 +80,6 @@ The following roles can be installed to ensure all requirements are met, using ` - robertdebock.bootstrap - robertdebock.buildtools - robertdebock.epel -- robertdebock.scl ``` @@ -92,52 +95,69 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|no|no|no*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tags| +|---------|----| +|alpine|all| +|archlinux|all| +|debian|all| +|el|7, 8| +|fedora|all| +|opensuse|all| +|ubuntu|artful, bionic| -A single star means the build may fail, it's marked as an experimental build. +The minimum version of Ansible required is 2.8 but tests have been done to: +- The previous version, on version lower. +- The current version. +- The development version. -Included version(s) -------------------- +Exceptions +---------- -This role [refers to a version](https://github.com/robertdebock/ansible-role-python_pip/blob/master/defaults/main.yml) released by PyPi. Check the released version(s) here: -- [pip](https://pypi.org/project/pip/). -- [setuptools](https://pypi.org/project/setuptools/). +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| amazonline:1 | ImportError: No module named pkg_resources | +| amazonline | ImportError: No module named pkg_resources | -This version reference means a role may get outdated. Monthly tests occur to see if [bit-rot](https://en.wikipedia.org/wiki/Software_rot) occured. If you however find a problem, please create an issue, I'll get on it as soon as possible. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-python_pip) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-python_pip) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-python_pip/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` License ------- diff --git a/roles/python_pip/defaults/main.yml b/roles/python_pip/defaults/main.yml index 7833736..e4532d4 100644 --- a/roles/python_pip/defaults/main.yml +++ b/roles/python_pip/defaults/main.yml @@ -1,12 +1,5 @@ --- # defaults file for python_pip - -# The version of pip to update to. -python_pip_version: 19.2.3 - -# The version of setuptools to update to. -python_pip_setuptools_version: 41.2.0 - # By default no modules should be installed. python_pip_modules: [] diff --git a/roles/python_pip/meta/.galaxy_install_info b/roles/python_pip/meta/.galaxy_install_info index d2d0548..1734496 100644 --- a/roles/python_pip/meta/.galaxy_install_info +++ b/roles/python_pip/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:51 2019', version: 2.1.0} +install_date: Mon Dec 16 06:45:33 2019 +version: 3.0.9 diff --git a/roles/python_pip/meta/exception.yml b/roles/python_pip/meta/exception.yml new file mode 100644 index 0000000..c6f46c0 --- /dev/null +++ b/roles/python_pip/meta/exception.yml @@ -0,0 +1,6 @@ +--- +exceptions: + - variation: amazonline:1 + reason: "ImportError: No module named pkg_resources" + - variation: amazonline + reason: "ImportError: No module named pkg_resources" diff --git a/roles/python_pip/meta/main.yml b/roles/python_pip/meta/main.yml index 7f8ab94..518806e 100644 --- a/roles/python_pip/meta/main.yml +++ b/roles/python_pip/meta/main.yml @@ -5,21 +5,22 @@ galaxy_info: description: Install pythons pip on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: + versions: - 7 + - 8 - name: Fedora versions: - all @@ -37,10 +38,6 @@ galaxy_info: - pypip - system - installer - - alpine - - debian - centos - - fedora - - ubuntu dependencies: [] diff --git a/roles/python_pip/meta/version.yml b/roles/python_pip/meta/version.yml deleted file mode 100644 index b4a6d37..0000000 --- a/roles/python_pip/meta/version.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -project_name: PyPi -reference: "https://github.com/robertdebock/ansible-role-python_pip/blob/master/defaults/main.yml" -versions: - - name: pip - url: "https://pypi.org/project/pip/" - - name: setuptools - url: "https://pypi.org/project/setuptools/" diff --git a/roles/python_pip/molecule/alpine-edge/molecule.yml b/roles/python_pip/molecule/alpine-edge/molecule.yml deleted file mode 100644 index d514bc9..0000000 --- a/roles/python_pip/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/python_pip/molecule/alpine-latest/molecule.yml b/roles/python_pip/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 3170774..0000000 --- a/roles/python_pip/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/python_pip/molecule/archlinux/molecule.yml b/roles/python_pip/molecule/archlinux/molecule.yml deleted file mode 100644 index a4d9986..0000000 --- a/roles/python_pip/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/python_pip/molecule/centos-6/molecule.yml b/roles/python_pip/molecule/centos-6/molecule.yml deleted file mode 100644 index 8fba79e..0000000 --- a/roles/python_pip/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/python_pip/molecule/centos-latest/molecule.yml b/roles/python_pip/molecule/centos-latest/molecule.yml deleted file mode 100644 index 27dbed3..0000000 --- a/roles/python_pip/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/python_pip/molecule/debian-stable/molecule.yml b/roles/python_pip/molecule/debian-stable/molecule.yml deleted file mode 100644 index d40b848..0000000 --- a/roles/python_pip/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/python_pip/molecule/debian-unstable/molecule.yml b/roles/python_pip/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 96712bb..0000000 --- a/roles/python_pip/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/python_pip/molecule/default/molecule.yml b/roles/python_pip/molecule/default/molecule.yml index 3c3bec9..5fc9054 100644 --- a/roles/python_pip/molecule/default/molecule.yml +++ b/roles/python_pip/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,19 @@ lint: driver: name: docker platforms: - - name: python_pip-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: python_pip-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: python_pip-archlinux - image: archlinux/base - pre_build_image: yes - - name: python_pip-centos-6 - image: centos:6 - pre_build_image: yes - - name: python_pip-centos-latest - image: centos:latest - pre_build_image: yes - - name: python_pip-debian-stable - image: debian:stable - pre_build_image: yes - - name: python_pip-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: python_pip-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: python_pip-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: python_pip-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: python_pip-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: python_pip-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: python_pip-ubuntu-devel - image: ubuntu:devel + - name: "python_pip-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml +verifier: + name: ansible lint: name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - python_pip-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - python_pip-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 + enabled: no scenario: name: default diff --git a/roles/python_pip/molecule/resources/playbook.yml b/roles/python_pip/molecule/default/playbook.yml similarity index 58% rename from roles/python_pip/molecule/resources/playbook.yml rename to roles/python_pip/molecule/default/playbook.yml index a694eb0..66d12e6 100644 --- a/roles/python_pip/molecule/resources/playbook.yml +++ b/roles/python_pip/molecule/default/playbook.yml @@ -4,10 +4,5 @@ become: yes gather_facts: yes - vars: - python_pip_modules: - - name: jinja2 - - name: ansible - roles: - ansible-role-python_pip diff --git a/roles/python_pip/molecule/resources/prepare.yml b/roles/python_pip/molecule/default/prepare.yml similarity index 100% rename from roles/python_pip/molecule/resources/prepare.yml rename to roles/python_pip/molecule/default/prepare.yml diff --git a/roles/python_pip/molecule/default/verify.yml b/roles/python_pip/molecule/default/verify.yml new file mode 100644 index 0000000..13736fb --- /dev/null +++ b/roles/python_pip/molecule/default/verify.yml @@ -0,0 +1,11 @@ +--- +- name: Verify + hosts: all + become: yes + gather_facts: yes + + tasks: + - name: install pip module + pip: + name: ansible + state: present diff --git a/roles/python_pip/molecule/ec2/README.md b/roles/python_pip/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/python_pip/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/python_pip/molecule/ec2/create.yml b/roles/python_pip/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/python_pip/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/python_pip/molecule/ec2/destroy.yml b/roles/python_pip/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/python_pip/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/python_pip/molecule/ec2/molecule.yml b/roles/python_pip/molecule/ec2/molecule.yml deleted file mode 100644 index ee138fb..0000000 --- a/roles/python_pip/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: python_pip-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: python_pip-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: python_pip-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: python_pip-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: python_pip-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: python_pip-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - python_pip-ubuntu-18.04: - ansible_user: ubuntu - python_pip-centos-7: - ansible_user: centos - python_pip-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/python_pip/molecule/fedora-latest/molecule.yml b/roles/python_pip/molecule/fedora-latest/molecule.yml deleted file mode 100644 index c3a4fcc..0000000 --- a/roles/python_pip/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/python_pip/molecule/fedora-rawhide/molecule.yml b/roles/python_pip/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index f4fb114..0000000 --- a/roles/python_pip/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/python_pip/molecule/opensuse-leap/molecule.yml b/roles/python_pip/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 9a13524..0000000 --- a/roles/python_pip/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/python_pip/molecule/ubuntu-devel/molecule.yml b/roles/python_pip/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index c0116bf..0000000 --- a/roles/python_pip/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/python_pip/molecule/ubuntu-latest/molecule.yml b/roles/python_pip/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index c39f5bc..0000000 --- a/roles/python_pip/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/python_pip/molecule/ubuntu-rolling/molecule.yml b/roles/python_pip/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 84d27ca..0000000 --- a/roles/python_pip/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: python_pip-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/python_pip/molecule/vagrant/INSTALL.rst b/roles/python_pip/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/python_pip/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/python_pip/molecule/vagrant/molecule.yml b/roles/python_pip/molecule/vagrant/molecule.yml deleted file mode 100644 index 4247a001..0000000 --- a/roles/python_pip/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: python_pip-debian - box: debian/stretch64 - - name: python_pip-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - python_pip-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/python_pip/requirements.yml b/roles/python_pip/requirements.yml index bc4c55b..0682eb0 100644 --- a/roles/python_pip/requirements.yml +++ b/roles/python_pip/requirements.yml @@ -2,4 +2,3 @@ - robertdebock.bootstrap - robertdebock.buildtools - robertdebock.epel -- robertdebock.scl diff --git a/roles/python_pip/tasks/main.yml b/roles/python_pip/tasks/main.yml index 9780ba9..64e25e5 100644 --- a/roles/python_pip/tasks/main.yml +++ b/roles/python_pip/tasks/main.yml @@ -8,25 +8,7 @@ until: python_pip_install_python_pip is succeeded retries: 3 -- name: update pip - pip: - name: pip - state: present - version: "{{ python_pip_version }}" - register: update_pip - until: update_pip is succeeded - retries: 3 - -- name: update setuptools - pip: - name: setuptools - state: present - version: "{{ python_pip_setuptools_version }}" - register: update_setuptools - until: update_setuptools is succeeded - retries: 3 - -- name: Configure pip proxy +- name: configure pip proxy ini_file: path: /etc/pip.conf section: global @@ -42,6 +24,8 @@ version: "{{ item.version | default(omit) }}" with_items: - "{{ python_pip_modules }}" + loop_control: + label: "{{ item.name }}" register: install_requested_modules until: install_requested_modules is succeeded retries: 3 diff --git a/roles/python_pip/tox.ini b/roles/python_pip/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/python_pip/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/python_pip/vars/main.yml b/roles/python_pip/vars/main.yml index a18230d..f33b957 100644 --- a/roles/python_pip/vars/main.yml +++ b/roles/python_pip/vars/main.yml @@ -1,12 +1,27 @@ --- # vars file for python_pip _python_pip_packages: - default: - - python-pip Alpine: - py-pip + - py-setuptools - python2-dev - Ubuntu: + Archlinux: - python-pip + - python-setuptools + Debian: + - python3-pip + - python3-setuptools + CentOS-7: + - python2-pip + - python-setuptools + RedHat-7: + - python2-pip + - python-setuptools + RedHat: + - python3-pip + - python3-setuptools + Suse: + - python-pip + - python-setuptools -python_pip_packages: "{{ _python_pip_packages[ansible_distribution] | default(_python_pip_packages['default']) }}" +python_pip_packages: "{{ _python_pip_packages[ansible_distribution ~ '-' ~ ansible_distribution_major_version] | default(_python_pip_packages[ansible_os_family] | default(_python_pip_packages['default'])) }}" diff --git a/roles/reboot/.ansible-lint b/roles/reboot/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/reboot/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/reboot/.github/ISSUE_TEMPLATE/bug_report.md b/roles/reboot/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/reboot/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/reboot/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/reboot/.github/settings.yml b/roles/reboot/.github/settings.yml index c090903..82c8276 100644 --- a/roles/reboot/.github/settings.yml +++ b/roles/reboot/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: The purpose of this role is to reboot your system. homepage: https://robertdebock.nl/ diff --git a/roles/reboot/.gitignore b/roles/reboot/.gitignore index 10b26d1..982db11 100644 --- a/roles/reboot/.gitignore +++ b/roles/reboot/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/reboot/.travis.yml b/roles/reboot/.travis.yml index 5e62789..d0b5d38 100644 --- a/roles/reboot/.travis.yml +++ b/roles/reboot/.travis.yml @@ -1,85 +1,47 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" expectation="fail" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="alpine" + - image="alpine" tag="edge" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="redhat" tag="7" + - image="centos" + - image="redhat" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/reboot/CONTRIBUTING.md b/roles/reboot/CONTRIBUTING.md index 3209430..b8b9b09 100644 --- a/roles/reboot/CONTRIBUTING.md +++ b/roles/reboot/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/reboot/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/reboot), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/reboot.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/reboot/README.md b/roles/reboot/README.md index cea3f1f..273af57 100644 --- a/roles/reboot/README.md +++ b/roles/reboot/README.md @@ -2,14 +2,14 @@ reboot ========= Ansible logo -Build status + Build status The purpose of this role is to reboot your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.reboot ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -33,6 +33,7 @@ The machine you are running this on, may need to be prepared. - robertdebock.bootstrap ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -83,25 +84,28 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|no|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|redhat|7|no| +|centos|latest|no| +|redhat|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| -A single star means the build may fail, it's marked as an experimental build. +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel Exceptions ---------- @@ -110,26 +114,59 @@ Some variarations of the build matrix do not work. These are the variations and | variation | reason | |---------------------------|------------------------| -| Archlinux & Ansible 2.7 | New-style module did not handle its own exit | - +| archlinux/base | New-style module did not handle its own exit | Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-reboot) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-reboot) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-reboot/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- command +- meta +- package +- pause +- setup +- shell +- stat +- wait_for_connection +``` License ------- diff --git a/roles/reboot/meta/.galaxy_install_info b/roles/reboot/meta/.galaxy_install_info index 41fca9d..9537fad 100644 --- a/roles/reboot/meta/.galaxy_install_info +++ b/roles/reboot/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:55 2019', version: 2.1.2} +install_date: Mon Dec 16 06:45:38 2019 +version: 2.3.4 diff --git a/roles/reboot/meta/exception.yml b/roles/reboot/meta/exception.yml index 6da44d3..98f94ba 100644 --- a/roles/reboot/meta/exception.yml +++ b/roles/reboot/meta/exception.yml @@ -1,4 +1,4 @@ --- exceptions: - - variation: Archlinux & Ansible 2.7 + - variation: archlinux/base reason: New-style module did not handle its own exit diff --git a/roles/reboot/meta/main.yml b/roles/reboot/meta/main.yml index 3d39caa..668b055 100644 --- a/roles/reboot/meta/main.yml +++ b/roles/reboot/meta/main.yml @@ -5,22 +5,19 @@ galaxy_info: description: The purpose of this role is to reboot your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - name: Alpine versions: - all - - name: ArchLinux - version: - - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -34,14 +31,8 @@ galaxy_info: galaxy_tags: - reboot - - alpine - archlinux - centos - - debian - - el - - fedora - - opensuse - - rhel - - ubuntu + - redhat dependencies: [] diff --git a/roles/reboot/molecule/alpine-edge/molecule.yml b/roles/reboot/molecule/alpine-edge/molecule.yml deleted file mode 100644 index e125f9b..0000000 --- a/roles/reboot/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/reboot/molecule/alpine-latest/molecule.yml b/roles/reboot/molecule/alpine-latest/molecule.yml deleted file mode 100644 index dfdccb8..0000000 --- a/roles/reboot/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/reboot/molecule/archlinux/molecule.yml b/roles/reboot/molecule/archlinux/molecule.yml deleted file mode 100644 index 0e0d4ed..0000000 --- a/roles/reboot/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/reboot/molecule/centos-6/molecule.yml b/roles/reboot/molecule/centos-6/molecule.yml deleted file mode 100644 index b9818d7..0000000 --- a/roles/reboot/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/reboot/molecule/centos-latest/molecule.yml b/roles/reboot/molecule/centos-latest/molecule.yml deleted file mode 100644 index dcd7671..0000000 --- a/roles/reboot/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/reboot/molecule/debian-stable/molecule.yml b/roles/reboot/molecule/debian-stable/molecule.yml deleted file mode 100644 index de1f5cf..0000000 --- a/roles/reboot/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/reboot/molecule/debian-unstable/molecule.yml b/roles/reboot/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 8c4d314..0000000 --- a/roles/reboot/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/reboot/molecule/default/molecule.yml b/roles/reboot/molecule/default/molecule.yml index e9a1a3e..6c474e9 100644 --- a/roles/reboot/molecule/default/molecule.yml +++ b/roles/reboot/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: reboot-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: reboot-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: reboot-archlinux - image: archlinux/base - pre_build_image: yes - - name: reboot-centos-6 - image: centos:6 - pre_build_image: yes - - name: reboot-centos-latest - image: centos:latest - pre_build_image: yes - - name: reboot-debian-stable - image: debian:stable - pre_build_image: yes - - name: reboot-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: reboot-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: reboot-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: reboot-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: reboot-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: reboot-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: reboot-ubuntu-devel - image: ubuntu:devel + - name: "reboot-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - reboot-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - reboot-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/reboot/molecule/resources/playbook.yml b/roles/reboot/molecule/default/playbook.yml similarity index 100% rename from roles/reboot/molecule/resources/playbook.yml rename to roles/reboot/molecule/default/playbook.yml diff --git a/roles/reboot/molecule/resources/prepare.yml b/roles/reboot/molecule/default/prepare.yml similarity index 100% rename from roles/reboot/molecule/resources/prepare.yml rename to roles/reboot/molecule/default/prepare.yml diff --git a/roles/reboot/molecule/ec2/README.md b/roles/reboot/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/reboot/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/reboot/molecule/ec2/create.yml b/roles/reboot/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/reboot/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/reboot/molecule/ec2/destroy.yml b/roles/reboot/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/reboot/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/reboot/molecule/ec2/molecule.yml b/roles/reboot/molecule/ec2/molecule.yml deleted file mode 100644 index 89c717b..0000000 --- a/roles/reboot/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: reboot-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - reboot-ubuntu-18.04: - ansible_user: ubuntu - reboot-centos-7: - ansible_user: centos - reboot-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/reboot/molecule/fedora-latest/molecule.yml b/roles/reboot/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 03239cc..0000000 --- a/roles/reboot/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/reboot/molecule/fedora-rawhide/molecule.yml b/roles/reboot/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 2f9225f..0000000 --- a/roles/reboot/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/reboot/molecule/opensuse-leap/molecule.yml b/roles/reboot/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 46f8ed7..0000000 --- a/roles/reboot/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/reboot/molecule/ubuntu-devel/molecule.yml b/roles/reboot/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index e56e3ee..0000000 --- a/roles/reboot/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/reboot/molecule/ubuntu-latest/molecule.yml b/roles/reboot/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 387d353..0000000 --- a/roles/reboot/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/reboot/molecule/ubuntu-rolling/molecule.yml b/roles/reboot/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 3ecf893..0000000 --- a/roles/reboot/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/reboot/molecule/vagrant/INSTALL.rst b/roles/reboot/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/reboot/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/reboot/molecule/vagrant/molecule.yml b/roles/reboot/molecule/vagrant/molecule.yml deleted file mode 100644 index 8f9f8b7..0000000 --- a/roles/reboot/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: reboot-debian - box: debian/stretch64 - - name: reboot-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - reboot-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/reboot/robertdebock.reboot/.github/ISSUE_TEMPLATE/bug_report.md b/roles/reboot/robertdebock.reboot/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index bd1a0dc..0000000 --- a/roles/reboot/robertdebock.reboot/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - -**Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. diff --git a/roles/reboot/robertdebock.reboot/.github/ISSUE_TEMPLATE/feature_request.md b/roles/reboot/robertdebock.reboot/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 066b2d9..0000000 --- a/roles/reboot/robertdebock.reboot/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/roles/reboot/robertdebock.reboot/.github/settings.yml b/roles/reboot/robertdebock.reboot/.github/settings.yml deleted file mode 100644 index c090903..0000000 --- a/roles/reboot/robertdebock.reboot/.github/settings.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -repository: - description: The purpose of this role is to reboot your system. - homepage: https://robertdebock.nl/ diff --git a/roles/reboot/robertdebock.reboot/.gitignore b/roles/reboot/robertdebock.reboot/.gitignore deleted file mode 100644 index 10b26d1..0000000 --- a/roles/reboot/robertdebock.reboot/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -molecule/*/.molecule -*.log -*.swp diff --git a/roles/reboot/robertdebock.reboot/.travis.yml b/roles/reboot/robertdebock.reboot/.travis.yml deleted file mode 100644 index 5e62789..0000000 --- a/roles/reboot/robertdebock.reboot/.travis.yml +++ /dev/null @@ -1,88 +0,0 @@ ---- -sudo: required -language: python -services: docker - -env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" expectation="fail" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" - -matrix: - allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" - -cache: - - pip - -install: - - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker - -script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ - slack: - secure: "KeXA8wXxYX41jjXJAMEU3dBFf0jf6T/OuY62Zt6fCxmse+R4nC7P6TZGx7LKjaVCXKdRz3+giJz7Ef/7q23yTSFIoasiB0rzWiAg0S0E5o8ZFdJ0HdQQZknA7j21GcvK9Kj/zgxXUqFu6hhc+vgKRnPAMOjpyaoo74PwG4kHARFLAxb7fKdCxhkfBWvtdkgAUWzESWNeUHNsknFlbEP7PTk1akfsOaC3xUYjfA7kmZMH6w0eM+/FuTaoYdJ8EM3OcH+3j2q0IXuXVrJ0B1IyGvpJ1qVvDu9YSvkxbD6Qd9BCVRDBkCcTxsBpZX+Ks5DhaTOO71zsk1nZtBIFPAanXARygoyuMrAS4exfSrWT2TTxu0D01J9JZUlGmI/Uf7R9Kf7LAT1KfvZR/7VAK3X53i3pZHQqp8EOPr+FGpB9MPn62jfWF7gWYR8AfP4M1gaP7JYVxZqmSKE0LgqQNY/SmPcs37TU8jL6h1ojN0PPy8tRhGUhY3/tQq/19aF62WDTzH1j/OgcI5GrAZ2bR8EOQGvSfJX2uWnFhBQsISxaYo4Eiocw5z/QGU/JFBXOgipAGeS2PjiR3PYa3SkeftEOHnbp7rzakKd4zDCM/EGiIG4rPnFSwvVPBnnm64ut+PqpX8JI5uxdoJ8bjVIM/47hGNUnVFIG/ZQUXzI5vySqwyY=" - email: false diff --git a/roles/reboot/robertdebock.reboot/.yamllint b/roles/reboot/robertdebock.reboot/.yamllint deleted file mode 100644 index ad0be76..0000000 --- a/roles/reboot/robertdebock.reboot/.yamllint +++ /dev/null @@ -1,11 +0,0 @@ -extends: default - -rules: - braces: - max-spaces-inside: 1 - level: error - brackets: - max-spaces-inside: 1 - level: error - line-length: disable - truthy: disable diff --git a/roles/reboot/robertdebock.reboot/CODE_OF_CONDUCT.md b/roles/reboot/robertdebock.reboot/CODE_OF_CONDUCT.md deleted file mode 100644 index 0d97a6f..0000000 --- a/roles/reboot/robertdebock.reboot/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,46 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behaviour that contributes to creating a positive environment include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behaviour by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable behaviour and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behaviour. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviours that they deem inappropriate, threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported by contacting the project team at robert@meinit.nl. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/roles/reboot/robertdebock.reboot/CONTRIBUTING.md b/roles/reboot/robertdebock.reboot/CONTRIBUTING.md deleted file mode 100644 index 3209430..0000000 --- a/roles/reboot/robertdebock.reboot/CONTRIBUTING.md +++ /dev/null @@ -1,10 +0,0 @@ -# Please contribute - -You can really make a difference by: - -- [Making an issue](https://help.github.com/articles/creating-an-issue/). A well described issue helps a lot. (Have a look at the [known issues](https://github.com/search?q=user%3Arobertdebock+is%3Aissue+state%3Aopen).) -- [Making a pull request](https://services.github.com/on-demand/github-cli/open-pull-request-github) when you see the error in code. - -I'll try to help and take every contribution seriously. - -It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. diff --git a/roles/reboot/robertdebock.reboot/LICENSE b/roles/reboot/robertdebock.reboot/LICENSE deleted file mode 100644 index 744118c..0000000 --- a/roles/reboot/robertdebock.reboot/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2019 Robert de Bock (robert@meinit.nl) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/roles/reboot/robertdebock.reboot/PULL_REQUEST_TEMPLATE.md b/roles/reboot/robertdebock.reboot/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b1578c0..0000000 --- a/roles/reboot/robertdebock.reboot/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -name: Pull request -about: Describe the proposed change - ---- - -**Describe the change** -A clear and concise description of what the pull request is. - -**Testing** -In case a feature was added, how were tests performed? diff --git a/roles/reboot/robertdebock.reboot/README.md b/roles/reboot/robertdebock.reboot/README.md deleted file mode 100644 index cea3f1f..0000000 --- a/roles/reboot/robertdebock.reboot/README.md +++ /dev/null @@ -1,143 +0,0 @@ -reboot -========= - -Ansible logo -Build status - -The purpose of this role is to reboot your system. - -Example Playbook ----------------- - -This example is taken from `molecule/resources/playbook.yml`: -```yaml ---- -- name: Converge - hosts: all - become: yes - gather_facts: yes - - roles: - - robertdebock.reboot -``` - -The machine you are running this on, may need to be prepared. -```yaml ---- -- name: Prepare - hosts: all - gather_facts: no - become: yes - - roles: - - robertdebock.bootstrap -``` - -Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. - -Role Variables --------------- - -These variables are set in `defaults/main.yml`: -```yaml ---- -# defaults file for reboot - -# Some operating systems can determine if a reboot is required. This -# parameter can be set to always reboot. -reboot_always: no - -# How long to wait before sending a reboot. -reboot_delay: 4 - -# Number of seconds to wait before checking if the machine is up. -reboot_up_delay: 8 - -# You can specify a message for rebooting, easier for auditing. -reboot_message: "Ansible role robertdebock.reboot initiated a reboot." -``` - -Requirements ------------- - -- Access to a repository containing packages, likely on the internet. -- A recent version of Ansible. (Tests run on the current, previous and next release of Ansible.) - -The following roles can be installed to ensure all requirements are met, using `ansible-galaxy install -r requirements.yml`: - -```yaml ---- -- robertdebock.bootstrap - -``` - -Context -------- - -This role is a part of many compatible roles. Have a look at [the documentation of these roles](https://robertdebock.nl/) for further information. - -Here is an overview of related roles: -![dependencies](https://raw.githubusercontent.com/robertdebock/drawings/artifacts/reboot.png "Dependency") - - -Compatibility -------------- - -This role has been tested against the following distributions and Ansible version: - -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|no|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| - -A single star means the build may fail, it's marked as an experimental build. - -Exceptions ----------- - -Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: - -| variation | reason | -|---------------------------|------------------------| -| Archlinux & Ansible 2.7 | New-style module did not handle its own exit | - - - -Testing -------- - -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-reboot) are done on every commit and periodically. - -If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-reboot/issues) - -To test this role locally please use [Molecule](https://github.com/ansible/molecule): -``` -pip install molecule -molecule test -``` - -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. - -There are many specific scenarios available, please have a look in the `molecule/` directory. - -License -------- - -Apache-2.0 - - -Author Information ------------------- - -[Robert de Bock](https://robertdebock.nl/) diff --git a/roles/reboot/robertdebock.reboot/SECURITY.md b/roles/reboot/robertdebock.reboot/SECURITY.md deleted file mode 100644 index 6293767..0000000 --- a/roles/reboot/robertdebock.reboot/SECURITY.md +++ /dev/null @@ -1,23 +0,0 @@ -# Security Policy - -This software implements other software, it's not very likely that this software introduces new vulnerabilities. - -## Supported Versions - -The current major version is supported. For example if the current version is 3.4.1: - -| Version | Supported | -| ------- | ------------------ | -| 3.4.1 | :white_check_mark: | -| 3.4.x | :white_check_mark: | -| 3.x.x | :white_check_mark: | -| 2.0.0 | :x: | -| 1.0.0 | :x: | - -## Reporting a Vulnerability - -Please [open an issue](https://github.com/robertdebock/ansible-role-reboot/issues) describing the vulnerability. - -Tell them where to go, how often they can expect to get an update on a -reported vulnerability, what to expect if the vulnerability is accepted or -declined, etc. diff --git a/roles/reboot/robertdebock.reboot/defaults/main.yml b/roles/reboot/robertdebock.reboot/defaults/main.yml deleted file mode 100644 index 5e045f5..0000000 --- a/roles/reboot/robertdebock.reboot/defaults/main.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -# defaults file for reboot - -# Some operating systems can determine if a reboot is required. This -# parameter can be set to always reboot. -reboot_always: no - -# How long to wait before sending a reboot. -reboot_delay: 4 - -# Number of seconds to wait before checking if the machine is up. -reboot_up_delay: 8 - -# You can specify a message for rebooting, easier for auditing. -reboot_message: "Ansible role robertdebock.reboot initiated a reboot." diff --git a/roles/reboot/robertdebock.reboot/handlers/main.yml b/roles/reboot/robertdebock.reboot/handlers/main.yml deleted file mode 100644 index 294f982..0000000 --- a/roles/reboot/robertdebock.reboot/handlers/main.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -# handlers file for reboot -- name: 1 wait for the start of reboot - pause: - seconds: "{{ reboot_delay }}" - -- name: 2 wait for the machine to be up - wait_for_connection: - delay: "{{ reboot_up_delay }}" - -- name: 3 gather facts after reboot - setup: diff --git a/roles/reboot/robertdebock.reboot/meta/.galaxy_install_info b/roles/reboot/robertdebock.reboot/meta/.galaxy_install_info deleted file mode 100644 index f80f9c5..0000000 --- a/roles/reboot/robertdebock.reboot/meta/.galaxy_install_info +++ /dev/null @@ -1 +0,0 @@ -{install_date: 'Tue Sep 17 04:22:14 2019', version: 2.1.2} diff --git a/roles/reboot/robertdebock.reboot/meta/exception.yml b/roles/reboot/robertdebock.reboot/meta/exception.yml deleted file mode 100644 index 6da44d3..0000000 --- a/roles/reboot/robertdebock.reboot/meta/exception.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -exceptions: - - variation: Archlinux & Ansible 2.7 - reason: New-style module did not handle its own exit diff --git a/roles/reboot/robertdebock.reboot/meta/main.yml b/roles/reboot/robertdebock.reboot/meta/main.yml deleted file mode 100644 index 3d39caa..0000000 --- a/roles/reboot/robertdebock.reboot/meta/main.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -galaxy_info: - author: Robert de Bock - role_name: reboot - description: The purpose of this role is to reboot your system. - license: Apache-2.0 - company: none - min_ansible_version: 2.6 - - platforms: - - name: Alpine - versions: - - all - - name: ArchLinux - version: - - all - - name: Debian - versions: - - all - - name: EL - version: - - 6 - - 7 - - name: Fedora - versions: - - all - - name: OpenSUSE - versions: - - all - - name: Ubuntu - versions: - - artful - - bionic - - galaxy_tags: - - reboot - - alpine - - archlinux - - centos - - debian - - el - - fedora - - opensuse - - rhel - - ubuntu - -dependencies: [] diff --git a/roles/reboot/robertdebock.reboot/molecule/alpine-edge/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/alpine-edge/molecule.yml deleted file mode 100644 index e125f9b..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/reboot/robertdebock.reboot/molecule/alpine-latest/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/alpine-latest/molecule.yml deleted file mode 100644 index dfdccb8..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/reboot/robertdebock.reboot/molecule/archlinux/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/archlinux/molecule.yml deleted file mode 100644 index 0e0d4ed..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/reboot/robertdebock.reboot/molecule/centos-6/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/centos-6/molecule.yml deleted file mode 100644 index b9818d7..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/reboot/robertdebock.reboot/molecule/centos-latest/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/centos-latest/molecule.yml deleted file mode 100644 index dcd7671..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/reboot/robertdebock.reboot/molecule/debian-stable/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/debian-stable/molecule.yml deleted file mode 100644 index de1f5cf..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/reboot/robertdebock.reboot/molecule/debian-unstable/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 8c4d314..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/reboot/robertdebock.reboot/molecule/default/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/default/molecule.yml deleted file mode 100644 index e9a1a3e..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/default/molecule.yml +++ /dev/null @@ -1,70 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: reboot-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: reboot-archlinux - image: archlinux/base - pre_build_image: yes - - name: reboot-centos-6 - image: centos:6 - pre_build_image: yes - - name: reboot-centos-latest - image: centos:latest - pre_build_image: yes - - name: reboot-debian-stable - image: debian:stable - pre_build_image: yes - - name: reboot-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: reboot-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: reboot-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: reboot-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: reboot-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: reboot-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: reboot-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - reboot-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - reboot-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: default diff --git a/roles/reboot/robertdebock.reboot/molecule/ec2/README.md b/roles/reboot/robertdebock.reboot/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/reboot/robertdebock.reboot/molecule/ec2/create.yml b/roles/reboot/robertdebock.reboot/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/reboot/robertdebock.reboot/molecule/ec2/destroy.yml b/roles/reboot/robertdebock.reboot/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/reboot/robertdebock.reboot/molecule/ec2/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/ec2/molecule.yml deleted file mode 100644 index 89c717b..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: reboot-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: reboot-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - reboot-ubuntu-18.04: - ansible_user: ubuntu - reboot-centos-7: - ansible_user: centos - reboot-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/reboot/robertdebock.reboot/molecule/fedora-latest/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 03239cc..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/reboot/robertdebock.reboot/molecule/fedora-rawhide/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 2f9225f..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/reboot/robertdebock.reboot/molecule/opensuse-leap/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 46f8ed7..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/reboot/robertdebock.reboot/molecule/resources/prepare.yml b/roles/reboot/robertdebock.reboot/molecule/resources/prepare.yml deleted file mode 100644 index 1cda60c..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/resources/prepare.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Prepare - hosts: all - gather_facts: no - become: yes - - roles: - - robertdebock.bootstrap diff --git a/roles/reboot/robertdebock.reboot/molecule/ubuntu-devel/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index e56e3ee..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/reboot/robertdebock.reboot/molecule/ubuntu-latest/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 387d353..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/reboot/robertdebock.reboot/molecule/ubuntu-rolling/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 3ecf893..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: reboot-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/reboot/robertdebock.reboot/molecule/vagrant/INSTALL.rst b/roles/reboot/robertdebock.reboot/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/reboot/robertdebock.reboot/molecule/vagrant/molecule.yml b/roles/reboot/robertdebock.reboot/molecule/vagrant/molecule.yml deleted file mode 100644 index 8f9f8b7..0000000 --- a/roles/reboot/robertdebock.reboot/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: reboot-debian - box: debian/stretch64 - - name: reboot-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - reboot-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/reboot/robertdebock.reboot/requirements.yml b/roles/reboot/robertdebock.reboot/requirements.yml deleted file mode 100644 index 46dec9d..0000000 --- a/roles/reboot/robertdebock.reboot/requirements.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- robertdebock.bootstrap diff --git a/roles/reboot/robertdebock.reboot/tasks/main.yml b/roles/reboot/robertdebock.reboot/tasks/main.yml deleted file mode 100644 index 217b0b9..0000000 --- a/roles/reboot/robertdebock.reboot/tasks/main.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- -# tasks file for reboot -- name: install requirements - package: - name: "{{ reboot_requirements }}" - state: present - register: reboot_install_requirements - until: reboot_install_requirements is succeeded - retries: 3 - -- name: check for needs-restarting for rhel - stat: - path: /usr/bin/needs-restarting - register: reboot_check_for_needs_restarting_for_rhel - -- name: check for needs-restarting for debian - stat: - path: /var/run/needs-restarting - register: reboot_check_for_needs_restarting_for_debian - -- name: see if a reboot is required for rhel - command: "{{ reboot_needs_restarting_command }}" - register: needsrestarting - changed_when: - - needsrestarting.rc != 0 - failed_when: - - needsrestarting.rc != 1 - - needsrestarting.rc != 0 - when: - - ansible_virtualization_type != "docker" - - reboot_check_for_needs_restarting_for_rhel.stat.exists - - not reboot_always | bool - -- name: show reboot_check_for_needs_restarting_for_rhel.stat.exists - debug: - var: reboot_check_for_needs_restarting_for_rhel.stat.exists - -- name: show needsrestarting.rc - debug: - var: needsrestarting.rc - -- name: show reboot_check_for_needs_restarting_for_debian.stat.exists - debug: - var: reboot_check_for_needs_restarting_for_debian.stat.exists - -- name: reboot the machine - shell: "(sleep {{ reboot_delay }} && {{ reboot_command }} &)" - async: 1 - poll: 0 - ignore_errors: yes - when: - - ansible_virtualization_type != "docker" - - (reboot_check_for_needs_restarting_for_rhel.stat.exists and - needsrestarting.rc == 1) or - reboot_check_for_needs_restarting_for_debian.stat.exists - notify: - - 1 wait for the start of reboot - - 2 wait for the machine to be up - - 3 gather facts after reboot - -- name: flush handlers - meta: flush_handlers diff --git a/roles/reboot/robertdebock.reboot/vars/main.yml b/roles/reboot/robertdebock.reboot/vars/main.yml deleted file mode 100644 index 5a51e8d..0000000 --- a/roles/reboot/robertdebock.reboot/vars/main.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -# vars file for reboot -_reboot_requirements: - default: [] - CentOS: yum-utils - Fedora: dnf-utils - -reboot_requirements: "{{ _reboot_requirements[ansible_distribution] | default(_reboot_requirements['default']) }}" - -_reboot_needs_restarting_command: - CentOS: needs-restarting -r - Fedora: needs-restarting - -reboot_needs_restarting_command: "{{ _reboot_needs_restarting_command[ansible_distribution] }}" - -_reboot_command: - default: shutdown -r now {{ reboot_message }} - Alpine: reboot - -reboot_command: "{{ _reboot_command[ansible_distribution] | default(_reboot_command['default']) }}" diff --git a/roles/reboot/tasks/main.yml b/roles/reboot/tasks/main.yml index 217b0b9..d9c41c3 100644 --- a/roles/reboot/tasks/main.yml +++ b/roles/reboot/tasks/main.yml @@ -31,18 +31,6 @@ - reboot_check_for_needs_restarting_for_rhel.stat.exists - not reboot_always | bool -- name: show reboot_check_for_needs_restarting_for_rhel.stat.exists - debug: - var: reboot_check_for_needs_restarting_for_rhel.stat.exists - -- name: show needsrestarting.rc - debug: - var: needsrestarting.rc - -- name: show reboot_check_for_needs_restarting_for_debian.stat.exists - debug: - var: reboot_check_for_needs_restarting_for_debian.stat.exists - - name: reboot the machine shell: "(sleep {{ reboot_delay }} && {{ reboot_command }} &)" async: 1 @@ -50,9 +38,10 @@ ignore_errors: yes when: - ansible_virtualization_type != "docker" - - (reboot_check_for_needs_restarting_for_rhel.stat.exists and + - reboot_always | bool or + ((reboot_check_for_needs_restarting_for_rhel.stat.exists and needsrestarting.rc == 1) or - reboot_check_for_needs_restarting_for_debian.stat.exists + reboot_check_for_needs_restarting_for_debian.stat.exists) notify: - 1 wait for the start of reboot - 2 wait for the machine to be up diff --git a/roles/reboot/tox.ini b/roles/reboot/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/reboot/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/reboot/vars/main.yml b/roles/reboot/vars/main.yml index 5a51e8d..3ae0173 100644 --- a/roles/reboot/vars/main.yml +++ b/roles/reboot/vars/main.yml @@ -8,13 +8,13 @@ _reboot_requirements: reboot_requirements: "{{ _reboot_requirements[ansible_distribution] | default(_reboot_requirements['default']) }}" _reboot_needs_restarting_command: - CentOS: needs-restarting -r - Fedora: needs-restarting + RedHat-7: needs-restarting -r + RedHat: needs-restarting -reboot_needs_restarting_command: "{{ _reboot_needs_restarting_command[ansible_distribution] }}" +reboot_needs_restarting_command: "{{ _reboot_needs_restarting_command[ansible_os_family ~ '-' ~ ansible_distribution_major_version] | default(_reboot_needs_restarting_command[ansible_os_family]) }}" _reboot_command: default: shutdown -r now {{ reboot_message }} Alpine: reboot -reboot_command: "{{ _reboot_command[ansible_distribution] | default(_reboot_command['default']) }}" +reboot_command: "{{ _reboot_command[ansible_os_family] | default(_reboot_command['default']) }}" diff --git a/roles/robertdebock.reboot b/roles/robertdebock.reboot deleted file mode 120000 index 7af01a4..0000000 --- a/roles/robertdebock.reboot +++ /dev/null @@ -1 +0,0 @@ -reboot/ \ No newline at end of file diff --git a/roles/ruby/.ansible-lint b/roles/ruby/.ansible-lint new file mode 100644 index 0000000..788f1ce --- /dev/null +++ b/roles/ruby/.ansible-lint @@ -0,0 +1,3 @@ +# +# Ansible managed +# diff --git a/roles/ruby/.github/ISSUE_TEMPLATE/bug_report.md b/roles/ruby/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/ruby/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/ruby/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/ruby/.github/settings.yml b/roles/ruby/.github/settings.yml index 42056fa..6a92b70 100644 --- a/roles/ruby/.github/settings.yml +++ b/roles/ruby/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install ruby on your system. homepage: https://robertdebock.nl/ diff --git a/roles/ruby/.gitignore b/roles/ruby/.gitignore index 10b26d1..982db11 100644 --- a/roles/ruby/.gitignore +++ b/roles/ruby/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/ruby/.travis.yml b/roles/ruby/.travis.yml index 5de9158..c22196e 100644 --- a/roles/ruby/.travis.yml +++ b/roles/ruby/.travis.yml @@ -1,85 +1,50 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="redhat" tag="7" + - image="centos" + - image="redhat" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/ruby/CONTRIBUTING.md b/roles/ruby/CONTRIBUTING.md index 3209430..75b2f37 100644 --- a/roles/ruby/CONTRIBUTING.md +++ b/roles/ruby/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/ruby/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/ruby), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/ruby.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/ruby/README.md b/roles/ruby/README.md index 5f9f0ad..04f88ca 100644 --- a/roles/ruby/README.md +++ b/roles/ruby/README.md @@ -2,14 +2,14 @@ ruby ========= Ansible logo -Build status + Build status Install ruby on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.ruby ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -33,6 +33,7 @@ The machine you are running this on, may need to be prepared. - robertdebock.bootstrap ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -70,42 +71,76 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): + +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|1|no| +|amazonlinux|latest|no| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|redhat|7|no| +|centos|latest|no| +|redhat|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-ruby) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-ruby) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-ruby/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- package +``` License ------- diff --git a/roles/ruby/meta/.galaxy_install_info b/roles/ruby/meta/.galaxy_install_info index f4ec2e4..5fd5702 100644 --- a/roles/ruby/meta/.galaxy_install_info +++ b/roles/ruby/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:21:58 2019', version: 2.0.6} +install_date: Mon Dec 16 06:45:43 2019 +version: 2.1.2 diff --git a/roles/ruby/meta/main.yml b/roles/ruby/meta/main.yml index bae770b..9dc4061 100644 --- a/roles/ruby/meta/main.yml +++ b/roles/ruby/meta/main.yml @@ -5,24 +5,27 @@ galaxy_info: description: Install ruby on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora - version: + versions: - all - name: OpenSUSE versions: @@ -36,11 +39,7 @@ galaxy_info: - ruby - installer - package - - alpine - centos - - debian - - fedora - - rhel - - ubuntu + - redhat dependencies: [] diff --git a/roles/ruby/molecule/alpine-edge/molecule.yml b/roles/ruby/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 300e89b..0000000 --- a/roles/ruby/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/ruby/molecule/alpine-latest/molecule.yml b/roles/ruby/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 9839d7c..0000000 --- a/roles/ruby/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/ruby/molecule/archlinux/molecule.yml b/roles/ruby/molecule/archlinux/molecule.yml deleted file mode 100644 index 47ea411..0000000 --- a/roles/ruby/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/ruby/molecule/centos-6/molecule.yml b/roles/ruby/molecule/centos-6/molecule.yml deleted file mode 100644 index abcf71c..0000000 --- a/roles/ruby/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/ruby/molecule/centos-latest/molecule.yml b/roles/ruby/molecule/centos-latest/molecule.yml deleted file mode 100644 index 3f22b38..0000000 --- a/roles/ruby/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/ruby/molecule/debian-stable/molecule.yml b/roles/ruby/molecule/debian-stable/molecule.yml deleted file mode 100644 index cd01cc1..0000000 --- a/roles/ruby/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/ruby/molecule/debian-unstable/molecule.yml b/roles/ruby/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 9af1258..0000000 --- a/roles/ruby/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/ruby/molecule/default/molecule.yml b/roles/ruby/molecule/default/molecule.yml index 5a6da07..d8e1763 100644 --- a/roles/ruby/molecule/default/molecule.yml +++ b/roles/ruby/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: ruby-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: ruby-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: ruby-archlinux - image: archlinux/base - pre_build_image: yes - - name: ruby-centos-6 - image: centos:6 - pre_build_image: yes - - name: ruby-centos-latest - image: centos:latest - pre_build_image: yes - - name: ruby-debian-stable - image: debian:stable - pre_build_image: yes - - name: ruby-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: ruby-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: ruby-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: ruby-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: ruby-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: ruby-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: ruby-ubuntu-devel - image: ubuntu:devel + - name: "ruby-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ruby-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - ruby-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/ruby/molecule/resources/playbook.yml b/roles/ruby/molecule/default/playbook.yml similarity index 100% rename from roles/ruby/molecule/resources/playbook.yml rename to roles/ruby/molecule/default/playbook.yml diff --git a/roles/postfix/molecule/resources/prepare.yml b/roles/ruby/molecule/default/prepare.yml similarity index 100% rename from roles/postfix/molecule/resources/prepare.yml rename to roles/ruby/molecule/default/prepare.yml diff --git a/roles/ruby/molecule/ec2/README.md b/roles/ruby/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/ruby/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/ruby/molecule/ec2/create.yml b/roles/ruby/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/ruby/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/ruby/molecule/ec2/destroy.yml b/roles/ruby/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/ruby/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/ruby/molecule/ec2/molecule.yml b/roles/ruby/molecule/ec2/molecule.yml deleted file mode 100644 index 9ec37a1..0000000 --- a/roles/ruby/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: ruby-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ruby-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ruby-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ruby-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ruby-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: ruby-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ruby-ubuntu-18.04: - ansible_user: ubuntu - ruby-centos-7: - ansible_user: centos - ruby-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/ruby/molecule/fedora-latest/molecule.yml b/roles/ruby/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 95295d3..0000000 --- a/roles/ruby/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/ruby/molecule/fedora-rawhide/molecule.yml b/roles/ruby/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 706fb85..0000000 --- a/roles/ruby/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/ruby/molecule/opensuse-leap/molecule.yml b/roles/ruby/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index da5f4c6..0000000 --- a/roles/ruby/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/ruby/molecule/ubuntu-devel/molecule.yml b/roles/ruby/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 4537b96..0000000 --- a/roles/ruby/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/ruby/molecule/ubuntu-latest/molecule.yml b/roles/ruby/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index a2d05b0..0000000 --- a/roles/ruby/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/ruby/molecule/ubuntu-rolling/molecule.yml b/roles/ruby/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index f20a89f..0000000 --- a/roles/ruby/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: ruby-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/ruby/molecule/vagrant/INSTALL.rst b/roles/ruby/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/ruby/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/ruby/molecule/vagrant/molecule.yml b/roles/ruby/molecule/vagrant/molecule.yml deleted file mode 100644 index 5cbb095..0000000 --- a/roles/ruby/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: ruby-debian - box: debian/stretch64 - - name: ruby-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - ruby-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/ruby/tox.ini b/roles/ruby/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/ruby/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/ruby/vars/main.yml b/roles/ruby/vars/main.yml index d2aa5a7..8245009 100644 --- a/roles/ruby/vars/main.yml +++ b/roles/ruby/vars/main.yml @@ -1,10 +1,4 @@ --- # vars file for ruby -_ruby_packages: - default: - - ruby - CentOS-6: - - ruby - - rubygems - -ruby_packages: "{{ _ruby_packages[ansible_distribution] | default(_ruby_packages['default']) }}" +ruby_packages: + - ruby diff --git a/roles/service/.ansible-lint b/roles/service/.ansible-lint new file mode 100644 index 0000000..788f1ce --- /dev/null +++ b/roles/service/.ansible-lint @@ -0,0 +1,3 @@ +# +# Ansible managed +# diff --git a/roles/service/.github/ISSUE_TEMPLATE/bug_report.md b/roles/service/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/service/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/service/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/service/.github/settings.yml b/roles/service/.github/settings.yml index a3342dd..8bb3037 100644 --- a/roles/service/.github/settings.yml +++ b/roles/service/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Add custom services to your Linux system. homepage: https://robertdebock.nl/ diff --git a/roles/service/.gitignore b/roles/service/.gitignore index 47cf7b9..982db11 100644 --- a/roles/service/.gitignore +++ b/roles/service/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log -*.swp \ No newline at end of file +*.swp +.tox diff --git a/roles/service/.travis.yml b/roles/service/.travis.yml index 69cadd0..2b8226e 100644 --- a/roles/service/.travis.yml +++ b/roles/service/.travis.yml @@ -1,89 +1,53 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.6,<2.7" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.6,<2.7" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.6,<2.7" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.6,<2.7" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.6,<2.7" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.6,<2.7" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.6,<2.7" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.6,<2.7" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.6,<2.7" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.6,<2.7" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.6,<2.7" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.6,<2.7" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.6,<2.7" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="redhat" tag="7" + - image="centos" + - image="redhat" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.6,<2.7" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.6,<2.7" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.6,<2.7" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.6,<2.7" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ slack: secure: "qaGtGqE0v0I1bzGWPPW2lLOesDQQ4g4l0fW3I7iJMf3f1YASWi3QXN/0H6i3lcO3VGok+k2yGXlZyG6dwMUPkz0jCv8iFsbKCiNnewVBbMX2L/gGhinl5n6rzw/Udkg/k+/CKZ7k+Bem/JDSgmIGVAyxzdmkRK0RxuhCurFQnlEUSEDNFekIKybuTccja6zbsuyX/gWZjEDxRdODpBPAslTFJSK/V5BOz49RGpka3kOvwt8PmoJZVkZwVMLcRzvyQORN3aUylivtl5kjxehA8dMLPgZTGd9g4oagDRsk5y9yFmUeV3XVYTBEec0QvCzsJ54M5D133ButcXutFfzlsIr5bpcizD46eRS9L6dmRuB9Xi9l5tVPponlJPG1kVJTJA8TsbDHWC4Dn3M8tOPNxGovy0c2V6Y0O2T6fG4PxmuBPAecrnxZg+pmWoZcR5KuaqHFdGhef+gKuM2r6JrBwPyytt0zz74/o+kiWp7koiRh2S5DIR6d65LKOf9j688AGitJJWsDqgcvNYZcWUsghtOVLbGd4KGq1PscJsAQGUW5yXtrbyUhu3pSDr/EmWH9JA69J9J1JdcczgZfX9lW7uNUVLWo53on2I64snOxlkXi/lWje2DujqE6tVYGsrHFq9eVw1s8aaIwVs2t0GgdJQJqgDhnbNFjio9CbFcHKy8=" - email: false diff --git a/roles/service/CONTRIBUTING.md b/roles/service/CONTRIBUTING.md index 3209430..84134c7 100644 --- a/roles/service/CONTRIBUTING.md +++ b/roles/service/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/service/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/service), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/service.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/service/README.md b/roles/service/README.md index 66a7b4a..3291894 100644 --- a/roles/service/README.md +++ b/roles/service/README.md @@ -2,14 +2,14 @@ service ========= Ansible logo -Build status + Build status Add custom services to your Linux system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -18,37 +18,43 @@ This example is taken from `molecule/resources/playbook.yml`: gather_facts: yes vars: + _service_test_command: + default: /usr/bin/sleep + Alpine: /bin/sleep + + service_test_command: "{{ _service_test_command[ansible_os_family] | default(_service_test_command['default']) }}" + service_list: - name: simple-service description: Simple Service - start_command: /usr/bin/sleep 3600 + start_command: "{{ service_test_command }} 3600" - name: forking-service description: Forking Service type: forking - start_command: "/usr/bin/sleep 7200 &" + start_command: "{{ service_test_command }} 7200 &" - name: specific-stop-service description: Specific Stop Service - start_command: /usr/bin/sleep 14400 + start_command: "{{ service_test_command }} 1440" stop_command: killall -f "sleep 1440" - name: specific-user-group-service description: Specific User Group Service - start_command: /usr/bin/sleep 28800 + start_command: "{{ service_test_command }} 28800" user_name: root group_name: root - name: specific-workingdirectory-service description: Specific WorkingDirectory Service - start_command: /usr/bin/sleep 57600 + start_command: "{{ service_test_command }} 57600" working_directory: /tmp - name: specific-pattern-service description: Specific Status Pattern Service - start_command: /usr/bin/sleep 115200 + start_command: "{{ service_test_command }} 115200" status_pattern: 115200 roles: - robertdebock.service ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -61,6 +67,36 @@ The machine you are running this on, may need to be prepared. - role: robertdebock.bootstrap ``` +After running this role, this playbook runs to verify that everything works, this may be a good example how you can use this role. +```yaml +--- +- name: Verify + hosts: all + become: yes + gather_facts: yes + + vars: + service_list: + - name: simple-service + + tasks: + - name: start simple-service + service: + name: simple-service + state: started + + - name: stop simple-service + service: + name: simple-service + state: stopped + + - name: restart simple-service + service: + name: simple-service + state: restarted + +``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -115,42 +151,80 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): + +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|1|no| +|amazonlinux|latest|no| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|redhat|7|no| +|centos|latest|no| +|redhat|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|no|yes|yes*| -|alpine-latest|no|yes|yes*| -|archlinux|no|yes|yes*| -|centos-6|no|yes|yes*| -|centos-latest|no|yes|yes*| -|debian-stable|no|yes|yes*| -|debian-unstable*|no|yes|yes*| -|fedora-latest|no|yes|yes*| -|fedora-rawhide*|no|yes|yes*| -|opensuse-leap|no|yes|yes*| -|ubuntu-devel*|no|yes|yes*| -|ubuntu-latest|no|yes|yes*| -|ubuntu-rolling|no|yes|yes*| -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-service) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-service) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-service/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- meta +- package +- setup +- systemd +- template +``` License ------- diff --git a/roles/service/handlers/main.yml b/roles/service/handlers/main.yml index cde6f5d..ff6e15b 100644 --- a/roles/service/handlers/main.yml +++ b/roles/service/handlers/main.yml @@ -3,16 +3,3 @@ - name: systemctl daemon-reload systemd: daemon_reload: yes - when: - - ansible_virtualization_type != "docker" - -- name: restart service - service: - name: "{{ item.name }}" - state: restarted - with_items: - - "{{ service_list }}" - when: - - ansible_virtualization_type != "docker" - loop_control: - label: "{{ item.name }}" diff --git a/roles/service/meta/.galaxy_install_info b/roles/service/meta/.galaxy_install_info index cc71be2..b076268 100644 --- a/roles/service/meta/.galaxy_install_info +++ b/roles/service/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:22:00 2019', version: 2.0.8} +install_date: Mon Dec 16 06:45:49 2019 +version: 2.2.8 diff --git a/roles/service/meta/main.yml b/roles/service/meta/main.yml index d9a1e4d..0de41e9 100644 --- a/roles/service/meta/main.yml +++ b/roles/service/meta/main.yml @@ -5,22 +5,25 @@ galaxy_info: description: Add custom services to your Linux system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -34,14 +37,8 @@ galaxy_info: galaxy_tags: - service - - alpine - archlinux - centos - - debian - - el - - fedora - - opensuse - - rhel - - ubuntu + - redhat dependencies: [] diff --git a/roles/service/molecule/alpine-edge/molecule.yml b/roles/service/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 2899539..0000000 --- a/roles/service/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/service/molecule/alpine-latest/molecule.yml b/roles/service/molecule/alpine-latest/molecule.yml deleted file mode 100644 index f703e56..0000000 --- a/roles/service/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/service/molecule/archlinux/molecule.yml b/roles/service/molecule/archlinux/molecule.yml deleted file mode 100644 index dd8fe46..0000000 --- a/roles/service/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/service/molecule/centos-6/molecule.yml b/roles/service/molecule/centos-6/molecule.yml deleted file mode 100644 index 75a7365..0000000 --- a/roles/service/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/service/molecule/centos-latest/molecule.yml b/roles/service/molecule/centos-latest/molecule.yml deleted file mode 100644 index b29f437..0000000 --- a/roles/service/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/service/molecule/debian-stable/molecule.yml b/roles/service/molecule/debian-stable/molecule.yml deleted file mode 100644 index 03d3613..0000000 --- a/roles/service/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/service/molecule/debian-unstable/molecule.yml b/roles/service/molecule/debian-unstable/molecule.yml deleted file mode 100644 index e264aaf..0000000 --- a/roles/service/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/service/molecule/default/molecule.yml b/roles/service/molecule/default/molecule.yml index 59761c5..6452ba1 100644 --- a/roles/service/molecule/default/molecule.yml +++ b/roles/service/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,19 @@ lint: driver: name: docker platforms: - - name: service-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: service-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: service-archlinux - image: archlinux/base - pre_build_image: yes - - name: service-centos-6 - image: centos:6 - pre_build_image: yes - - name: service-centos-latest - image: centos:latest - pre_build_image: yes - - name: service-debian-stable - image: debian:stable - pre_build_image: yes - - name: service-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: service-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: service-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: service-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: service-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: service-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: service-ubuntu-devel - image: ubuntu:devel + - name: "service-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml +verifier: + name: ansible lint: name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - service-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - service-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 + enabled: no scenario: name: default diff --git a/roles/service/molecule/resources/playbook.yml b/roles/service/molecule/default/playbook.yml similarity index 59% rename from roles/service/molecule/resources/playbook.yml rename to roles/service/molecule/default/playbook.yml index d938f2a..ed1ad03 100644 --- a/roles/service/molecule/resources/playbook.yml +++ b/roles/service/molecule/default/playbook.yml @@ -5,30 +5,36 @@ gather_facts: yes vars: + _service_test_command: + default: /usr/bin/sleep + Alpine: /bin/sleep + + service_test_command: "{{ _service_test_command[ansible_os_family] | default(_service_test_command['default']) }}" + service_list: - name: simple-service description: Simple Service - start_command: /usr/bin/sleep 3600 + start_command: "{{ service_test_command }} 3600" - name: forking-service description: Forking Service type: forking - start_command: "/usr/bin/sleep 7200 &" + start_command: "{{ service_test_command }} 7200 &" - name: specific-stop-service description: Specific Stop Service - start_command: /usr/bin/sleep 14400 + start_command: "{{ service_test_command }} 1440" stop_command: killall -f "sleep 1440" - name: specific-user-group-service description: Specific User Group Service - start_command: /usr/bin/sleep 28800 + start_command: "{{ service_test_command }} 28800" user_name: root group_name: root - name: specific-workingdirectory-service description: Specific WorkingDirectory Service - start_command: /usr/bin/sleep 57600 + start_command: "{{ service_test_command }} 57600" working_directory: /tmp - name: specific-pattern-service description: Specific Status Pattern Service - start_command: /usr/bin/sleep 115200 + start_command: "{{ service_test_command }} 115200" status_pattern: 115200 roles: diff --git a/roles/service/molecule/resources/prepare.yml b/roles/service/molecule/default/prepare.yml similarity index 100% rename from roles/service/molecule/resources/prepare.yml rename to roles/service/molecule/default/prepare.yml diff --git a/roles/service/molecule/default/verify.yml b/roles/service/molecule/default/verify.yml new file mode 100644 index 0000000..b18ac4d --- /dev/null +++ b/roles/service/molecule/default/verify.yml @@ -0,0 +1,25 @@ +--- +- name: Verify + hosts: all + become: yes + gather_facts: yes + + vars: + service_list: + - name: simple-service + + tasks: + - name: start simple-service + service: + name: simple-service + state: started + + - name: stop simple-service + service: + name: simple-service + state: stopped + + - name: restart simple-service + service: + name: simple-service + state: restarted diff --git a/roles/service/molecule/ec2/README.md b/roles/service/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/service/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/service/molecule/ec2/create.yml b/roles/service/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/service/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/service/molecule/ec2/destroy.yml b/roles/service/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/service/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/service/molecule/ec2/molecule.yml b/roles/service/molecule/ec2/molecule.yml deleted file mode 100644 index 54d537f..0000000 --- a/roles/service/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: service-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: service-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: service-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: service-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: service-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: service-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - service-ubuntu-18.04: - ansible_user: ubuntu - service-centos-7: - ansible_user: centos - service-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/service/molecule/fedora-latest/molecule.yml b/roles/service/molecule/fedora-latest/molecule.yml deleted file mode 100644 index e9367cf..0000000 --- a/roles/service/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/service/molecule/fedora-rawhide/molecule.yml b/roles/service/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 3eb0f4e..0000000 --- a/roles/service/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/service/molecule/opensuse-leap/molecule.yml b/roles/service/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 77a74ab..0000000 --- a/roles/service/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/service/molecule/ubuntu-devel/molecule.yml b/roles/service/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 992d847..0000000 --- a/roles/service/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/service/molecule/ubuntu-latest/molecule.yml b/roles/service/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index a2aed7a..0000000 --- a/roles/service/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/service/molecule/ubuntu-rolling/molecule.yml b/roles/service/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index c644577..0000000 --- a/roles/service/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: service-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/service/molecule/vagrant/molecule.yml b/roles/service/molecule/vagrant/molecule.yml deleted file mode 100644 index 30c43ff..0000000 --- a/roles/service/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: service-debian - box: debian/stretch64 - - name: service-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - service-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/service/tasks/main.yml b/roles/service/tasks/main.yml index 3d47452..1503a14 100644 --- a/roles/service/tasks/main.yml +++ b/roles/service/tasks/main.yml @@ -35,8 +35,6 @@ ansible_service_mgr == "openrc" with_items: - "{{ service_list }}" - notify: - - restart service loop_control: label: "{{ item.name }}" diff --git a/roles/service/templates/sysvinit.j2 b/roles/service/templates/sysvinit.j2 index 8ce37b7..c00e9f0 100644 --- a/roles/service/templates/sysvinit.j2 +++ b/roles/service/templates/sysvinit.j2 @@ -4,7 +4,6 @@ # /etc/init.d/{{ item.name }} # # {{ item.description }} -# As simple as possible, using Apache Tomcat's daemon.sh mostly. # # chkconfig: 2345 20 80 # description: {{ item.name }} @@ -15,41 +14,61 @@ if [ -f /etc/init.d/functions ] ; then fi start() { - echo -n "Starting {{ item.name }}: " -{% if item.working_directory is defined %} - cd {{ item.working_directory }} -{% endif %} -{% if item.type is defined and item.type != "simple" %} - # Start the program in the foreground, when finished, continue. - {% if item.user_name is defined %}su - {{ item.user_name ~ ' ' }}{% endif %}{{ item.start_command }} +{% if item.status_pattern is defined %} + pgrep -f {{ item.status_pattern }} > /dev/null {% else %} - # Start the program in the background and continue. - ({% if item.user_name is defined %}su - {{ item.user_name ~ ' ' }}{% endif %}{{ item.start_command }} &) + pgrep -f {{ item.start_command | regex_replace(' .*') }} > /dev/null {% endif %} returncode="${?}" - touch /var/lock/subsys/{{ item.name }} - return ${returncode} + if [ $returncode -gt 0 ] ; then + echo -n "Starting {{ item.name }}: " +{% if item.working_directory is defined %} + cd {{ item.working_directory }} +{% endif %} +{% if item.type is defined and item.type != "simple" %} + {% if item.user_name is defined %}su - {{ item.user_name ~ ' ' }}{% endif %}{{ item.start_command }} +{% else %} + ({% if item.user_name is defined %}su - {{ item.user_name ~ ' ' }}{% endif %}{{ item.start_command }} &) +{% endif %} + returncode="${?}" + touch /var/lock/subsys/{{ item.name }} + else + echo "Already running." + fi } stop() { - echo -n "Shutting down {{ item.name }}: " - {{ item.stop_command | default('killall -f {{ item.start_command.split[0] }}') }} +{% if item.status_pattern is defined %} + pgrep -f {{ item.status_pattern }} > /dev/null +{% else %} + pgrep -f {{ item.start_command | regex_replace(' .*') }} > /dev/null +{% endif %} returncode="${?}" - rm -f /var/lock/subsys/{{ item.name }} - return ${returncode} + if [ $returncode -eq 0 ] ; then + echo -n "Shutting down {{ item.name }}: " +{% if item.stop_command is defined %} + {{ item.stop_command }} +{% else %} + pkill -f {{ item.start_command | regex_replace(' .*') }} +{% endif %} + returncode="${?}" + rm -f /var/lock/subsys/{{ item.name }} + else + echo "Already stopped." + fi } status() { {% if item.status_pattern is defined %} - pgrep -f {{ item.status_pattern }} > /dev/null 2>&1 + pgrep -f {{ item.status_pattern }} > /dev/null {% else %} - echo "Not implemented." ; exit 1 + pgrep -f {{ item.start_command | regex_replace(' .*') }} > /dev/null {% endif %} returncode="${?}" if [ $returncode -gt 0 ] ; then - echo "{{ item.name }} is not running." + echo "{{ item.name }} is not running." ; exit ${returncode} else - echo "{{ item.name }} is running." + echo "{{ item.name }} is running." ; exit ${returncode} fi return ${returncode} } @@ -64,7 +83,7 @@ case "$1" in status) status ;; - restart) + restart|force-reload) stop start ;; diff --git a/roles/service/tox.ini b/roles/service/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/service/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/service/vars/main.yml b/roles/service/vars/main.yml index b11f2f1..beee86f 100644 --- a/roles/service/vars/main.yml +++ b/roles/service/vars/main.yml @@ -6,11 +6,9 @@ _service_required_packages: - psmisc Debian: - psmisc - Fedora: + RedHat: - psmisc - openSUSE Leap: - - psmisc - Ubuntu: + Suse: - psmisc -service_required_packages: "{{ _service_required_packages[ansible_distribution] | default(_service_required_packages['default']) }}" +service_required_packages: "{{ _service_required_packages[ansible_os_family] | default(_service_required_packages['default']) }}" diff --git a/roles/travis/.ansible-lint b/roles/travis/.ansible-lint new file mode 100644 index 0000000..f2934a8 --- /dev/null +++ b/roles/travis/.ansible-lint @@ -0,0 +1,4 @@ +exclude_paths: + - ./meta/version.yml + - ./meta/exception.yml + - ./meta/preferences.yml diff --git a/roles/travis/.github/ISSUE_TEMPLATE/bug_report.md b/roles/travis/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/travis/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/travis/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/travis/.gitignore b/roles/travis/.gitignore index 47cf7b9..982db11 100644 --- a/roles/travis/.gitignore +++ b/roles/travis/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log -*.swp \ No newline at end of file +*.swp +.tox diff --git a/roles/travis/.travis.yml b/roles/travis/.travis.yml index f315ef8..01efc7c 100644 --- a/roles/travis/.travis.yml +++ b/roles/travis/.travis.yml @@ -1,85 +1,41 @@ --- -sudo: required language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" expectation="fail" - - version="" distro="centos-6" expectation="fail" - - version="devel" distro="centos-6" expectation="fail" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" expectation="fail" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/travis/README.md b/roles/travis/README.md index a090b89..56702eb 100644 --- a/roles/travis/README.md +++ b/roles/travis/README.md @@ -2,14 +2,14 @@ travis ========= Ansible logo -Build status + Build status Installs travis on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.travis ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -35,6 +35,7 @@ The machine you are running this on, may need to be prepared. - role: robertdebock.ruby ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -74,42 +75,81 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|no|no|no*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|1|no| +|amazonlinux|latest|no| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|latest|no| +|opensuse|latest|no| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| CentOS 7 | Dependency faraday requires Ruby version >= 2.3 | +| Fedora | extconf failed, exit code 1 | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-travis) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-travis) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-travis/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- gem +- package +``` License ------- diff --git a/roles/travis/meta/.galaxy_install_info b/roles/travis/meta/.galaxy_install_info index ca7ecaa..226fe81 100644 --- a/roles/travis/meta/.galaxy_install_info +++ b/roles/travis/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:22:03 2019', version: 2.0.5} +install_date: Mon Dec 16 06:45:52 2019 +version: 2.1.2 diff --git a/roles/travis/meta/exception.yml b/roles/travis/meta/exception.yml new file mode 100644 index 0000000..66d9e65 --- /dev/null +++ b/roles/travis/meta/exception.yml @@ -0,0 +1,6 @@ +--- +exceptions: + - variation: CentOS 7 + reason: "Dependency faraday requires Ruby version >= 2.3" + - variation: Fedora + reason: "extconf failed, exit code 1" diff --git a/roles/travis/meta/main.yml b/roles/travis/meta/main.yml index 95c2420..9896cf1 100644 --- a/roles/travis/meta/main.yml +++ b/roles/travis/meta/main.yml @@ -5,21 +5,24 @@ galaxy_info: description: Installs travis on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 7 + versions: + - 8 - name: OpenSUSE versions: - all @@ -30,14 +33,8 @@ galaxy_info: galaxy_tags: - travis - - alpine - archlinux - centos - - debian - - el - - fedora - - opensuse - rhel - - ubuntu dependencies: [] diff --git a/roles/travis/molecule.yml b/roles/travis/molecule.yml new file mode 100644 index 0000000..496cae0 --- /dev/null +++ b/roles/travis/molecule.yml @@ -0,0 +1,21 @@ +--- +dependency: + name: galaxy + options: + role-file: requirements.yml +lint: + name: yamllint +driver: + name: docker +platforms: + - name: "travis-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes +provisioner: + name: ansible +scenario: + name: default diff --git a/roles/travis/molecule/alpine-edge/molecule.yml b/roles/travis/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 8d4b17d..0000000 --- a/roles/travis/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/travis/molecule/alpine-latest/molecule.yml b/roles/travis/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 4cd78e6..0000000 --- a/roles/travis/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/travis/molecule/archlinux/molecule.yml b/roles/travis/molecule/archlinux/molecule.yml deleted file mode 100644 index f625787..0000000 --- a/roles/travis/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/travis/molecule/centos-6/molecule.yml b/roles/travis/molecule/centos-6/molecule.yml deleted file mode 100644 index a8694d6..0000000 --- a/roles/travis/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/travis/molecule/centos-latest/molecule.yml b/roles/travis/molecule/centos-latest/molecule.yml deleted file mode 100644 index d55b0ee..0000000 --- a/roles/travis/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/travis/molecule/debian-stable/molecule.yml b/roles/travis/molecule/debian-stable/molecule.yml deleted file mode 100644 index f596cb0..0000000 --- a/roles/travis/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/travis/molecule/debian-unstable/molecule.yml b/roles/travis/molecule/debian-unstable/molecule.yml deleted file mode 100644 index fdd36a4..0000000 --- a/roles/travis/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/travis/molecule/default/molecule.yml b/roles/travis/molecule/default/molecule.yml index 7a6f532..496cae0 100644 --- a/roles/travis/molecule/default/molecule.yml +++ b/roles/travis/molecule/default/molecule.yml @@ -8,63 +8,14 @@ lint: driver: name: docker platforms: - - name: travis-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: travis-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: travis-archlinux - image: archlinux/base - pre_build_image: yes - - name: travis-centos-6 - image: centos:6 - pre_build_image: yes - - name: travis-centos-latest - image: centos:latest - pre_build_image: yes - - name: travis-debian-stable - image: debian:stable - pre_build_image: yes - - name: travis-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: travis-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: travis-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: travis-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: travis-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: travis-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: travis-ubuntu-devel - image: ubuntu:devel + - name: "travis-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - travis-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - travis-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/travis/molecule/resources/playbook.yml b/roles/travis/molecule/default/playbook.yml similarity index 100% rename from roles/travis/molecule/resources/playbook.yml rename to roles/travis/molecule/default/playbook.yml diff --git a/roles/travis/molecule/resources/prepare.yml b/roles/travis/molecule/default/prepare.yml similarity index 100% rename from roles/travis/molecule/resources/prepare.yml rename to roles/travis/molecule/default/prepare.yml diff --git a/roles/travis/molecule/ec2/README.md b/roles/travis/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/travis/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/travis/molecule/ec2/create.yml b/roles/travis/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/travis/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/travis/molecule/ec2/destroy.yml b/roles/travis/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/travis/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/travis/molecule/ec2/molecule.yml b/roles/travis/molecule/ec2/molecule.yml deleted file mode 100644 index e16cd8d..0000000 --- a/roles/travis/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: travis-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: travis-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: travis-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: travis-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: travis-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: travis-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - travis-ubuntu-18.04: - ansible_user: ubuntu - travis-centos-7: - ansible_user: centos - travis-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/travis/molecule/fedora-latest/molecule.yml b/roles/travis/molecule/fedora-latest/molecule.yml deleted file mode 100644 index d6572cc..0000000 --- a/roles/travis/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/travis/molecule/fedora-rawhide/molecule.yml b/roles/travis/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index e750d33..0000000 --- a/roles/travis/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/travis/molecule/opensuse-leap/molecule.yml b/roles/travis/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 64cd882..0000000 --- a/roles/travis/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/travis/molecule/ubuntu-devel/molecule.yml b/roles/travis/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 11b4677..0000000 --- a/roles/travis/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/travis/molecule/ubuntu-latest/molecule.yml b/roles/travis/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 9eb7b06..0000000 --- a/roles/travis/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/travis/molecule/ubuntu-rolling/molecule.yml b/roles/travis/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 8952eac..0000000 --- a/roles/travis/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: travis-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/travis/molecule/vagrant/molecule.yml b/roles/travis/molecule/vagrant/molecule.yml deleted file mode 100644 index c6f4502..0000000 --- a/roles/travis/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: travis-debian - box: debian/stretch64 - - name: travis-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - travis-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/travis/tasks/main.yml b/roles/travis/tasks/main.yml index 8fb3da6..25971e4 100644 --- a/roles/travis/tasks/main.yml +++ b/roles/travis/tasks/main.yml @@ -1,9 +1,5 @@ --- # tasks file for travis -- name: test veriables and environment - assert: - that: - - name: install requirements package: name: "{{ travis_requirements }}" diff --git a/roles/travis/tox.ini b/roles/travis/tox.ini new file mode 100644 index 0000000..f1cb9a1 --- /dev/null +++ b/roles/travis/tox.ini @@ -0,0 +1,19 @@ +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/travis/vars/main.yml b/roles/travis/vars/main.yml index 0539af3..2c4b8bb 100644 --- a/roles/travis/vars/main.yml +++ b/roles/travis/vars/main.yml @@ -6,17 +6,13 @@ _travis_requirements: - ruby-dev Archlinux: - bash - CentOS: - - ruby-devel Debian: - ruby-dev - Fedora: + RedHat: - ruby-devel - openSUSE Leap: + Suse: - ruby-devel - Ubuntu: - - ruby-dev -travis_requirements: "{{ _travis_requirements[ansible_distribution] | default(_travis_requirements['default']) }}" +travis_requirements: "{{ _travis_requirements[ansible_os_family] | default(_travis_requirements['default']) }}" travis_package: travis diff --git a/roles/update/.ansible-lint b/roles/update/.ansible-lint new file mode 100644 index 0000000..5f770c6 --- /dev/null +++ b/roles/update/.ansible-lint @@ -0,0 +1,5 @@ +# +# Ansible managed +# +exclude_paths: + - ./meta/exception.yml diff --git a/roles/update/.github/ISSUE_TEMPLATE/bug_report.md b/roles/update/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/update/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/update/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/update/.github/settings.yml b/roles/update/.github/settings.yml index c8078bf..823f25d 100644 --- a/roles/update/.github/settings.yml +++ b/roles/update/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: Install updates on your system. homepage: https://robertdebock.nl/ diff --git a/roles/update/.gitignore b/roles/update/.gitignore index 10b26d1..982db11 100644 --- a/roles/update/.gitignore +++ b/roles/update/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log *.swp +.tox diff --git a/roles/update/.travis.yml b/roles/update/.travis.yml index 750e57b..76ac3b6 100644 --- a/roles/update/.travis.yml +++ b/roles/update/.travis.yml @@ -1,85 +1,50 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" expectation="fail" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="redhat" tag="7" + - image="centos" + - image="redhat" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/update/CONTRIBUTING.md b/roles/update/CONTRIBUTING.md index 3209430..503b463 100644 --- a/roles/update/CONTRIBUTING.md +++ b/roles/update/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/update/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/update), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/update.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/update/README.md b/roles/update/README.md index da75188..70996ad 100644 --- a/roles/update/README.md +++ b/roles/update/README.md @@ -2,14 +2,14 @@ update ========= Ansible logo -Build status + Build status Install updates on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.update ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -33,6 +33,7 @@ The machine you are running this on, may need to be prepared. - robertdebock.bootstrap ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -85,25 +86,30 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|no|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|amazonlinux|1|no| +|amazonlinux|latest|no| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|redhat|7|no| +|centos|latest|no| +|redhat|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| -A single star means the build may fail, it's marked as an experimental build. +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel Exceptions ---------- @@ -115,23 +121,56 @@ Some variarations of the build matrix do not work. These are the variations and | Archlinux & Ansible 2.7 | New-style module did not handle its own exit | - Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-update) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-update) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-update/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- apk +- apt +- dnf +- include_role +- package +- pacman +- yum +- zypper +``` License ------- diff --git a/roles/update/handlers/main.yml b/roles/update/handlers/main.yml deleted file mode 100644 index c80863f..0000000 --- a/roles/update/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# handlers file for update diff --git a/roles/update/meta/.galaxy_install_info b/roles/update/meta/.galaxy_install_info index ad17645..7e71854 100644 --- a/roles/update/meta/.galaxy_install_info +++ b/roles/update/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:22:06 2019', version: 2.0.6} +install_date: Mon Dec 16 06:45:57 2019 +version: 2.1.1 diff --git a/roles/update/meta/main.yml b/roles/update/meta/main.yml index be83619..be817ab 100644 --- a/roles/update/meta/main.yml +++ b/roles/update/meta/main.yml @@ -5,22 +5,25 @@ galaxy_info: description: Install updates on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -34,12 +37,8 @@ galaxy_info: galaxy_tags: - update - - alpine - centos - - debian - - fedora - - rhel - - ubuntu + - redhat dependencies: - robertdebock.reboot diff --git a/roles/update/molecule/alpine-edge/molecule.yml b/roles/update/molecule/alpine-edge/molecule.yml deleted file mode 100644 index fc53e6d..0000000 --- a/roles/update/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/update/molecule/alpine-latest/molecule.yml b/roles/update/molecule/alpine-latest/molecule.yml deleted file mode 100644 index aab0d11..0000000 --- a/roles/update/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/update/molecule/archlinux/molecule.yml b/roles/update/molecule/archlinux/molecule.yml deleted file mode 100644 index 5189be7..0000000 --- a/roles/update/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/update/molecule/centos-6/molecule.yml b/roles/update/molecule/centos-6/molecule.yml deleted file mode 100644 index 069492e..0000000 --- a/roles/update/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/update/molecule/centos-latest/molecule.yml b/roles/update/molecule/centos-latest/molecule.yml deleted file mode 100644 index 060b359..0000000 --- a/roles/update/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/update/molecule/debian-stable/molecule.yml b/roles/update/molecule/debian-stable/molecule.yml deleted file mode 100644 index dba5fe1..0000000 --- a/roles/update/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/update/molecule/debian-unstable/molecule.yml b/roles/update/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 63a1d4f..0000000 --- a/roles/update/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/update/molecule/default/molecule.yml b/roles/update/molecule/default/molecule.yml index 88d3bad..2b62ffa 100644 --- a/roles/update/molecule/default/molecule.yml +++ b/roles/update/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: update-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: update-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: update-archlinux - image: archlinux/base - pre_build_image: yes - - name: update-centos-6 - image: centos:6 - pre_build_image: yes - - name: update-centos-latest - image: centos:latest - pre_build_image: yes - - name: update-debian-stable - image: debian:stable - pre_build_image: yes - - name: update-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: update-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: update-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: update-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: update-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: update-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: update-ubuntu-devel - image: ubuntu:devel + - name: "update-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - update-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - update-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/update/molecule/resources/playbook.yml b/roles/update/molecule/default/playbook.yml similarity index 100% rename from roles/update/molecule/resources/playbook.yml rename to roles/update/molecule/default/playbook.yml diff --git a/roles/ruby/molecule/resources/prepare.yml b/roles/update/molecule/default/prepare.yml similarity index 100% rename from roles/ruby/molecule/resources/prepare.yml rename to roles/update/molecule/default/prepare.yml diff --git a/roles/update/molecule/ec2/README.md b/roles/update/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/update/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/update/molecule/ec2/create.yml b/roles/update/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/update/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/update/molecule/ec2/destroy.yml b/roles/update/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/update/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/update/molecule/ec2/molecule.yml b/roles/update/molecule/ec2/molecule.yml deleted file mode 100644 index 479946f..0000000 --- a/roles/update/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: update-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: update-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: update-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: update-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: update-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: update-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - update-ubuntu-18.04: - ansible_user: ubuntu - update-centos-7: - ansible_user: centos - update-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/update/molecule/fedora-latest/molecule.yml b/roles/update/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 79d06a2..0000000 --- a/roles/update/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/update/molecule/fedora-rawhide/molecule.yml b/roles/update/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 63ba83e..0000000 --- a/roles/update/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/update/molecule/opensuse-leap/molecule.yml b/roles/update/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index 34edc49..0000000 --- a/roles/update/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/update/molecule/ubuntu-devel/molecule.yml b/roles/update/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 1a89d9c..0000000 --- a/roles/update/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/update/molecule/ubuntu-latest/molecule.yml b/roles/update/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 16e8025..0000000 --- a/roles/update/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/update/molecule/ubuntu-rolling/molecule.yml b/roles/update/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 382ecef..0000000 --- a/roles/update/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: update-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/update/molecule/vagrant/INSTALL.rst b/roles/update/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/update/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/update/molecule/vagrant/molecule.yml b/roles/update/molecule/vagrant/molecule.yml deleted file mode 100644 index 90532da..0000000 --- a/roles/update/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: update-debian - box: debian/stretch64 - - name: update-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - update-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/update/tasks/main.yml b/roles/update/tasks/main.yml index de42100..270d15d 100644 --- a/roles/update/tasks/main.yml +++ b/roles/update/tasks/main.yml @@ -103,7 +103,7 @@ - name: reboot for updates include_role: - name: reboot + name: robertdebock.reboot vars: reboot_message: rebooting for robertdebock/ansible-role-update when: diff --git a/roles/update/tox.ini b/roles/update/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/update/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/users/.ansible-lint b/roles/users/.ansible-lint new file mode 100644 index 0000000..788f1ce --- /dev/null +++ b/roles/users/.ansible-lint @@ -0,0 +1,3 @@ +# +# Ansible managed +# diff --git a/roles/users/.github/ISSUE_TEMPLATE/bug_report.md b/roles/users/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/users/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/users/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/users/.github/settings.yml b/roles/users/.github/settings.yml index 799df93..cd26217 100644 --- a/roles/users/.github/settings.yml +++ b/roles/users/.github/settings.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# repository: description: The purpose of this role is to add users and groups on your system. homepage: https://robertdebock.nl/ diff --git a/roles/users/.gitignore b/roles/users/.gitignore index 55207b5..982db11 100644 --- a/roles/users/.gitignore +++ b/roles/users/.gitignore @@ -1,4 +1,4 @@ -molecule/*/.molecule +.molecule *.log -molecule/*/ssh_keys *.swp +.tox diff --git a/roles/users/.travis.yml b/roles/users/.travis.yml index 332b7a9..dcd63a9 100644 --- a/roles/users/.travis.yml +++ b/roles/users/.travis.yml @@ -1,85 +1,50 @@ --- -sudo: required +# +# Ansible managed +# language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" - - version="" distro="centos-6" - - version="devel" distro="centos-6" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="amazonlinux" tag="1" + - image="amazonlinux" + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="redhat" tag="7" + - image="centos" + - image="redhat" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/users/CONTRIBUTING.md b/roles/users/CONTRIBUTING.md index 3209430..9fedcc7 100644 --- a/roles/users/CONTRIBUTING.md +++ b/roles/users/CONTRIBUTING.md @@ -8,3 +8,67 @@ You can really make a difference by: I'll try to help and take every contribution seriously. It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## Step by step + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### 1. Make an issue. + +When you spot an issue, [create an issue](https://github.com/robertdebock/users/issues). + +Making the issue help me and others to find similar problems in the future. + +### 2. Fork the project. + +On the top right side of [the repository on GitHub](https://github.com/robertdebock/users), click `fork`. This copies everything to your GitHub namespace. + +### 3. Make the changes + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/users.git +``` + +Now you can start to edit on your laptop. + +### 4. Optionally: test your changes + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### 6. Optionally: Regenerate all dynamic content + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### 7. Make a pull request + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### 8. Wait + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. diff --git a/roles/users/README.md b/roles/users/README.md index 3fde25a..2855a8a 100644 --- a/roles/users/README.md +++ b/roles/users/README.md @@ -2,14 +2,14 @@ users ========= Ansible logo -Build status + Build status The purpose of this role is to add users and groups on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -52,12 +52,15 @@ This example is taken from `molecule/resources/playbook.yml`: authorized_keys: - "ssh-rsa ABC1234567" - "ssh-rsa ABC12345678" + - name: passuser + password: "$6$mysecretsalt$qJbapG68nyRab3gxvKWPUcs2g3t0oMHSHMnSKecYNpSi3CuZm.GbBqXO8BE6EI6P1JUefhA0qvD7b5LSh./PU1" + update_password: on_create roles: - robertdebock.users ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -67,8 +70,10 @@ The machine you are running this on, may need to be prepared. roles: - robertdebock.bootstrap + - robertdebock.core_dependencies ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -129,6 +134,7 @@ The following roles can be installed to ensure all requirements are met, using ` ```yaml --- - robertdebock.bootstrap +- robertdebock.core_dependencies ``` @@ -144,42 +150,78 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): + +|container|tags| +|---------|----| +|amazon|all| +|alpine|all| +|archlinux|all| +|debian|all| +|el|7, 8| +|fedora|all| +|opensuse|all| +|ubuntu|artful, bionic| + +The minimum version of Ansible required is 2.8 but tests have been done to: + +- The previous version, on version lower. +- The current version. +- The development version. -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|yes|yes|yes*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-users) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-users) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-users/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- authorized_key +- command +- copy +- file +- group +- include +- shell +- template +- user +``` License ------- diff --git a/roles/users/meta/.galaxy_install_info b/roles/users/meta/.galaxy_install_info index bc5efd5..27e6b79 100644 --- a/roles/users/meta/.galaxy_install_info +++ b/roles/users/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:22:08 2019', version: 3.1.3} +install_date: Mon Dec 16 06:46:02 2019 +version: 3.2.2 diff --git a/roles/users/meta/main.yml b/roles/users/meta/main.yml index c23a9d5..640433b 100644 --- a/roles/users/meta/main.yml +++ b/roles/users/meta/main.yml @@ -5,22 +5,25 @@ galaxy_info: description: The purpose of this role is to add users and groups on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: + - name: Amazon + versions: + - all - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -34,16 +37,10 @@ galaxy_info: galaxy_tags: - users - - alpine - centos - - debian - - el - - fedora - - opensuse - - rhel + - redhat - server - sudo - system - - ubuntu dependencies: [] diff --git a/roles/users/molecule/alpine-edge/molecule.yml b/roles/users/molecule/alpine-edge/molecule.yml deleted file mode 100644 index 8f411b1..0000000 --- a/roles/users/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/users/molecule/alpine-latest/molecule.yml b/roles/users/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 5473933..0000000 --- a/roles/users/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/users/molecule/archlinux/molecule.yml b/roles/users/molecule/archlinux/molecule.yml deleted file mode 100644 index 14aa5b7..0000000 --- a/roles/users/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/users/molecule/centos-6/molecule.yml b/roles/users/molecule/centos-6/molecule.yml deleted file mode 100644 index 368cd17..0000000 --- a/roles/users/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/users/molecule/centos-latest/molecule.yml b/roles/users/molecule/centos-latest/molecule.yml deleted file mode 100644 index 6ea8d0a..0000000 --- a/roles/users/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/users/molecule/debian-stable/molecule.yml b/roles/users/molecule/debian-stable/molecule.yml deleted file mode 100644 index 461a79a..0000000 --- a/roles/users/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/users/molecule/debian-unstable/molecule.yml b/roles/users/molecule/debian-unstable/molecule.yml deleted file mode 100644 index 0a15f37..0000000 --- a/roles/users/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/users/molecule/default/molecule.yml b/roles/users/molecule/default/molecule.yml index 5d6910b..f7cdcd5 100644 --- a/roles/users/molecule/default/molecule.yml +++ b/roles/users/molecule/default/molecule.yml @@ -1,4 +1,7 @@ --- +# +# Ansible managed +# dependency: name: galaxy options: @@ -8,63 +11,14 @@ lint: driver: name: docker platforms: - - name: users-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: users-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: users-archlinux - image: archlinux/base - pre_build_image: yes - - name: users-centos-6 - image: centos:6 - pre_build_image: yes - - name: users-centos-latest - image: centos:latest - pre_build_image: yes - - name: users-debian-stable - image: debian:stable - pre_build_image: yes - - name: users-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: users-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: users-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: users-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: users-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: users-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: users-ubuntu-devel - image: ubuntu:devel + - name: "users-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - users-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - users-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/users/molecule/resources/playbook.yml b/roles/users/molecule/default/playbook.yml similarity index 84% rename from roles/users/molecule/resources/playbook.yml rename to roles/users/molecule/default/playbook.yml index e1ab849..589263b 100644 --- a/roles/users/molecule/resources/playbook.yml +++ b/roles/users/molecule/default/playbook.yml @@ -39,6 +39,9 @@ authorized_keys: - "ssh-rsa ABC1234567" - "ssh-rsa ABC12345678" + - name: passuser + password: "$6$mysecretsalt$qJbapG68nyRab3gxvKWPUcs2g3t0oMHSHMnSKecYNpSi3CuZm.GbBqXO8BE6EI6P1JUefhA0qvD7b5LSh./PU1" + update_password: on_create roles: - ansible-role-users diff --git a/roles/update/molecule/resources/prepare.yml b/roles/users/molecule/default/prepare.yml similarity index 73% rename from roles/update/molecule/resources/prepare.yml rename to roles/users/molecule/default/prepare.yml index 4298ff8..6e172dc 100644 --- a/roles/update/molecule/resources/prepare.yml +++ b/roles/users/molecule/default/prepare.yml @@ -1,8 +1,9 @@ --- - name: Prepare hosts: all - become: yes gather_facts: no + become: yes roles: - robertdebock.bootstrap + - robertdebock.core_dependencies diff --git a/roles/users/molecule/default/ssh_keys/keyuser b/roles/users/molecule/default/ssh_keys/keyuser new file mode 100644 index 0000000..8361b91 --- /dev/null +++ b/roles/users/molecule/default/ssh_keys/keyuser @@ -0,0 +1,28 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn +NhAAAAAwEAAQAAAQEArWszsZw2AZ+8uBeLcgO/LNFiLj5HeRFpo7H4MOtL9MkQplKyQtn0 +noHiH5mLXg6OIJjh45kgqh2wbLOJAkr7gCgfLXgWbjbKMn1lMKHF3vT6AF0xa6ruKRyYN4 +6Llf39jVPCSxuW2vjMvdKWP+A8Pz11YPwu89XfvbtA6GMzEgquw3nSv2mB26GnFgeCY7jU +PuePul1sWdEI5TKF1YbpUPkfeTVo0TXDAoBdzvAbXeOE8ED1xmMSyrYitzvmo9ycCGby9X +J59c4dtFoV8nZ7JacGZ6p2Lagq0wCrNNwb+2vYlOOQ9suAboUcsojMei/x0yoJ3iC2AaFX +zuZB+2XxQQAAA+grVfABK1XwAQAAAAdzc2gtcnNhAAABAQCtazOxnDYBn7y4F4tyA78s0W +IuPkd5EWmjsfgw60v0yRCmUrJC2fSegeIfmYteDo4gmOHjmSCqHbBss4kCSvuAKB8teBZu +NsoyfWUwocXe9PoAXTFrqu4pHJg3jouV/f2NU8JLG5ba+My90pY/4Dw/PXVg/C7z1d+9u0 +DoYzMSCq7DedK/aYHboacWB4JjuNQ+54+6XWxZ0QjlMoXVhulQ+R95NWjRNcMCgF3O8Btd +44TwQPXGYxLKtiK3O+aj3JwIZvL1cnn1zh20WhXydnslpwZnqnYtqCrTAKs03Bv7a9iU45 +D2y4BuhRyyiMx6L/HTKgneILYBoVfO5kH7ZfFBAAAAAwEAAQAAAQAxcgV1OLL1V5Q5cQ0j +XwodPz4dLUi3rk1OjSnU2OH5U3LZ2W5WPUrP/vx4QhFIqiHADZcqi7iSiJCLDc2cx8BZ1B +a/oiPTHPAd4T7+1MFURskZXXj/1+a79hk4jf4isB6hMyaMv7sNiC7oWKjaYZcL+PwEwSKq +B2sZ79Ab8lzXYZfvCWfYBK9ctM2/eNtRFdIIM86tARoqdpi8JK57iERyZiVd3qx6uOVv18 +WfPznp8Lj/MU2GWPwNBkUz/+Js3QJy7m1yOsLBoqCwHaxrqPFWE+vSeEOBBpi/D/UbJb6D +MLA+/rBPaGWhvqHD3OWrhTC/KudelX56GO9p3GQmZOp5AAAAgGyh/zkLUvsXysf0lcukd2 +203PrBxRyj/0oiiskydzRNv+VrojDoWQe8zNN5zV8YsMHuscrhp/lmsC9PsPYB42tfs6eH +TM4sHoKyKuVwD8B8TT3AxFH4f7QToh3MZ5JXCyAS8Qfz6J7XEz6OiqykCWI91TJvMbPuys +NWWWLh1gNOAAAAgQDhruC7DP6mheBUSAHv4zeXasQe33KIAFB6yNFbFQ0N8lltWoJ+lhvh +I5LbhKaHLWXM6dHBfRUeQ0jNlGGKUMZw5GlqeGKZuT7Fi9yjFsfR8FE8NFbJ8SZQmtyJzF +PBgJgY8I+2PuYJV4VOqpuW9rpRKFJ9m+pkMcf0UIC7m8551wAAAIEAxLb7CUPSr0GkItLA +843jUKOBW062u7+cu8bfHfr+FyzUXLaa4VWGAFRnOlnIyDTWyLaIBNyEzg8bwlJ8rG62tz +YP/uc1IG4GlehzabAt8tiYe7iSo4hnhiH9/LRPVpqDQSq9dtfj3JsJgt2OjDq6Qu0nvasP +lqyX2qVxzM78eqcAAAAsR2VuZXJhdGVkIGJ5IEFuc2libGUgcm9sZSByb2JlcnRkZWJvY2 +sudXNlcnMBAgMEBQYH +-----END OPENSSH PRIVATE KEY----- diff --git a/roles/users/molecule/default/ssh_keys/keyuser.ppk b/roles/users/molecule/default/ssh_keys/keyuser.ppk new file mode 100644 index 0000000..37237db --- /dev/null +++ b/roles/users/molecule/default/ssh_keys/keyuser.ppk @@ -0,0 +1,9 @@ +---- BEGIN SSH2 PUBLIC KEY ---- +Comment: "2048-bit RSA, converted by robertdb@laptop-robert from OpenS" +AAAAB3NzaC1yc2EAAAADAQABAAABAQCtazOxnDYBn7y4F4tyA78s0WIuPkd5EWmjsfgw60 +v0yRCmUrJC2fSegeIfmYteDo4gmOHjmSCqHbBss4kCSvuAKB8teBZuNsoyfWUwocXe9PoA +XTFrqu4pHJg3jouV/f2NU8JLG5ba+My90pY/4Dw/PXVg/C7z1d+9u0DoYzMSCq7DedK/aY +HboacWB4JjuNQ+54+6XWxZ0QjlMoXVhulQ+R95NWjRNcMCgF3O8Btd44TwQPXGYxLKtiK3 +O+aj3JwIZvL1cnn1zh20WhXydnslpwZnqnYtqCrTAKs03Bv7a9iU45D2y4BuhRyyiMx6L/ +HTKgneILYBoVfO5kH7ZfFB +---- END SSH2 PUBLIC KEY ---- diff --git a/roles/users/molecule/default/ssh_keys/keyuser.pub b/roles/users/molecule/default/ssh_keys/keyuser.pub new file mode 100644 index 0000000..61bf60a --- /dev/null +++ b/roles/users/molecule/default/ssh_keys/keyuser.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtazOxnDYBn7y4F4tyA78s0WIuPkd5EWmjsfgw60v0yRCmUrJC2fSegeIfmYteDo4gmOHjmSCqHbBss4kCSvuAKB8teBZuNsoyfWUwocXe9PoAXTFrqu4pHJg3jouV/f2NU8JLG5ba+My90pY/4Dw/PXVg/C7z1d+9u0DoYzMSCq7DedK/aYHboacWB4JjuNQ+54+6XWxZ0QjlMoXVhulQ+R95NWjRNcMCgF3O8Btd44TwQPXGYxLKtiK3O+aj3JwIZvL1cnn1zh20WhXydnslpwZnqnYtqCrTAKs03Bv7a9iU45D2y4BuhRyyiMx6L/HTKgneILYBoVfO5kH7ZfFB Generated by Ansible role robertdebock.users diff --git a/roles/users/molecule/default/ssh_keys/privkeyuser b/roles/users/molecule/default/ssh_keys/privkeyuser new file mode 100644 index 0000000..edd49bb --- /dev/null +++ b/roles/users/molecule/default/ssh_keys/privkeyuser @@ -0,0 +1,28 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn +NhAAAAAwEAAQAAAQEAyEIjnJlNVLTfpXn4PCJPeY4+HgjgJjwRJykC9NYd1osu2dCz7DTn +IyARU/Pld+42zPmE7Es0j5MSi6vomgGmzm491/H1LxStRyCZC0LusS5vaj7N3EMkcuxtO/ +SPMTTjrIaKlAsbPd68cUWs3mE2Dp12yY06Xb95nsqrveTNyzU+swoS60VnbKZYcJ4bO2W8 +J/bpbVKKFTdj3RhilA/qGgR78hOFqE2rcBEOjVux4vP5hcGN3p4onS9u8+h/qH19RxPXys +dHnLslV1Mz6yDYJfPgOGIAhjbR5w8fWtSmDWGTdx1Aojztk6vvesFCefnYzvw2NJzi/W5L ++nbAkDYT/QAAA+jZAkqJ2QJKiQAAAAdzc2gtcnNhAAABAQDIQiOcmU1UtN+lefg8Ik95jj +4eCOAmPBEnKQL01h3Wiy7Z0LPsNOcjIBFT8+V37jbM+YTsSzSPkxKLq+iaAabObj3X8fUv +FK1HIJkLQu6xLm9qPs3cQyRy7G079I8xNOOshoqUCxs93rxxRazeYTYOnXbJjTpdv3meyq +u95M3LNT6zChLrRWdsplhwnhs7Zbwn9ultUooVN2PdGGKUD+oaBHvyE4WoTatwEQ6NW7Hi +8/mFwY3eniidL27z6H+ofX1HE9fKx0ecuyVXUzPrINgl8+A4YgCGNtHnDx9a1KYNYZN3HU +CiPO2Tq+96wUJ5+djO/DY0nOL9bkv6dsCQNhP9AAAAAwEAAQAAAQEAw+ROyaT8jFvSWiCR +vuEhNRr7kI3GFiCz9sababz5uyCzV8Zb+jdV0npP+PugAE05thBvAmYeqEOJ5K7o/Z2X+l +7EiDTbTo6/YdB1ZRq4OwHdYuTEoy3avcCgqgF1AQFnpSCG9oJWx5LWa0do7q/RHULTLB3G +dmYTJk3C6iKjXJ6gVUXVO2rocWygdxDdvwXOGnarlMJwCO5MWJPk2uuKkkd6Is5JIFPe5M +fW0wExl6IzYokf3PCwIpl06pr9r4vsMaaIDHyj+SF6JY62KRIOVyu4w+A70iT3coxEeTrR +/Mo4vWhcOSw7ezHCSeYWbU9S4qiTODPrOO9dgiOgR7AUUQAAAIEAljav1cUIGWtG5Xb/fe +uHKLCH2lnUxznt9fGoUlauc0/XCdYdMWVtCMmIHQ0FaYksov2FXK9Ej2nC2xgfD10M4yp7 +9U1qS9qLqTRtkjzITmzjApdWuA28GapK87yDgrXFzIAL00kH2ZDq94OlwKs2+IyJAmQc7I +v49aYLlKq/cfYAAACBAPeQYblgQVcw1ae3NVkyVyPOzy3Cta3BM1Hc3xXS7AWh/o1gXklI +58c6z7+J9M5QL3Up94RxnSU+cYBGVtdjYU+nbeh7E0PwcP2i/PNvvfIiHf0h9BWditJH0Q +Zy5ezVBrnYH9qlsJnw7tTH/k4pT/TB2QOSUvvQEHXbskdVKbwjAAAAgQDPFRZ9adrzCJnx +csFPLHR/pyHtO6v/+4gpjLSvlZywzgOM3nDW6trNH9cfFTIgqrpgyJyNTpbN2OW9NZBYqo +hRF+4oe5gn0ByF4qfDciMWqfqX53LawCk8oAKqXdUXA/JM5majZZGw55PbIH6vK5E2MVm8 +/UZLoNdhq7Fwo9BhXwAAACxHZW5lcmF0ZWQgYnkgQW5zaWJsZSByb2xlIHJvYmVydGRlYm +9jay51c2VycwECAwQF +-----END OPENSSH PRIVATE KEY----- diff --git a/roles/users/molecule/default/ssh_keys/privkeyuser.ppk b/roles/users/molecule/default/ssh_keys/privkeyuser.ppk new file mode 100644 index 0000000..fb302c3 --- /dev/null +++ b/roles/users/molecule/default/ssh_keys/privkeyuser.ppk @@ -0,0 +1,9 @@ +---- BEGIN SSH2 PUBLIC KEY ---- +Comment: "2048-bit RSA, converted by robertdb@laptop-robert from OpenS" +AAAAB3NzaC1yc2EAAAADAQABAAABAQDIQiOcmU1UtN+lefg8Ik95jj4eCOAmPBEnKQL01h +3Wiy7Z0LPsNOcjIBFT8+V37jbM+YTsSzSPkxKLq+iaAabObj3X8fUvFK1HIJkLQu6xLm9q +Ps3cQyRy7G079I8xNOOshoqUCxs93rxxRazeYTYOnXbJjTpdv3meyqu95M3LNT6zChLrRW +dsplhwnhs7Zbwn9ultUooVN2PdGGKUD+oaBHvyE4WoTatwEQ6NW7Hi8/mFwY3eniidL27z +6H+ofX1HE9fKx0ecuyVXUzPrINgl8+A4YgCGNtHnDx9a1KYNYZN3HUCiPO2Tq+96wUJ5+d +jO/DY0nOL9bkv6dsCQNhP9 +---- END SSH2 PUBLIC KEY ---- diff --git a/roles/users/molecule/default/ssh_keys/privkeyuser.pub b/roles/users/molecule/default/ssh_keys/privkeyuser.pub new file mode 100644 index 0000000..059c5f1 --- /dev/null +++ b/roles/users/molecule/default/ssh_keys/privkeyuser.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIQiOcmU1UtN+lefg8Ik95jj4eCOAmPBEnKQL01h3Wiy7Z0LPsNOcjIBFT8+V37jbM+YTsSzSPkxKLq+iaAabObj3X8fUvFK1HIJkLQu6xLm9qPs3cQyRy7G079I8xNOOshoqUCxs93rxxRazeYTYOnXbJjTpdv3meyqu95M3LNT6zChLrRWdsplhwnhs7Zbwn9ultUooVN2PdGGKUD+oaBHvyE4WoTatwEQ6NW7Hi8/mFwY3eniidL27z6H+ofX1HE9fKx0ecuyVXUzPrINgl8+A4YgCGNtHnDx9a1KYNYZN3HUCiPO2Tq+96wUJ5+djO/DY0nOL9bkv6dsCQNhP9 Generated by Ansible role robertdebock.users diff --git a/roles/users/molecule/ec2/README.md b/roles/users/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/users/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/users/molecule/ec2/create.yml b/roles/users/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/users/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/users/molecule/ec2/destroy.yml b/roles/users/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/users/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/users/molecule/ec2/molecule.yml b/roles/users/molecule/ec2/molecule.yml deleted file mode 100644 index d8ecd5a..0000000 --- a/roles/users/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: users-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: users-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: users-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: users-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: users-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: users-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - users-ubuntu-18.04: - ansible_user: ubuntu - users-centos-7: - ansible_user: centos - users-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/users/molecule/fedora-latest/molecule.yml b/roles/users/molecule/fedora-latest/molecule.yml deleted file mode 100644 index 90c4bc4..0000000 --- a/roles/users/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/users/molecule/fedora-rawhide/molecule.yml b/roles/users/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 7e20d24..0000000 --- a/roles/users/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/users/molecule/opensuse-leap/molecule.yml b/roles/users/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index a132a73..0000000 --- a/roles/users/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/users/molecule/ubuntu-devel/molecule.yml b/roles/users/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index fcec760..0000000 --- a/roles/users/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/users/molecule/ubuntu-latest/molecule.yml b/roles/users/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 33b77e0..0000000 --- a/roles/users/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/users/molecule/ubuntu-rolling/molecule.yml b/roles/users/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index 331ca82..0000000 --- a/roles/users/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: users-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/users/molecule/vagrant/INSTALL.rst b/roles/users/molecule/vagrant/INSTALL.rst deleted file mode 100644 index ca81c7b..0000000 --- a/roles/users/molecule/vagrant/INSTALL.rst +++ /dev/null @@ -1,17 +0,0 @@ -******* -Vagrant driver installation guide -******* - -Requirements -============ - -* Vagrant -* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop -* python-vagrant - -Install -======= - -.. code-block:: bash - - $ sudo pip install python-vagrant diff --git a/roles/users/molecule/vagrant/molecule.yml b/roles/users/molecule/vagrant/molecule.yml deleted file mode 100644 index bdcb079..0000000 --- a/roles/users/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: users-debian - box: debian/stretch64 - - name: users-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - users-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/users/requirements.yml b/roles/users/requirements.yml index 46dec9d..e531325 100644 --- a/roles/users/requirements.yml +++ b/roles/users/requirements.yml @@ -1,2 +1,3 @@ --- - robertdebock.bootstrap +- robertdebock.core_dependencies diff --git a/roles/users/tasks/main.yml b/roles/users/tasks/main.yml index f043ada..1f67550 100644 --- a/roles/users/tasks/main.yml +++ b/roles/users/tasks/main.yml @@ -4,6 +4,8 @@ file: path: "{{ users_ssh_key_directory }}" state: directory + when: + - '"manage_ssh_key: yes" in users_user_list' delegate_to: localhost become: no diff --git a/roles/users/tasks/user.yml b/roles/users/tasks/user.yml index b72dd8b..1319d90 100644 --- a/roles/users/tasks/user.yml +++ b/roles/users/tasks/user.yml @@ -10,6 +10,7 @@ group: "{{ user.group | default(omit) }}" groups: "{{ user.groups | default(omit) }}" shell: "{{ user.shell | default(users_shell) }}" + update_password: "{{ user.update_password | default(omit) }}" register: users_manage_user - name: set sudo options for {{ user.name }} diff --git a/roles/users/tox.ini b/roles/users/tox.ini new file mode 100644 index 0000000..a902e16 --- /dev/null +++ b/roles/users/tox.ini @@ -0,0 +1,22 @@ +# +# Ansible managed +# +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/users/vars/main.yml b/roles/users/vars/main.yml index 4183a5c..5c07541 100644 --- a/roles/users/vars/main.yml +++ b/roles/users/vars/main.yml @@ -1,5 +1,4 @@ --- # vars file for users - users_ssh_keygen_command: ssh-keygen -f {{ users_ssh_key_directory }}/{{ user.name }} -N "" -C "Generated by Ansible role robertdebock.users" users_ssh_keygen_pubkey_command: ssh-keygen -y -f {{ users_ssh_key_directory }}/{{ user.name }} diff --git a/roles/vagrant/.ansible-lint b/roles/vagrant/.ansible-lint new file mode 100644 index 0000000..f2934a8 --- /dev/null +++ b/roles/vagrant/.ansible-lint @@ -0,0 +1,4 @@ +exclude_paths: + - ./meta/version.yml + - ./meta/exception.yml + - ./meta/preferences.yml diff --git a/roles/vagrant/.github/ISSUE_TEMPLATE/bug_report.md b/roles/vagrant/.github/ISSUE_TEMPLATE/bug_report.md index bd1a0dc..c695b98 100644 --- a/roles/vagrant/.github/ISSUE_TEMPLATE/bug_report.md +++ b/roles/vagrant/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,21 +7,22 @@ about: Create a report to help us improve **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: -1. Run this role: -2. See error +**Playbook** +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + + +```yaml +YOUR PLAYBOOK HERE +``` + +**Output** +Show at least the error, possible related output, maybe just all the output. **Expected behavior** A clear and concise description of what you expected to happen. -**Error** -Please show the resulting error. If applicable a snippet of the playbook including the role ran with `-vvv` - **Environment** -- Control node OS: [e.g. Debian 9] -- Control node Ansible version: [e.g. 2.6.2] -- Managed node OS: [e.g. CentOS 7] - -**Additional context** -Add any other context about the problem here. +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) diff --git a/roles/vagrant/.gitignore b/roles/vagrant/.gitignore index 47cf7b9..982db11 100644 --- a/roles/vagrant/.gitignore +++ b/roles/vagrant/.gitignore @@ -1,3 +1,4 @@ -molecule/*/.molecule +.molecule *.log -*.swp \ No newline at end of file +*.swp +.tox diff --git a/roles/vagrant/.travis.yml b/roles/vagrant/.travis.yml index a1d4693..22c19e3 100644 --- a/roles/vagrant/.travis.yml +++ b/roles/vagrant/.travis.yml @@ -1,85 +1,43 @@ --- -sudo: required language: python -services: docker + +python: + - "3.7" + +services: + - docker env: - - version=">=2.7,<2.8" distro="alpine-latest" - - version="" distro="alpine-latest" - - version="devel" distro="alpine-latest" - - version=">=2.7,<2.8" distro="alpine-edge" - - version="" distro="alpine-edge" - - version="devel" distro="alpine-edge" - - version=">=2.7,<2.8" distro="archlinux" - - version="" distro="archlinux" - - version="devel" distro="archlinux" - - version=">=2.7,<2.8" distro="centos-6" expectation="fail" - - version="" distro="centos-6" expectation="fail" - - version="devel" distro="centos-6" expectation="fail" - - version=">=2.7,<2.8" distro="centos-latest" - - version="" distro="centos-latest" - - version="devel" distro="centos-latest" - - version=">=2.7,<2.8" distro="debian-stable" - - version="" distro="debian-stable" - - version="devel" distro="debian-stable" - - version=">=2.7,<2.8" distro="debian-unstable" - - version="" distro="debian-unstable" - - version="devel" distro="debian-unstable" - - version=">=2.7,<2.8" distro="fedora-latest" - - version="" distro="fedora-latest" - - version="devel" distro="fedora-latest" - - version=">=2.7,<2.8" distro="fedora-rawhide" - - version="" distro="fedora-rawhide" - - version="devel" distro="fedora-rawhide" - - version=">=2.7,<2.8" distro="opensuse-leap" - - version="" distro="opensuse-leap" - - version="devel" distro="opensuse-leap" - - version=">=2.7,<2.8" distro="ubuntu-rolling" - - version="" distro="ubuntu-rolling" - - version="devel" distro="ubuntu-rolling" - - version=">=2.7,<2.8" distro="ubuntu-latest" - - version="" distro="ubuntu-latest" - - version="devel" distro="ubuntu-latest" - - version=">=2.7,<2.8" distro="ubuntu-devel" - - version="" distro="ubuntu-devel" - - version="devel" distro="ubuntu-devel" + global: + namespace="robertdebock" + matrix: + - image="alpine" + - image="alpine" tag="edge" + # - namespace="archlinux" image="base" + - image="debian" tag="unstable" + - image="debian" + - image="centos" tag="7" + - image="centos" + - image="fedora" + - image="fedora" tag="rawhide" + - image="opensuse" + - image="ubuntu" matrix: allow_failures: - - env: version=">=2.7,<2.8" distro="alpine-edge" - - env: version="" distro="alpine-edge" - - env: version="devel" distro="alpine-edge" - - env: version="devel" distro="alpine-latest" - - env: version="devel" distro="archlinux" - - env: version="devel" distro="centos-6" expectation="fail" - - env: version="devel" distro="centos-latest" - - env: version="devel" distro="debian-stable" - - env: version=">=2.7,<2.8" distro="debian-unstable" - - env: version="" distro="debian-unstable" - - env: version="devel" distro="debian-unstable" - - env: version="devel" distro="fedora-latest" - - env: version=">=2.7,<2.8" distro="fedora-rawhide" - - env: version="" distro="fedora-rawhide" - - env: version="devel" distro="fedora-rawhide" - - env: version="devel" distro="opensuse-leap" - - env: version="devel" distro="ubuntu-rolling" - - env: version=">=2.7,<2.8" distro="ubuntu-devel" - - env: version="" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-devel" - - env: version="devel" distro="ubuntu-latest" + - env: image="alpine" tag="edge" + - env: image="debian" tag="unstable" + - env: image="fedora" tag="rawhide" cache: - pip install: - pip install --upgrade pip - - if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - - if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi - - pip install molecule - - pip install docker + - pip install tox script: - - if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi + - tox --parallel all notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/vagrant/README.md b/roles/vagrant/README.md index ee64234..78b1a9d 100644 --- a/roles/vagrant/README.md +++ b/roles/vagrant/README.md @@ -2,14 +2,14 @@ vagrant ========= Ansible logo -Build status + Build status Install vagrant on your system. Example Playbook ---------------- -This example is taken from `molecule/resources/playbook.yml`: +This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release. ```yaml --- - name: Converge @@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`: - robertdebock.vagrant ``` -The machine you are running this on, may need to be prepared. +The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work. ```yaml --- - name: Prepare @@ -31,11 +31,13 @@ The machine you are running this on, may need to be prepared. roles: - role: robertdebock.bootstrap + - role: robertdebock.core_dependencies - role: robertdebock.buildtools - role: robertdebock.epel - role: robertdebock.python_pip ``` + Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. Role Variables @@ -64,6 +66,7 @@ The following roles can be installed to ensure all requirements are met, using ` ```yaml --- - robertdebock.bootstrap +- robertdebock.core_dependencies - robertdebock.buildtools - robertdebock.epel - robertdebock.python_pip @@ -82,42 +85,86 @@ Here is an overview of related roles: Compatibility ------------- -This role has been tested against the following distributions and Ansible version: +This role has been tested on these [container images](https://hub.docker.com/): -|distribution|ansible 2.7|ansible 2.8|ansible devel| -|------------|-----------|-----------|-------------| -|alpine-edge*|yes|yes|yes*| -|alpine-latest|yes|yes|yes*| -|archlinux|yes|yes|yes*| -|centos-6|no|no|no*| -|centos-latest|yes|yes|yes*| -|debian-stable|yes|yes|yes*| -|debian-unstable*|yes|yes|yes*| -|fedora-latest|yes|yes|yes*| -|fedora-rawhide*|yes|yes|yes*| -|opensuse-leap|yes|yes|yes*| -|ubuntu-devel*|yes|yes|yes*| -|ubuntu-latest|yes|yes|yes*| -|ubuntu-rolling|yes|yes|yes*| +|container|tag|allow_failures| +|---------|---|--------------| +|alpine|latest|no| +|alpine|edge|yes| +|debian|unstable|yes| +|debian|latest|no| +|centos|7|no| +|centos|latest|no| +|fedora|latest|no| +|fedora|rawhide|yes| +|opensuse|latest|no| +|ubuntu|latest|no| + +This role has been tested on these Ansible versions: + +- ansible>=2.8, <2.9 +- ansible>=2.9 +- git+https://github.com/ansible/ansible.git@devel + +Exceptions +---------- + +Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work: + +| variation | reason | +|---------------------------|------------------------| +| alpine | Dependency not available: python_pip | -A single star means the build may fail, it's marked as an experimental build. Testing ------- -[Unit tests](https://travis-ci.org/robertdebock/ansible-role-vagrant) are done on every commit and periodically. +[Unit tests](https://travis-ci.org/robertdebock/ansible-role-vagrant) are done on every commit, pull request, release and periodically. If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-vagrant/issues) -To test this role locally please use [Molecule](https://github.com/ansible/molecule): +Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule): + +[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions. +[Molecule](https://github.com/ansible/molecule) tests multiple distributions. + +To test using the defaults (any installed ansible version, namespace: `robertdebock`, image: `fedora`, tag: `latest`): + ``` -pip install molecule molecule test + +# Or select a specific image: +image=ubuntu molecule test +# Or select a specific image and a specific tag: +image="debian" tag="stable" tox ``` -To test on Amazon EC2, configure [~/.aws/credentials](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html) and set a region using `export AWS_REGION=eu-central-1` before running `molecule test --scenario-name ec2`. +Or you can test multiple versions of Ansible, and select images: +Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `robertdebock`, image: `fedora`, tag: `latest`) tests: -There are many specific scenarios available, please have a look in the `molecule/` directory. +``` +tox + +# To run CentOS (namespace: `robertdebock`, tag: `latest`) +image="centos" tox +# Or customize more: +image="debian" tag="stable" tox +``` + +Modules +------- + +This role uses the following modules: +```yaml +--- +- apt +- get_url +- package +- pip +- service +- unarchive +- zypper +``` License ------- diff --git a/roles/vagrant/meta/.galaxy_install_info b/roles/vagrant/meta/.galaxy_install_info index 00c5615..81b32bc 100644 --- a/roles/vagrant/meta/.galaxy_install_info +++ b/roles/vagrant/meta/.galaxy_install_info @@ -1 +1,2 @@ -{install_date: 'Tue Sep 17 04:22:11 2019', version: 2.0.5} +install_date: Mon Dec 16 06:46:06 2019 +version: 2.1.1 diff --git a/roles/vagrant/meta/exception.yml b/roles/vagrant/meta/exception.yml new file mode 100644 index 0000000..5897a1b --- /dev/null +++ b/roles/vagrant/meta/exception.yml @@ -0,0 +1,4 @@ +--- +exceptions: + - variation: alpine + reason: "Dependency not available: python_pip" diff --git a/roles/vagrant/meta/main.yml b/roles/vagrant/meta/main.yml index 2cfca46..01491b9 100644 --- a/roles/vagrant/meta/main.yml +++ b/roles/vagrant/meta/main.yml @@ -5,22 +5,22 @@ galaxy_info: description: Install vagrant on your system. license: Apache-2.0 company: none - min_ansible_version: 2.6 + min_ansible_version: 2.8 platforms: - name: Alpine versions: - all - name: ArchLinux - version: + versions: - all - name: Debian versions: - all - name: EL - version: - - 6 + versions: - 7 + - 8 - name: Fedora versions: - all @@ -34,14 +34,8 @@ galaxy_info: galaxy_tags: - vagrant - - alpine - archlinux - centos - - debian - - el - - fedora - - opensuse - rhel - - ubuntu dependencies: [] diff --git a/roles/vagrant/molecule.yml b/roles/vagrant/molecule.yml new file mode 100644 index 0000000..e13e499 --- /dev/null +++ b/roles/vagrant/molecule.yml @@ -0,0 +1,21 @@ +--- +dependency: + name: galaxy + options: + role-file: requirements.yml +lint: + name: yamllint +driver: + name: docker +platforms: + - name: "vagrant-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes +provisioner: + name: ansible +scenario: + name: default diff --git a/roles/vagrant/molecule/alpine-edge/molecule.yml b/roles/vagrant/molecule/alpine-edge/molecule.yml deleted file mode 100644 index cb6c8c6..0000000 --- a/roles/vagrant/molecule/alpine-edge/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-edge diff --git a/roles/vagrant/molecule/alpine-latest/molecule.yml b/roles/vagrant/molecule/alpine-latest/molecule.yml deleted file mode 100644 index 461473d..0000000 --- a/roles/vagrant/molecule/alpine-latest/molecule.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: alpine-latest diff --git a/roles/vagrant/molecule/archlinux/molecule.yml b/roles/vagrant/molecule/archlinux/molecule.yml deleted file mode 100644 index 04c7c17..0000000 --- a/roles/vagrant/molecule/archlinux/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-archlinux - image: archlinux/base - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: archlinux diff --git a/roles/vagrant/molecule/centos-6/molecule.yml b/roles/vagrant/molecule/centos-6/molecule.yml deleted file mode 100644 index 76bf48f..0000000 --- a/roles/vagrant/molecule/centos-6/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-centos-6 - image: centos:6 - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-6 diff --git a/roles/vagrant/molecule/centos-latest/molecule.yml b/roles/vagrant/molecule/centos-latest/molecule.yml deleted file mode 100644 index 1757ab2..0000000 --- a/roles/vagrant/molecule/centos-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-centos-latest - image: centos:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: centos-latest diff --git a/roles/vagrant/molecule/debian-stable/molecule.yml b/roles/vagrant/molecule/debian-stable/molecule.yml deleted file mode 100644 index dca3d9b..0000000 --- a/roles/vagrant/molecule/debian-stable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-debian-stable - image: debian:stable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-stable diff --git a/roles/vagrant/molecule/debian-unstable/molecule.yml b/roles/vagrant/molecule/debian-unstable/molecule.yml deleted file mode 100644 index b51f5b3..0000000 --- a/roles/vagrant/molecule/debian-unstable/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-debian-unstable - image: debian:unstable - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: debian-unstable diff --git a/roles/vagrant/molecule/default/molecule.yml b/roles/vagrant/molecule/default/molecule.yml index fcbccb7..e13e499 100644 --- a/roles/vagrant/molecule/default/molecule.yml +++ b/roles/vagrant/molecule/default/molecule.yml @@ -8,63 +8,14 @@ lint: driver: name: docker platforms: - - name: vagrant-alpine-edge - image: alpine:edge - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: vagrant-alpine-latest - image: alpine:latest - pre_build_image: yes - command: sh -c "while true ; do sleep 1 ; done" - - name: vagrant-archlinux - image: archlinux/base - pre_build_image: yes - - name: vagrant-centos-6 - image: centos:6 - pre_build_image: yes - - name: vagrant-centos-latest - image: centos:latest - pre_build_image: yes - - name: vagrant-debian-stable - image: debian:stable - pre_build_image: yes - - name: vagrant-debian-unstable - image: debian:unstable - pre_build_image: yes - - name: vagrant-fedora-latest - image: fedora:latest - pre_build_image: yes - - name: vagrant-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - - name: vagrant-opensuse-leap - image: opensuse/leap - pre_build_image: yes - - name: vagrant-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes - - name: vagrant-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes - - name: vagrant-ubuntu-devel - image: ubuntu:devel + - name: "vagrant-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes pre_build_image: yes provisioner: name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - vagrant-fedora-latest: - ansible_python_interpreter: /usr/bin/python3 - vagrant-fedora-rawhide: - ansible_python_interpreter: /usr/bin/python3 scenario: name: default diff --git a/roles/vagrant/molecule/resources/playbook.yml b/roles/vagrant/molecule/default/playbook.yml similarity index 100% rename from roles/vagrant/molecule/resources/playbook.yml rename to roles/vagrant/molecule/default/playbook.yml diff --git a/roles/investigate/molecule/resources/prepare.yml b/roles/vagrant/molecule/default/prepare.yml similarity index 55% rename from roles/investigate/molecule/resources/prepare.yml rename to roles/vagrant/molecule/default/prepare.yml index c8572a5..0d6f180 100644 --- a/roles/investigate/molecule/resources/prepare.yml +++ b/roles/vagrant/molecule/default/prepare.yml @@ -6,4 +6,7 @@ roles: - role: robertdebock.bootstrap + - role: robertdebock.core_dependencies + - role: robertdebock.buildtools - role: robertdebock.epel + - role: robertdebock.python_pip diff --git a/roles/vagrant/molecule/ec2/README.md b/roles/vagrant/molecule/ec2/README.md deleted file mode 100644 index 856b351..0000000 --- a/roles/vagrant/molecule/ec2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Amazon EC2 - -To test on Amazon elastic compute cloud (EC2), set this variable: - -``` -export EC2_REGION=eu-central-1 -``` - -And save the credentials: -``` -cat ~/.aws/credentials -[default] -aws_access_key_id=YOUR_KEY_ID -aws_secret_access_key=YOUR_ACCESS_KEY -``` diff --git a/roles/vagrant/molecule/ec2/create.yml b/roles/vagrant/molecule/ec2/create.yml deleted file mode 100644 index 7992818..0000000 --- a/roles/vagrant/molecule/ec2/create.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - vars: - ssh_user: ec2-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: Security group for testing Molecule - security_group_rules: - - proto: tcp - from_port: "{{ ssh_port }}" - to_port: "{{ ssh_port }}" - cidr_ip: '0.0.0.0/0' - - proto: icmp - from_port: 8 - to_port: -1 - cidr_ip: '0.0.0.0/0' - security_group_rules_egress: - - proto: -1 - from_port: 0 - to_port: 0 - cidr_ip: '0.0.0.0/0' - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - tasks: - - name: Create security group - ec2_group: - name: "{{ security_group_name }}" - description: "{{ security_group_name }}" - rules: "{{ security_group_rules }}" - rules_egress: "{{ security_group_rules_egress }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - ec2_key: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - ec2_key: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Create molecule instance(s) - ec2: - key_name: "{{ keypair_name }}" - image: "{{ item.image }}" - instance_type: "{{ item.instance_type }}" - vpc_subnet_id: "{{ item.vpc_subnet_id }}" - group: "{{ security_group_name }}" - instance_tags: - instance: "{{ item.name }}" - wait: true - assign_public_ip: true - exact_count: 1 - count_tag: - instance: "{{ item.name }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.instances[0].tags.instance }}", - 'address': "{{ item.instances[0].public_ip }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", - 'instance_ids': "{{ item.instance_ids }}", } - with_items: "{{ ec2_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - timeout: 320 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - - - name: Wait for boot process to finish - pause: - minutes: 2 diff --git a/roles/vagrant/molecule/ec2/destroy.yml b/roles/vagrant/molecule/ec2/destroy.yml deleted file mode 100644 index b460c1e..0000000 --- a/roles/vagrant/molecule/ec2/destroy.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" - tasks: - - block: - - name: Populate instance config - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true - - - name: Destroy molecule instance(s) - ec2: - state: absent - instance_ids: "{{ item.instance_ids }}" - register: server - with_items: "{{ instance_conf }}" - when: not skip_instances - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: ec2_jobs - until: ec2_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/roles/vagrant/molecule/ec2/molecule.yml b/roles/vagrant/molecule/ec2/molecule.yml deleted file mode 100644 index 485877d..0000000 --- a/roles/vagrant/molecule/ec2/molecule.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: ec2 -platforms: - - name: vagrant-rhel-7 - image: ami-c86c3f23 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: vagrant-sles-15 - image: ami-0a1886cf45f944eb1 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: vagrant-ubuntu-18.04 - image: ami-0bdf93799014acdc4 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: vagrant-amazon-linux-2 - image: ami-02ea8f348fa28c108 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: vagrant-centos-7 - image: ami-9a183671 - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 - - name: vagrant-fedora-29 - image: ami-0f904cfaa69a1c64c - instance_type: t2.micro - vpc_subnet_id: subnet-0e688067 -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - vagrant-ubuntu-18.04: - ansible_user: ubuntu - vagrant-centos-7: - ansible_user: centos - vagrant-fedora-29: - ansible_user: fedora -scenario: - name: ec2 - create_sequence: - - create - check_sequence: - - destroy - - dependency - - create - - converge - - check - - destroy - converge_sequence: - - dependency - - create - - converge - destroy_sequence: - - destroy - test_sequence: - - lint - - destroy - - dependency - - syntax - - create - - converge - - idempotence - - side_effect - - verify - - destroy diff --git a/roles/vagrant/molecule/fedora-latest/molecule.yml b/roles/vagrant/molecule/fedora-latest/molecule.yml deleted file mode 100644 index a2ac967..0000000 --- a/roles/vagrant/molecule/fedora-latest/molecule.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-fedora-latest - image: fedora:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-latest diff --git a/roles/vagrant/molecule/fedora-rawhide/molecule.yml b/roles/vagrant/molecule/fedora-rawhide/molecule.yml deleted file mode 100644 index 1227de6..0000000 --- a/roles/vagrant/molecule/fedora-rawhide/molecule.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-fedora-rawhide - image: fedora:rawhide - pre_build_image: yes - registry: - url: registry.fedoraproject.org -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - group_vars: - all: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: fedora-rawhide diff --git a/roles/vagrant/molecule/opensuse-leap/molecule.yml b/roles/vagrant/molecule/opensuse-leap/molecule.yml deleted file mode 100644 index cccab49..0000000 --- a/roles/vagrant/molecule/opensuse-leap/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-opensuse-leap - image: opensuse/leap - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: opensuse-leap diff --git a/roles/vagrant/molecule/ubuntu-devel/molecule.yml b/roles/vagrant/molecule/ubuntu-devel/molecule.yml deleted file mode 100644 index 567c167..0000000 --- a/roles/vagrant/molecule/ubuntu-devel/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-ubuntu-devel - image: ubuntu:devel - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-devel diff --git a/roles/vagrant/molecule/ubuntu-latest/molecule.yml b/roles/vagrant/molecule/ubuntu-latest/molecule.yml deleted file mode 100644 index 53ad7db..0000000 --- a/roles/vagrant/molecule/ubuntu-latest/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-ubuntu-latest - image: ubuntu:latest - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-latest diff --git a/roles/vagrant/molecule/ubuntu-rolling/molecule.yml b/roles/vagrant/molecule/ubuntu-rolling/molecule.yml deleted file mode 100644 index f77f60d..0000000 --- a/roles/vagrant/molecule/ubuntu-rolling/molecule.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: docker -platforms: - - name: vagrant-ubuntu-rolling - image: ubuntu:rolling - pre_build_image: yes -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml -scenario: - name: ubuntu-rolling diff --git a/roles/vagrant/molecule/vagrant/molecule.yml b/roles/vagrant/molecule/vagrant/molecule.yml deleted file mode 100644 index e02be0c..0000000 --- a/roles/vagrant/molecule/vagrant/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy - options: - role-file: requirements.yml -lint: - name: yamllint -driver: - name: vagrant - provider: - name: virtualbox -platforms: - - name: vagrant-debian - box: debian/stretch64 - - name: vagrant-fedora - box: fedora/30-cloud-base -provisioner: - name: ansible - playbooks: - prepare: ../resources/prepare.yml - converge: ../resources/playbook.yml - lint: - name: ansible-lint - options: - exclude: - - meta/version.yml - - meta/exception.yml - inventory: - host_vars: - vagrant-fedora: - ansible_python_interpreter: /usr/bin/python3 -scenario: - name: vagrant diff --git a/roles/vagrant/requirements.yml b/roles/vagrant/requirements.yml index 2fd552b..ee11b6a 100644 --- a/roles/vagrant/requirements.yml +++ b/roles/vagrant/requirements.yml @@ -1,5 +1,6 @@ --- - robertdebock.bootstrap +- robertdebock.core_dependencies - robertdebock.buildtools - robertdebock.epel - robertdebock.python_pip diff --git a/roles/vagrant/tasks/main.yml b/roles/vagrant/tasks/main.yml index 2d8092f..f48df7c 100644 --- a/roles/vagrant/tasks/main.yml +++ b/roles/vagrant/tasks/main.yml @@ -1,10 +1,5 @@ --- # tasks file for vagrant -- name: test veriables and environment - assert: - that: - - vagrant_version is defined - - name: download vagrant get_url: url: "{{ vagrant_package }}" diff --git a/roles/vagrant/tox.ini b/roles/vagrant/tox.ini new file mode 100644 index 0000000..f1cb9a1 --- /dev/null +++ b/roles/vagrant/tox.ini @@ -0,0 +1,19 @@ +[tox] +minversion = 3.7 +envlist = py{37}-ansible-{previous,current,next} +skipsdist = true + +[testenv] +deps = + previous: ansible>=2.8, <2.9 + current: ansible>=2.9 + next: git+https://github.com/ansible/ansible.git@devel + docker + molecule +commands = + molecule test +setenv = + TOX_ENVNAME={envname} + MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname} + +passenv = namespace image tag diff --git a/roles/vagrant/vars/main.yml b/roles/vagrant/vars/main.yml index acac0c5..3eab161 100644 --- a/roles/vagrant/vars/main.yml +++ b/roles/vagrant/vars/main.yml @@ -1,6 +1,5 @@ --- # vars file for vagrant - vagrant_release_url: "https://releases.hashicorp.com/vagrant/{{ vagrant_version }}" _vagrant_package: @@ -8,7 +7,6 @@ _vagrant_package: dnf: "{{ vagrant_release_url }}/vagrant_{{ vagrant_version }}_{{ ansible_architecture }}.rpm" yum: "{{ vagrant_release_url }}/vagrant_{{ vagrant_version }}_{{ ansible_architecture }}.rpm" zypper: "{{ vagrant_release_url }}/vagrant_{{ vagrant_version }}_{{ ansible_architecture }}.rpm" - # src: "{{ vagrant_release_url }}/vagrant_{{ vagrant_version }}_{{ ansible_architecture }}.tar.xz" src: "{{ vagrant_release_url }}/vagrant_{{ vagrant_version }}_linux_amd64.zip" vagrant_package: "{{ _vagrant_package[ansible_pkg_mgr] | default(_vagrant_package['src']) }}"