Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port molecule v1 host/group vars handling (#712)
Fixes: #693
- Loading branch information
Showing
12 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM centos:7 | ||
|
||
RUN yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf |
27 changes: 27 additions & 0 deletions
27
test/scenarios/host_group_vars/molecule/default/create.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
vars: | ||
molecule_yml: "{{ lookup('file','molecule.yml') | from_yaml }}" | ||
tasks: | ||
- name: Build an Ansible compatible image | ||
docker_image: | ||
path: . | ||
name: molecule_local/centos:7 | ||
|
||
# - name: Pull CentOS image | ||
# docker_image: | ||
# name: centos:7 | ||
# tag: latest | ||
|
||
- name: Create molecule instance(s) | ||
docker_container: | ||
name: "{{ item.name | instance_with_scenario_name(molecule_yml.scenario.name) }}" | ||
hostname: "{{ item.name }}" | ||
image: molecule_local/centos:7 | ||
state: started | ||
recreate: no | ||
log_driver: syslog | ||
command: sleep infinity | ||
|
||
with_items: "{{ molecule_yml.platforms }}" |
11 changes: 11 additions & 0 deletions
11
test/scenarios/host_group_vars/molecule/default/destroy.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
vars: | ||
molecule_yml: "{{ lookup('file','molecule.yml') | from_yaml }}" | ||
tasks: | ||
- name: Destroy molecule instance(s) | ||
docker_container: | ||
name: "{{ item.name | instance_with_scenario_name(molecule_yml.scenario.name) }}" | ||
state: absent | ||
with_items: "{{ molecule_yml.platforms }}" |
2 changes: 2 additions & 0 deletions
2
test/scenarios/host_group_vars/molecule/default/group_vars/example/all.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
host_group_vars_group_vars_dir: True |
2 changes: 2 additions & 0 deletions
2
test/scenarios/host_group_vars/molecule/default/host_vars/host-group-vars-default/all.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
host_group_vars_host_vars_dir: True |
24 changes: 24 additions & 0 deletions
24
test/scenarios/host_group_vars/molecule/default/molecule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
lint: | ||
name: ansible-lint | ||
platforms: | ||
- name: host-group-vars | ||
groups: | ||
- example | ||
provisioner: | ||
name: ansible | ||
host_vars: | ||
# TODO(retr0h): We may wish to handle the scenario_name appended. | ||
host-group-vars-default: | ||
- host_group_vars_host_molecule_yml: True | ||
group_vars: | ||
example: | ||
- host_group_vars_example_group_molecule_yml: True | ||
scenario: | ||
name: default | ||
verifier: | ||
name: testinfra |
23 changes: 23 additions & 0 deletions
23
test/scenarios/host_group_vars/molecule/default/playbook.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- hosts: all | ||
tasks: | ||
- name: Host vars host_var for host host-group-vars from molecule.yml | ||
command: echo "{{ host_group_vars_host_molecule_yml }}" | ||
changed_when: False | ||
|
||
- name: Host vars from host_vars existing directory | ||
command: echo "{{ host_group_vars_host_vars_dir }}" | ||
changed_when: False | ||
|
||
- name: Group vars group_var for group example from molecule.yml | ||
command: echo "{{ host_group_vars_example_group_molecule_yml }}" | ||
changed_when: False | ||
|
||
- name: Group vars from group_vars existing directory | ||
command: echo "{{ host_group_vars_group_vars_dir }}" | ||
changed_when: False | ||
|
||
# TODO(retr0h): Implement children functionality. | ||
# - name: Group host vars scenario test example2:children group vars from molecule.yml | ||
# command: echo "{{ group_host_vars_example2_group_molecule_yml }}" | ||
# changed_when: False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
# tasks file for docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters