Update roles.

This commit is contained in:
Robert de Bock 2019-12-16 07:47:17 +01:00
parent af5f550208
commit 30ec107002
812 changed files with 4952 additions and 20579 deletions

View File

@ -1,7 +1,7 @@
namespace: "robertdebock" namespace: "robertdebock"
name: "development_environment" name: "development_environment"
description: Install everything you need to develop Ansible roles. description: Install everything you need to develop Ansible roles.
version: "1.2.0" version: "1.2.1"
readme: "README.md" readme: "README.md"
authors: authors:
- "Robert de Bock" - "Robert de Bock"

View File

@ -0,0 +1,5 @@
#
# Ansible managed
#
exclude_paths:
- ./meta/exception.yml

View File

@ -7,21 +7,22 @@ about: Create a report to help us improve
**Describe the bug** **Describe the bug**
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
**To Reproduce** **Playbook**
Steps to reproduce the behavior: Please paste the playbook you are using. (Consider `requirements.yml` and
1. Run this role: optionally the command you've invoked.)
2. See error
```yaml
YOUR PLAYBOOK HERE
```
**Output**
Show at least the error, possible related output, maybe just all the output.
**Expected behavior** **Expected behavior**
A clear and concise description of what you expected to happen. 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** **Environment**
- Control node OS: [e.g. Debian 9] - Control node OS: [e.g. Debian 9] (`cat /etc/os-release`)
- Control node Ansible version: [e.g. 2.6.2] - Control node Ansible version: [e.g. 2.9.1] (`ansible --version`)
- Managed node OS: [e.g. CentOS 7] - Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`)
**Additional context**
Add any other context about the problem here.

View File

@ -1,4 +1,7 @@
--- ---
#
# Ansible managed
#
repository: repository:
description: Install and configure ansible on your system. description: Install and configure ansible on your system.
homepage: https://robertdebock.nl/ homepage: https://robertdebock.nl/

View File

@ -1,3 +1,4 @@
molecule/*/.molecule .molecule
*.log *.log
*.swp *.swp
.tox

View File

@ -1,85 +1,44 @@
--- ---
sudo: required #
# Ansible managed
#
language: python language: python
services: docker
python:
- "3.7"
services:
- docker
env: env:
- version=">=2.7,<2.8" distro="alpine-latest" global:
- version="" distro="alpine-latest" namespace="robertdebock"
- version="devel" distro="alpine-latest" matrix:
- version=">=2.7,<2.8" distro="alpine-edge" - image="amazonlinux"
- version="" distro="alpine-edge" - image="alpine"
- version="devel" distro="alpine-edge" - image="alpine" tag="edge"
- version=">=2.7,<2.8" distro="archlinux" # - namespace="archlinux" image="base"
- version="" distro="archlinux" - image="debian" tag="unstable"
- version="devel" distro="archlinux" - image="debian"
- version=">=2.7,<2.8" distro="centos-6" - image="fedora"
- version="" distro="centos-6" - image="fedora" tag="rawhide"
- version="devel" distro="centos-6" - image="ubuntu"
- 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: matrix:
allow_failures: allow_failures:
- env: version=">=2.7,<2.8" distro="alpine-edge" - env: image="alpine" tag="edge"
- env: version="" distro="alpine-edge" - env: image="debian" tag="unstable"
- env: version="devel" distro="alpine-edge" - env: image="fedora" tag="rawhide"
- 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: cache:
- pip - pip
install: install:
- pip install --upgrade pip - pip install --upgrade pip
- if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - pip install tox
- if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi
- pip install molecule
- pip install docker
script: script:
- if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi - tox --parallel all
notifications: notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/ webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@ -2,14 +2,14 @@ ansible
========= =========
<img src="https://docs.ansible.com/ansible-tower/3.2.4/html_ja/installandreference/_static/images/logo_invert.png" width="10%" height="10%" alt="Ansible logo" align="right"/> <img src="https://docs.ansible.com/ansible-tower/3.2.4/html_ja/installandreference/_static/images/logo_invert.png" width="10%" height="10%" alt="Ansible logo" align="right"/>
<a href="https://travis-ci.org/robertdebock/ansible-role-ansible"><img src="https://travis-ci.org/robertdebock/ansible-role-ansible.svg?branch=master" alt="Build status" align="left"/></a> <a href="https://travis-ci.org/robertdebock/ansible-role-ansible"> <img src="https://travis-ci.org/robertdebock/ansible-role-ansible.svg?branch=master" alt="Build status"/></a> <img src="https://img.shields.io/ansible/role/d/35944"/> <img src="https://img.shields.io/ansible/quality/35944"/>
Install and configure ansible on your system. Install and configure ansible on your system.
Example Playbook 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 ```yaml
--- ---
- name: Converge - name: Converge
@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`:
- robertdebock.ansible - 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 ```yaml
--- ---
- name: Prepare - name: Prepare
@ -32,6 +32,24 @@ The machine you are running this on, may need to be prepared.
roles: roles:
- role: robertdebock.bootstrap - role: robertdebock.bootstrap
- role: robertdebock.epel - 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. 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.bootstrap
- robertdebock.epel - robertdebock.epel
- robertdebock.buildtools
- robertdebock.python_pip
``` ```
@ -84,42 +104,80 @@ Here is an overview of related roles:
Compatibility 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| |container|tag|allow_failures|
|------------|-----------|-----------|-------------| |---------|---|--------------|
|alpine-edge*|yes|yes|yes*| |amazonlinux|latest|no|
|alpine-latest|yes|yes|yes*| |alpine|latest|no|
|archlinux|yes|yes|yes*| |alpine|edge|yes|
|centos-6|yes|yes|yes*| |debian|unstable|yes|
|centos-latest|yes|yes|yes*| |debian|latest|no|
|debian-stable|yes|yes|yes*| |fedora|latest|no|
|debian-unstable*|yes|yes|yes*| |fedora|rawhide|yes|
|fedora-latest|yes|yes|yes*| |ubuntu|latest|no|
|fedora-rawhide*|yes|yes|yes*|
|opensuse-leap|yes|yes|yes*| This role has been tested on these Ansible versions:
|ubuntu-devel*|yes|yes|yes*|
|ubuntu-latest|yes|yes|yes*| - ansible>=2.8, <2.9
|ubuntu-rolling|yes|yes|yes*| - 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 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) 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 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 License
------- -------

