Skip to content

Commit

Permalink
Problem: ansible-pulp CI is failing as of molecule 3.0's release
Browse files Browse the repository at this point in the history
Solution:

Follow molecule 3.0 migration guide:
ansible/molecule#2560

Implementation includes:
1. Installing molecule-inspec, now a separate package.
2. Reworking lint sections of molecule.yml files
3. Renaming playbook.yml symlinks to converge.yml
4. Resolve some lint errors

Fixes: #6211
  • Loading branch information
mikedep333 committed Feb 20, 2020
1 parent 8f6aade commit c5a4fe4
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# systemctl subcommands that actually manage services.
skip_list:
- '303'
- '401'
exclude_paths:
- ./roles/geerlingguy.postgresql/
- ../../.ansible/roles/geerlingguy.postgresql/
- ./.github/
5 changes: 5 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
extends: default

rules:
Expand All @@ -13,3 +14,7 @@ rules:
brackets:
min-spaces-inside-empty: 0
max-spaces-inside-empty: 1

ignore: |
.tox
.git
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ and so on.

**Using Molecule:**

1. Install [molecule](https://molecule.readthedocs.io/en/latest/). It is recommended that you do so
with `pip` in a virtualenv.
1. Install [molecule](https://molecule.readthedocs.io/en/latest/) and
[molecule-inspec](https://github.com/ansible-community/molecule-inspec).


It is recommended that you do so with `pip` in a virtualenv.
2. Run molecule commands.

Test all scenarios on all hosts.
Expand Down
File renamed without changes.
12 changes: 4 additions & 8 deletions molecule/default-upgrade/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ dependency:
role-file: requirements.yml
driver:
name: docker
lint:
name: yamllint
lint: |
yamllint .
ansible-lint
# rubocop
# This is ignored by molecule, but can be reused in yaml
.platform_base: &platform_base
privileged: False
Expand Down Expand Up @@ -43,10 +45,7 @@ provisioner:
inventory:
links:
host_vars: ../scenario_resources/host_vars/
lint:
name: ansible-lint
scenario:
name: default-upgrade
test_sequence:
- lint
- dependency
Expand All @@ -59,6 +58,3 @@ scenario:
- verify
verifier:
name: inspec
lint:
name: rubocop
enabled: false
File renamed without changes.
12 changes: 4 additions & 8 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ dependency:
role-file: requirements.yml
driver:
name: docker
lint:
name: yamllint
lint: |
yamllint .
ansible-lint
# rubocop
# This is ignored by molecule, but can be reused in yaml
.platform_base: &platform_base
privileged: False
Expand Down Expand Up @@ -40,10 +42,7 @@ provisioner:
links:
host_vars: ../scenario_resources/host_vars/
group_vars: ../scenario_resources/group_vars/
lint:
name: ansible-lint
scenario:
name: default
test_sequence:
- lint
- dependency
Expand All @@ -56,6 +55,3 @@ scenario:
- verify
verifier:
name: inspec
lint:
name: rubocop
enabled: false
File renamed without changes.
12 changes: 4 additions & 8 deletions molecule/dynamic/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ dependency:
role-file: requirements.yml
driver:
name: docker
lint:
name: yamllint
lint: |
yamllint .
ansible-lint
# rubocop
# This is ignored by molecule, but can be reused in yaml
.platform_base: &platform_base
privileged: False
Expand Down Expand Up @@ -40,10 +42,7 @@ provisioner:
links:
host_vars: ../scenario_resources/host_vars/
group_vars: ../scenario_resources/group_vars/
lint:
name: ansible-lint
scenario:
name: dynamic
test_sequence:
- lint
- dependency
Expand All @@ -56,6 +55,3 @@ scenario:
- verify
verifier:
name: inspec
lint:
name: rubocop
enabled: false
4 changes: 4 additions & 0 deletions molecule/scenario_resources/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
package:
name: "{{ inspec_download_source_dir }}/{{ inspec_package_name }}"
state: latest
tags:
- skip_ansible_lint

- name: Create Molecule directory for test files
file:
Expand All @@ -43,12 +45,14 @@
- name: Register test files
shell: "ls {{ inspec_test_directory }}/test_*.rb"
register: test_files
changed_when: false

- name: Execute Inspec tests
command: "{{ inspec_bin }} exec {{ item }}"
register: test_results
with_items: "{{ test_files.stdout_lines }}"
ignore_errors: true
changed_when: true

- name: Display details about the Inspec results
debug:
Expand Down
File renamed without changes.
12 changes: 4 additions & 8 deletions molecule/source-dynamic/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ dependency:
role-file: requirements.yml
driver:
name: docker
lint:
name: yamllint
lint: |
yamllint .
ansible-lint
# rubocop
# This is ignored by molecule, but can be reused in yaml
.platform_base: &platform_base
privileged: False
Expand Down Expand Up @@ -36,10 +38,7 @@ provisioner:
links:
host_vars: ../scenario_resources/host_vars/
group_vars: ../scenario_resources/group_vars/
lint:
name: ansible-lint
scenario:
name: source-dynamic
test_sequence:
- lint
- dependency
Expand All @@ -55,6 +54,3 @@ scenario:

verifier:
name: inspec
lint:
name: rubocop
enabled: false
File renamed without changes.
12 changes: 4 additions & 8 deletions molecule/source-upgrade/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ dependency:
role-file: requirements.yml
driver:
name: docker
lint:
name: yamllint
lint: |
yamllint .
ansible-lint
# rubocop
# This is ignored by molecule, but can be reused in yaml
.platform_base: &platform_base
privileged: False
Expand Down Expand Up @@ -38,10 +40,7 @@ provisioner:
inventory:
links:
host_vars: ../scenario_resources/host_vars/
lint:
name: ansible-lint
scenario:
name: source-upgrade
test_sequence:
- lint
- dependency
Expand All @@ -60,6 +59,3 @@ scenario:
prepare: prepare.yml
verifier:
name: inspec
lint:
name: rubocop
enabled: false
File renamed without changes.
12 changes: 4 additions & 8 deletions molecule/source/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ dependency:
role-file: requirements.yml
driver:
name: docker
lint:
name: yamllint
lint: |
yamllint .
ansible-lint
# rubocop
# This is ignored by molecule, but can be reused in yaml
.platform_base: &platform_base
privileged: False
Expand Down Expand Up @@ -36,10 +38,7 @@ provisioner:
links:
host_vars: ../scenario_resources/host_vars/
group_vars: ../scenario_resources/group_vars/
lint:
name: ansible-lint
scenario:
name: source
test_sequence:
- lint
- dependency
Expand All @@ -55,6 +54,3 @@ scenario:

verifier:
name: inspec
lint:
name: rubocop
enabled: false
2 changes: 2 additions & 0 deletions molecule/source/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
git:
repo: 'https://github.com/pulp/pulpcore.git'
dest: '{{ pulp_source_dir }}'
version: master
update: yes

- name: Clone pulp_file repository
git:
repo: 'https://github.com/pulp/pulp_file.git'
dest: '{{ item.value.source_dir }}'
version: master
update: yes
with_dict: '{{ pulp_install_plugins }}'

Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ sitepackages = true
deps =
ansible
docker
molecule<3.0
molecule
molecule-inspec
passenv = TRAVIS_WAIT
whitelist_externals =
travis-wait-enhanced
Expand Down

0 comments on commit c5a4fe4

Please sign in to comment.