-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1676 from samvarankashyap/standardize_docker
Merged by Jenkins
- Loading branch information
Showing
28 changed files
with
252 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
skip_list: | ||
- "204" # disable LineTooLongRule | ||
- "503" # disable "Tasks run when changed should be handlers" |
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,7 @@ | ||
.*.swp | ||
.*.swo | ||
*.pyc | ||
*.pyo | ||
__pycache__/* | ||
molecule/*/junit.xml | ||
molecule/*/pytestdebug.log |
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 @@ | ||
Ryan Cole <[email protected]> |
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 @@ | ||
docker_become: true | ||
docker_become_user: root |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
# Handlers for docker |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
../../../library/rundb.py |
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,19 @@ | ||
galaxy_info: | ||
author: Samvaran Rallabandi | ||
description: docker provisioning for LinchPin | ||
company: Red Hat, Inc. | ||
license: GPLv3 | ||
min_ansible_version: 2.8 | ||
platforms: | ||
- name: EL | ||
versions: | ||
- 7 | ||
- 8 | ||
- name: Fedora | ||
versions: | ||
- 30 | ||
- 31 | ||
galaxy_tags: | ||
- oasis | ||
- linchpin | ||
- docker |
6 changes: 6 additions & 0 deletions
6
linchpin/provision/roles/docker/molecule/delegated/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,6 @@ | ||
- name: Create | ||
hosts: all | ||
tasks: | ||
- name: "Create molecule instances" | ||
debug: | ||
msg: "Creating..." |
7 changes: 7 additions & 0 deletions
7
linchpin/provision/roles/docker/molecule/delegated/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,7 @@ | ||
- name: Destroy | ||
hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
roles: | ||
- role: oasis_roles.molecule_docker_ci | ||
molecule_docker_ci_state: absent |
40 changes: 40 additions & 0 deletions
40
linchpin/provision/roles/docker/molecule/delegated/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,40 @@ | ||
dependency: | ||
name: galaxy | ||
options: | ||
role-file: molecule/shared/requirements.yml | ||
driver: | ||
name: delegated | ||
options: | ||
managed: false | ||
ansible_connection_options: | ||
ansible_connection: local | ||
lint: | ||
name: yamllint | ||
options: | ||
config-file: tests/yamllint.yml | ||
platforms: | ||
- name: docker-delegated | ||
provisioner: | ||
name: ansible | ||
lint: | ||
name: ansible-lint | ||
playbooks: | ||
prepare: ../shared/prepare.yml | ||
converge: ../shared/playbook.yml | ||
cleanup: ../shared/cleanup.yml | ||
config_options: | ||
defaults: | ||
stdout_callback: yaml | ||
verifier: | ||
name: testinfra | ||
options: | ||
# Add a -v so you see the individual test names, | ||
# particularly useful with parameterized tests | ||
v: true | ||
lint: | ||
name: flake8 | ||
# Using the shared directory is useful for sharing tests across scenarios, | ||
# but is not a requirement. For scenario specific tests, add the appropriate | ||
# file path to the test or test directory below | ||
additional_files_or_dirs: | ||
- ../../shared/tests |
8 changes: 8 additions & 0 deletions
8
linchpin/provision/roles/docker/molecule/delegated/tests/test_null.py
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,8 @@ | ||
# Without at least a file here, tests in the additional directory will not | ||
# get picked up. If you add actual tests to this directory, then you can | ||
# safely eliminate this file. Otherwise, it exists only to cause the tests in | ||
# shared/tests to be discovered. | ||
# | ||
# Most tests should be written in the shared/tests directory so that they can | ||
# be captured by all the scenarios. Only add tests here if there are tests | ||
# only relevant to a particular scenario |
22 changes: 22 additions & 0 deletions
22
linchpin/provision/roles/docker/molecule/shared/cleanup.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,22 @@ | ||
- name: unregister systems | ||
hosts: all | ||
gather_facts: false | ||
tasks: | ||
- name: wait for host | ||
wait_for_connection: | ||
timeout: 1 | ||
register: waiting | ||
ignore_errors: true | ||
|
||
- block: | ||
- name: fetch facts | ||
setup: {} | ||
|
||
- name: do unregistration | ||
include_role: | ||
name: oasis_roles.rhsm | ||
when: ansible_distribution == 'RedHat' | ||
when: waiting is success | ||
vars: | ||
rhsm_unregister: true | ||
rhsm_username: "{{ omit }}" |
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,5 @@ | ||
- name: converge | ||
hosts: all | ||
roles: | ||
- role: docker | ||
post_tasks: [] |
15 changes: 15 additions & 0 deletions
15
linchpin/provision/roles/docker/molecule/shared/prepare.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,15 @@ | ||
- name: register RHSM | ||
hosts: all | ||
roles: | ||
- role: oasis_roles.rhsm | ||
when: ansible_distribution == 'RedHat' | ||
vars: | ||
rhsm_username: "{{ lookup('env', 'OASIS_RHSM_USERNAME') }}" | ||
rhsm_password: "{{ lookup('env', 'OASIS_RHSM_PASSWORD') }}" | ||
rhsm_server_hostname: "{{ lookup('env', 'OASIS_RHSM_SERVER_HOSTNAME') }}" | ||
rhsm_pool_ids: "{{ lookup('env', 'OASIS_RHSM_POOL_IDS') }}" | ||
rhsm_repositories: | ||
enabled: | ||
- rhel-7-server-rpms | ||
- rhel-7-server-extras-rpms | ||
- rhel-7-server-optional-rpms |
2 changes: 2 additions & 0 deletions
2
linchpin/provision/roles/docker/molecule/shared/requirements.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 @@ | ||
- oasis_roles.rhsm | ||
- oasis_roles.molecule_docker_ci |
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 |
---|---|---|
@@ -1,17 +1,20 @@ | ||
--- | ||
- name: "declaring output vars" | ||
set_fact: | ||
topology_outputs_docker_container: [] | ||
topology_outputs_docker_image: [] | ||
|
||
- name: "Initiating Provisioning of docker resource group" | ||
include: provision_resource_group.yml res_grp={{ item }} | ||
include_tasks: provision_resource_group.yml | ||
vars: | ||
res_grp: "{{ item }}" | ||
with_items: | ||
- "{{ resources }}" | ||
when: state == "present" | ||
|
||
- name: "Initiating Teardown of docker resource group" | ||
include: teardown_resource_group.yml res_grp={{ item }} | ||
include_tasks: teardown_resource_group.yml | ||
vars: | ||
res_grp: "{{ item }}" | ||
with_items: | ||
- "{{ resources }}" | ||
when: state == "absent" |
41 changes: 28 additions & 13 deletions
41
linchpin/provision/roles/docker/tasks/provision_docker_container.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 |
---|---|---|
@@ -1,36 +1,51 @@ | ||
--- | ||
# Provision a docker container | ||
|
||
- set_fact: | ||
- name: "set empty list for docker parameters" | ||
set_fact: | ||
docker_container_params: {} | ||
|
||
# Build the list of parameters to Ansible's docker_container module. | ||
# The topology's resource definition parameters should map to | ||
# Ansible's docker_container parameters, except for 'role'. | ||
|
||
- set_fact: | ||
docker_container_params: "{{ docker_container_params | combine({res_def_item.key: res_def_item.value}) }}" | ||
- name: "Build list of paramters" | ||
set_fact: | ||
docker_container_params: "{{ docker_container_params | | ||
combine({res_def_item.key:\ | ||
res_def_item.value}) }}" | ||
with_dict: "{{ res_def }}" | ||
when: res_def_item.key not in ['role'] | ||
loop_control: | ||
loop_var: res_def_item | ||
|
||
- block: | ||
- name: Provision Docker container | ||
docker_container: "{{ docker_container_params }}" | ||
register: outputitem | ||
- name: Provision Docker container | ||
docker_container: "{{ docker_container_params }}" | ||
register: outputitem | ||
rescue: | ||
- fail: | ||
msg: 'An error occurred with docker_container module. It might be caused by either the lack of Docker on the host, dependencies, or daemon access denial. Please make sure the dependencies are installed and Docker configured correctly. Try running `linchpin setup docker` to install Docker, or `pip install linchpin[docker] to install Python dependencies.' | ||
- name: "Fail when docker dependencies are not found" | ||
fail: | ||
msg: 'An error occurred with docker_container module. | ||
It might be caused by either the lack of Docker on the host, | ||
dependencies, or daemon access denial. | ||
Please make sure the dependencies are installed | ||
and Docker configured correctly. | ||
Try running `linchpin setup docker` | ||
to install Docker, | ||
or `pip install linchpin[docker] | ||
to install Python dependencies.' | ||
|
||
- name: "set tmp var" | ||
set_fact: | ||
tmp: ["{{ outputitem['ansible_facts']['docker_container'] | combine({'resource_definition': res_def}) }}"] | ||
tmp: ["{{ outputitem['ansible_facts']['docker_container'] | | ||
combine({'resource_definition': res_def}) }}"] | ||
|
||
- name: "Append outputitem to topology_outputs" | ||
set_fact: | ||
topology_outputs_docker_container: "{{ topology_outputs_docker_container + tmp }}" | ||
topology_outputs_docker_container: "{{ topology_outputs_docker_container\ | ||
+ tmp }}" | ||
|
||
- name: "Add type to resource" | ||
set_fact: | ||
topology_outputs_docker_container: "{{ topology_outputs_docker_container | add_res_data(res_grp_type, res_def['role']) }}" | ||
topology_outputs_docker_container: "{{ topology_outputs_docker_container | | ||
add_res_data(res_grp_type, | ||
res_def['role']) }}" |
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
--- | ||
- name: "Provision resource" | ||
include: "provision_{{ res_def['role'] }}.yml" | ||
include_tasks: "provision_{{ res_def['role'] }}.yml" |
6 changes: 5 additions & 1 deletion
6
linchpin/provision/roles/docker/tasks/provision_resource_group.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
10 changes: 6 additions & 4 deletions
10
linchpin/provision/roles/docker/tasks/teardown_docker_container_res.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
--- | ||
- name: Teardown Docker container | ||
docker_container: | ||
docker_host: "{{ output_res['resource_definition']['docker_host'] | default(omit) }}" | ||
docker_host: "{{ output_res['resource_definition']['docker_host'] | | ||
default(omit) }}" | ||
name: "{{ output_res['Config']['Hostname'] }}" | ||
force_kill: "{{ output_res['resource_definition']['force_kill'] | default(omit) }}" | ||
keep_volumes: "{{ output_res['resource_definition']['keep_volumes'] | default(omit) }}" | ||
force_kill: "{{ output_res['resource_definition']['force_kill'] | | ||
default(omit) }}" | ||
keep_volumes: "{{ output_res['resource_definition']['keep_volumes'] | | ||
default(omit) }}" | ||
state: absent |
8 changes: 4 additions & 4 deletions
8
linchpin/provision/roles/docker/tasks/teardown_docker_image_res.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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
--- | ||
# Destroy a docker container | ||
|
||
- name: Teardown Docker container | ||
docker_image: | ||
docker_host: "{{ output_res['resource_definition']['docker_host'] | default(omit) }}" | ||
docker_host: "{{ output_res['resource_definition']['docker_host'] | | ||
default(omit) }}" | ||
name: "{{ output_res['resource_definition']['name'] }}" | ||
force: "{{ output_res['resource_definition']['force'] | default(omit) }}" | ||
force: "{{ output_res['resource_definition']['force'] | | ||
default(omit) }}" | ||
tag: "{{ output_res['resource_definition']['tag'] | default(omit) }}" | ||
state: absent |
Oops, something went wrong.