View File

@ -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

View File

@ -0,0 +1,4 @@
---
exceptions:
- variation: amazonlinux:1
reason: "No package matching 'python3-pip'"

View File

@ -5,26 +5,26 @@ galaxy_info:
description: Install and configure ansible on your system. description: Install and configure ansible on your system.
license: Apache-2.0 license: Apache-2.0
company: none company: none
min_ansible_version: 2.6 min_ansible_version: 2.8
platforms: platforms:
- name: Amazon
versions:
- Candidate
- name: Alpine - name: Alpine
versions: versions:
- all - all
- name: ArchLinux - name: ArchLinux
version: versions:
- all - all
- name: Debian - name: Debian
versions: versions:
- all - all
- name: EL - name: EL
version:
- 6
- 7
- name: Fedora
versions: versions:
- all - 7
- name: OpenSUSE - 8
- name: Fedora
versions: versions:
- all - all
- name: Ubuntu - name: Ubuntu
@ -34,14 +34,5 @@ galaxy_info:
galaxy_tags: galaxy_tags:
- ansible - ansible
- alpine
- archlinux
- centos
- debian
- el
- fedora
- opensuse
- rhel
- ubuntu
dependencies: [] dependencies: []

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,7 @@
--- ---
#
# Ansible managed
#
dependency: dependency:
name: galaxy name: galaxy
options: options:
@ -8,63 +11,19 @@ lint:
driver: driver:
name: docker name: docker
platforms: platforms:
- name: ansible-alpine-edge - name: "ansible-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}"
image: alpine:edge image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}"
pre_build_image: yes command: /sbin/init
command: sh -c "while true ; do sleep 1 ; done" volumes:
- name: ansible-alpine-latest - /sys/fs/cgroup:/sys/fs/cgroup:ro
image: alpine:latest privileged: yes
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
pre_build_image: yes pre_build_image: yes
provisioner: provisioner:
name: ansible name: ansible
playbooks: verifier:
prepare: ../resources/prepare.yml name: ansible
converge: ../resources/playbook.yml
lint: lint:
name: ansible-lint name: ansible-lint
options: enabled: no
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
scenario: scenario:
name: default name: default

View File

@ -6,6 +6,6 @@
roles: roles:
- role: robertdebock.bootstrap - role: robertdebock.bootstrap
- role: robertdebock.buildtools
- role: robertdebock.epel - role: robertdebock.epel
- role: robertdebock.buildtools
- role: robertdebock.python_pip - role: robertdebock.python_pip

View File

@ -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

View File

@ -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
```

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,5 @@
--- ---
- robertdebock.bootstrap - robertdebock.bootstrap
- robertdebock.epel - robertdebock.epel
- robertdebock.buildtools
- robertdebock.python_pip

View File

@ -1,11 +1,21 @@
--- ---
# tasks file for ansible # tasks file for ansible
- name: install ansible - name: install ansible
block:
- name: install ansible package (allowed to fail)
package: package:
name: "{{ ansible_packages }}" name: "{{ ansible_packages }}"
state: present state: present
register: ansible_install_ansible register: ansible_install_ansible_package
until: ansible_install_ansible is succeeded 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 retries: 3
- name: ensure the ansible directory exists - name: ensure the ansible directory exists

22
roles/ansible/tox.ini Normal file
View File

@ -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

View File

@ -0,0 +1,5 @@
#
# Ansible managed
#
exclude_paths:
- ./meta/exception.yml

View File

@ -7,21 +7,22 @@ about: Create a report to help us improve
**Describe the bug** **Describe the bug**
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
**To Reproduce** **Playbook**
Steps to reproduce the behavior: Please paste the playbook you are using. (Consider `requirements.yml` and
1. Run this role: optionally the command you've invoked.)
2. See error
```yaml
YOUR PLAYBOOK HERE
```
**Output**
Show at least the error, possible related output, maybe just all the output.
**Expected behavior** **Expected behavior**
A clear and concise description of what you expected to happen. 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** **Environment**
- Control node OS: [e.g. Debian 9] - Control node OS: [e.g. Debian 9] (`cat /etc/os-release`)
- Control node Ansible version: [e.g. 2.6.2] - Control node Ansible version: [e.g. 2.9.1] (`ansible --version`)
- Managed node OS: [e.g. CentOS 7] - Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`)
**Additional context**
Add any other context about the problem here.

View File

@ -1,4 +1,7 @@
--- ---
#
# Ansible managed
#
repository: repository:
description: Install ansible-lint on your system. description: Install ansible-lint on your system.
homepage: https://robertdebock.nl/ homepage: https://robertdebock.nl/

View File

@ -1,3 +1,4 @@
molecule/*/.molecule .molecule
*.log *.log
*.swp *.swp
.tox

View File

@ -1,85 +1,42 @@
--- ---
sudo: required #
# Ansible managed
#
language: python language: python
services: docker
python:
- "3.7"
services:
- docker
env: env:
- version=">=2.7,<2.8" distro="alpine-latest" global:
- version="" distro="alpine-latest" namespace="robertdebock"
- version="devel" distro="alpine-latest" matrix:
- version=">=2.7,<2.8" distro="alpine-edge" # - namespace="archlinux" image="base"
- version="" distro="alpine-edge" - image="debian" tag="unstable"
- version="devel" distro="alpine-edge" - image="debian"
- version=">=2.7,<2.8" distro="archlinux" - image="centos"
- version="" distro="archlinux" - image="fedora"
- version="devel" distro="archlinux" - image="fedora" tag="rawhide"
- version=">=2.7,<2.8" distro="centos-6" expectation="fail" - image="opensuse"
- version="" distro="centos-6" expectation="fail" - image="ubuntu"
- 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"
matrix: matrix:
allow_failures: allow_failures:
- env: version=">=2.7,<2.8" distro="alpine-edge" - env: image="debian" tag="unstable"
- env: version="" distro="alpine-edge" - env: image="fedora" tag="rawhide"
- 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"
cache: cache:
- pip - pip
install: install:
- pip install --upgrade pip - pip install --upgrade pip
- if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - pip install tox
- if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi
- pip install molecule
- pip install docker
script: script:
- if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi - tox --parallel all
notifications: notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/ webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@ -2,14 +2,14 @@ ansible_lint
========= =========
<img src="https://docs.ansible.com/ansible-tower/3.2.4/html_ja/installandreference/_static/images/logo_invert.png" width="10%" height="10%" alt="Ansible logo" align="right"/> <img src="https://docs.ansible.com/ansible-tower/3.2.4/html_ja/installandreference/_static/images/logo_invert.png" width="10%" height="10%" alt="Ansible logo" align="right"/>
<a href="https://travis-ci.org/robertdebock/ansible-role-ansible_lint"><img src="https://travis-ci.org/robertdebock/ansible-role-ansible_lint.svg?branch=master" alt="Build status" align="left"/></a> <a href="https://travis-ci.org/robertdebock/ansible-role-ansible_lint"> <img src="https://travis-ci.org/robertdebock/ansible-role-ansible_lint.svg?branch=master" alt="Build status"/></a> <img src="https://img.shields.io/ansible/role/d/35946"/> <img src="https://img.shields.io/ansible/quality/35946"/>
Install ansible-lint on your system. Install ansible-lint on your system.
Example Playbook 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 ```yaml
--- ---
- name: Converge - name: Converge
@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`:
- robertdebock.ansible_lint - 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 ```yaml
--- ---
- name: Prepare - name: Prepare
@ -36,6 +36,7 @@ The machine you are running this on, may need to be prepared.
- role: robertdebock.python_pip - 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. Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles.
Role Variables Role Variables
@ -76,42 +77,78 @@ Here is an overview of related roles:
Compatibility 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| |container|tag|allow_failures|
|------------|-----------|-----------|-------------| |---------|---|--------------|
|alpine-edge*|yes|yes|yes*| |debian|unstable|yes|
|alpine-latest|yes|yes|yes*| |debian|latest|no|
|archlinux|yes|yes|yes*| |centos|latest|no|
|centos-6|no|no|no*| |fedora|latest|no|
|centos-latest|yes|yes|yes*| |fedora|rawhide|yes|
|debian-stable|yes|yes|yes*| |opensuse|latest|no|
|debian-unstable*|yes|yes|yes*| |ubuntu|latest|no|
|fedora-latest|yes|yes|yes*|
|fedora-rawhide*|yes|yes|yes*| This role has been tested on these Ansible versions:
|opensuse-leap|yes|yes|yes*|
|ubuntu-devel*|yes|yes|yes*| - ansible>=2.8, <2.9
|ubuntu-latest|yes|yes|yes*| - ansible>=2.9
|ubuntu-rolling|yes|yes|yes*| - 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 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) 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 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 License
------- -------

View File

@ -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

View File

@ -0,0 +1,6 @@
---
exceptions:
- variation: amazonlinux:1
reason: "No package matching 'python3-pip'"
- variation: amazonlinux
reason: "No module named pkg_resources"

View File

@ -5,21 +5,18 @@ galaxy_info:
description: Install ansible-lint on your system. description: Install ansible-lint on your system.
license: Apache-2.0 license: Apache-2.0
company: none company: none
min_ansible_version: 2.6 min_ansible_version: 2.8
platforms: platforms:
- name: Alpine
versions:
- all
- name: ArchLinux - name: ArchLinux
version: versions:
- all - all
- name: Debian - name: Debian
versions: versions:
- all - all
- name: EL - name: EL
version: versions:
- 7 - 8
- name: Fedora - name: Fedora
versions: versions:
- all - all
@ -33,14 +30,8 @@ galaxy_info:
galaxy_tags: galaxy_tags:
- ansiblelint - ansiblelint
- alpine
- archlinux - archlinux
- centos - centos
- debian
- el
- fedora
- opensuse
- rhel - rhel
- ubuntu
dependencies: [] dependencies: []

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,7 @@
--- ---
#
# Ansible managed
#
dependency: dependency:
name: galaxy name: galaxy
options: options:
@ -8,63 +11,14 @@ lint:
driver: driver:
name: docker name: docker
platforms: platforms:
- name: ansible_lint-alpine-edge - name: "ansible_lint-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}"
image: alpine:edge image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}"
pre_build_image: yes command: /sbin/init
command: sh -c "while true ; do sleep 1 ; done" volumes:
- name: ansible_lint-alpine-latest - /sys/fs/cgroup:/sys/fs/cgroup:ro
image: alpine:latest privileged: yes
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
pre_build_image: yes pre_build_image: yes
provisioner: provisioner:
name: ansible 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: scenario:
name: default name: default

View File

@ -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
```

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,9 +1,5 @@
--- ---
# tasks file for ansible_lint # tasks file for ansible_lint
- name: test veriables and environment
assert:
that:
- name: install ansible_lint - name: install ansible_lint
pip: pip:
name: "{{ ansible_lint_packages }}" name: "{{ ansible_lint_packages }}"

View File

@ -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

5
roles/ara/.ansible-lint Normal file
View File

@ -0,0 +1,5 @@
#
# Ansible managed
#
exclude_paths:
- ./meta/exception.yml

View File

@ -7,21 +7,22 @@ about: Create a report to help us improve
**Describe the bug** **Describe the bug**
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
**To Reproduce** **Playbook**
Steps to reproduce the behavior: Please paste the playbook you are using. (Consider `requirements.yml` and
1. Run this role: optionally the command you've invoked.)
2. See error
```yaml
YOUR PLAYBOOK HERE
```
**Output**
Show at least the error, possible related output, maybe just all the output.
**Expected behavior** **Expected behavior**
A clear and concise description of what you expected to happen. 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** **Environment**
- Control node OS: [e.g. Debian 9] - Control node OS: [e.g. Debian 9] (`cat /etc/os-release`)
- Control node Ansible version: [e.g. 2.6.2] - Control node Ansible version: [e.g. 2.9.1] (`ansible --version`)
- Managed node OS: [e.g. CentOS 7] - Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`)
**Additional context**
Add any other context about the problem here.

View File

@ -1,4 +1,7 @@
--- ---
#
# Ansible managed
#
repository: repository:
description: Install and configure ara on your system. description: Install and configure ara on your system.
homepage: https://robertdebock.nl/ homepage: https://robertdebock.nl/

View File

@ -1,3 +1,4 @@
molecule/*/.molecule .molecule
*.log *.log
*.swp *.swp
.tox

View File

@ -1,85 +1,41 @@
--- ---
sudo: required #
# Ansible managed
#
language: python language: python
services: docker
python:
- "3.7"
services:
- docker
env: env:
- version=">=2.7,<2.8" distro="alpine-latest" expectation="fail" global:
- version="" distro="alpine-latest" expectation="fail" namespace="robertdebock"
- version="devel" distro="alpine-latest" expectation="fail" matrix:
- version=">=2.7,<2.8" distro="alpine-edge" expectation="fail" # - namespace="archlinux" image="base"
- version="" distro="alpine-edge" expectation="fail" - image="debian" tag="unstable"
- version="devel" distro="alpine-edge" expectation="fail" - image="debian"
- version=">=2.7,<2.8" distro="archlinux" - image="centos"
- version="" distro="archlinux" - image="fedora"
- version="devel" distro="archlinux" - image="fedora" tag="rawhide"
- version=">=2.7,<2.8" distro="centos-6" expectation="fail" - image="ubuntu"
- 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"
matrix: matrix:
allow_failures: allow_failures:
- env: version=">=2.7,<2.8" distro="alpine-edge" expectation="fail" - env: image="debian" tag="unstable"
- env: version="" distro="alpine-edge" expectation="fail" - env: image="fedora" tag="rawhide"
- 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"
cache: cache:
- pip - pip
install: install:
- pip install --upgrade pip - pip install --upgrade pip
- if [ "${version}" != "devel" ] ; then pip install ansible"${version}" ; fi - pip install tox
- if [ "${version}" = "devel" ] ; then pip install git+https://github.com/ansible/ansible.git@devel ; fi
- pip install molecule
- pip install docker
script: script:
- if [ "${expectation}" = "fail" ] ; then ! molecule test --scenario-name "${distro}" ; else molecule test --scenario-name "${distro}" ; fi - tox --parallel all
notifications: notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/ webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@ -2,14 +2,14 @@ ara
========= =========
<img src="https://docs.ansible.com/ansible-tower/3.2.4/html_ja/installandreference/_static/images/logo_invert.png" width="10%" height="10%" alt="Ansible logo" align="right"/> <img src="https://docs.ansible.com/ansible-tower/3.2.4/html_ja/installandreference/_static/images/logo_invert.png" width="10%" height="10%" alt="Ansible logo" align="right"/>
<a href="https://travis-ci.org/robertdebock/ansible-role-ara"><img src="https://travis-ci.org/robertdebock/ansible-role-ara.svg?branch=master" alt="Build status" align="left"/></a> <a href="https://travis-ci.org/robertdebock/ansible-role-ara"> <img src="https://travis-ci.org/robertdebock/ansible-role-ara.svg?branch=master" alt="Build status"/></a> <img src="https://img.shields.io/ansible/role/d/24687"/> <img src="https://img.shields.io/ansible/quality/24687"/>
Install and configure ara on your system. Install and configure ara on your system.
Example Playbook 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 ```yaml
--- ---
- name: Converge - name: Converge
@ -21,7 +21,7 @@ This example is taken from `molecule/resources/playbook.yml`:
- robertdebock.ara - 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 ```yaml
--- ---
- name: Prepare - name: Prepare
@ -36,6 +36,7 @@ The machine you are running this on, may need to be prepared.
- robertdebock.python_pip - 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. Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles.
Role Variables Role Variables
@ -96,42 +97,83 @@ Here is an overview of related roles:
Compatibility 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| |container|tag|allow_failures|
|------------|-----------|-----------|-------------| |---------|---|--------------|
|alpine-edge*|no|no|no*| |debian|unstable|yes|
|alpine-latest|no|no|no*| |debian|latest|no|
|archlinux|yes|yes|yes*| |centos|latest|no|
|centos-6|no|no|no*| |fedora|latest|no|
|centos-latest|no|no|no*| |fedora|rawhide|yes|
|debian-stable|no|no|no*| |ubuntu|latest|no|
|debian-unstable*|no|no|no*|
|fedora-latest|yes|yes|yes*| This role has been tested on these Ansible versions:
|fedora-rawhide*|yes|yes|yes*|
|opensuse-leap|no|no|no*| - ansible>=2.8, <2.9
|ubuntu-devel*|no|no|no*| - ansible>=2.9
|ubuntu-latest|no|no|no*| - git+https://github.com/ansible/ansible.git@devel
|ubuntu-rolling|no|no|no*|
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 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) 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 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 License
------- -------

View File

@ -4,8 +4,6 @@
service: service:
name: ara name: ara
state: restarted state: restarted
when:
- ansible_virtualization_type != "docker"
become: yes become: yes
- name: systemctl daemon-reload - name: systemctl daemon-reload

View File

@ -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

View File

@ -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"

View File

@ -5,25 +5,19 @@ galaxy_info:
description: Install and configure ara on your system. description: Install and configure ara on your system.
license: Apache-2.0 license: Apache-2.0
company: none company: none
min_ansible_version: 2.6 min_ansible_version: 2.8
platforms: platforms:
- name: Alpine
versions:
- all
- name: ArchLinux - name: ArchLinux
version: versions:
- all - all
- name: Debian - name: Debian
versions: versions:
- all - all
- name: EL - name: EL
version:
- 7
- name: Fedora
versions: versions:
- all - 8
- name: OpenSUSE - name: Fedora
versions: versions:
- all - all
- name: Ubuntu - name: Ubuntu
@ -32,21 +26,14 @@ galaxy_info:
- bionic - bionic
galaxy_tags: galaxy_tags:
- alpine
- ansiblerecordsansible - ansiblerecordsansible
- ara - ara
- arareportsansible - arareportsansible
- archlinux
- centos
- cloud - cloud
- debian - centos
- development - development
- fedora
- monitoring - monitoring
- opensuse
- reporting
- rhel - rhel
- ubuntu - reporting
- web
dependencies: [] dependencies: []

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,7 @@
--- ---
#
# Ansible managed
#
dependency: dependency:
name: galaxy name: galaxy
options: options:
@ -8,63 +11,14 @@ lint:
driver: driver:
name: docker name: docker
platforms: platforms:
- name: ara-alpine-edge - name: "ara-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}"
image: alpine:edge image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}"
pre_build_image: yes command: /sbin/init
command: sh -c "while true ; do sleep 1 ; done" volumes:
- name: ara-alpine-latest - /sys/fs/cgroup:/sys/fs/cgroup:ro
image: alpine:latest privileged: yes
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
pre_build_image: yes pre_build_image: yes
provisioner: provisioner:
name: ansible 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: scenario:
name: default name: default

View File

@ -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
```

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,13 +1,5 @@
--- ---
# tasks file for ara # 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 - name: install ara
pip: pip:
name: ara[server] name: ara[server]
@ -18,7 +10,7 @@
- name: create ara service - name: create ara service
import_role: import_role:
name: service name: robertdebock.service
- name: find callback_plugins path - name: find callback_plugins path
block: block:
@ -65,5 +57,3 @@
name: ara name: ara
state: started state: started
enabled: yes enabled: yes
when:
- ansible_virtualization_type != "docker"

Some files were not shown because too many files have changed in this diff Show More