From 7e0055af20a44b9794727909500761b1d354e7fb Mon Sep 17 00:00:00 2001 From: mnguyen Date: Tue, 12 Sep 2017 11:28:21 -0400 Subject: [PATCH 1/8] Add atomic CLI tests This commit adds tests for the the atomic command. The tests revolve mostly around pulling images and installing/running containers with variations of the options in the atomic subcommand. These tests include: - Pull by fully qualified image name - Pull by short image name - Pull by fully qualified image name with --name option - Pull with tags - Pull by digest - Pull to ostree/docker storage - Images update command Most of the tests use the cockpit container. This container was chosen because it has most of the labels that the atomic command utilizes. For simple tests, the busybox container was chosen because it is small. --- roles/atomic_containers_delete/meta/main.yml | 2 + roles/atomic_containers_delete/tasks/main.yml | 10 + roles/atomic_containers_list/meta/main.yml | 2 + roles/atomic_containers_list/tasks/main.yml | 12 + .../meta/main.yml | 7 + .../tasks/main.yml | 55 ++ roles/atomic_images_delete/meta/main.yml | 2 + roles/atomic_images_delete/tasks/main.yml | 17 +- roles/atomic_images_list/meta/main.yml | 2 + roles/atomic_images_list/tasks/main.yml | 16 + roles/atomic_images_list_verify/meta/main.yml | 7 + .../atomic_images_list_verify/tasks/main.yml | 59 ++ roles/atomic_install/meta/main.yml | 2 + roles/atomic_install/tasks/main.yml | 16 + roles/atomic_pull/meta/main.yml | 2 + roles/atomic_pull/tasks/main.yml | 20 +- roles/atomic_push/meta/main.yml | 2 + roles/atomic_push/tasks/main.yml | 16 + roles/atomic_run/meta/main.yml | 2 + roles/atomic_run/tasks/main.yml | 12 + roles/atomic_stop/meta/main.yml | 2 + roles/atomic_stop/tasks/main.yml | 12 + roles/atomic_uninstall/meta/main.yml | 2 + roles/atomic_uninstall/tasks/main.yml | 16 + roles/docker_commit/meta/main.yml | 2 + roles/docker_commit/tasks/main.yml | 13 + roles/docker_images/meta/main.yml | 2 + roles/docker_images/tasks/main.yml | 22 + roles/docker_pull/meta/main.yml | 2 + roles/docker_pull/tasks/main.yml | 16 + roles/docker_rmi/meta/main.yml | 2 + roles/docker_rmi/tasks/main.yml | 16 + roles/docker_tag/meta/main.yml | 2 + roles/docker_tag/tasks/main.yml | 19 + tests/atomic/README.md | 34 ++ tests/atomic/callback_plugins | 1 + tests/atomic/info.txt | 9 + tests/atomic/main.yml | 527 ++++++++++++++++++ tests/atomic/roles | 1 + tests/atomic/vars.yml | 3 + 40 files changed, 947 insertions(+), 19 deletions(-) create mode 100644 roles/atomic_containers_delete/meta/main.yml create mode 100644 roles/atomic_containers_delete/tasks/main.yml create mode 100644 roles/atomic_containers_list/meta/main.yml create mode 100644 roles/atomic_containers_list/tasks/main.yml create mode 100644 roles/atomic_containers_list_verify/meta/main.yml create mode 100644 roles/atomic_containers_list_verify/tasks/main.yml create mode 100644 roles/atomic_images_delete/meta/main.yml create mode 100644 roles/atomic_images_list/meta/main.yml create mode 100644 roles/atomic_images_list/tasks/main.yml create mode 100644 roles/atomic_images_list_verify/meta/main.yml create mode 100644 roles/atomic_images_list_verify/tasks/main.yml create mode 100644 roles/atomic_install/meta/main.yml create mode 100644 roles/atomic_install/tasks/main.yml create mode 100644 roles/atomic_pull/meta/main.yml create mode 100644 roles/atomic_push/meta/main.yml create mode 100644 roles/atomic_push/tasks/main.yml create mode 100644 roles/atomic_run/meta/main.yml create mode 100644 roles/atomic_run/tasks/main.yml create mode 100644 roles/atomic_stop/meta/main.yml create mode 100644 roles/atomic_stop/tasks/main.yml create mode 100644 roles/atomic_uninstall/meta/main.yml create mode 100644 roles/atomic_uninstall/tasks/main.yml create mode 100644 roles/docker_commit/meta/main.yml create mode 100644 roles/docker_commit/tasks/main.yml create mode 100644 roles/docker_images/meta/main.yml create mode 100644 roles/docker_images/tasks/main.yml create mode 100644 roles/docker_pull/meta/main.yml create mode 100644 roles/docker_pull/tasks/main.yml create mode 100644 roles/docker_rmi/meta/main.yml create mode 100644 roles/docker_rmi/tasks/main.yml create mode 100644 roles/docker_tag/meta/main.yml create mode 100644 roles/docker_tag/tasks/main.yml create mode 100644 tests/atomic/README.md create mode 120000 tests/atomic/callback_plugins create mode 100644 tests/atomic/info.txt create mode 100644 tests/atomic/main.yml create mode 120000 tests/atomic/roles create mode 100644 tests/atomic/vars.yml diff --git a/roles/atomic_containers_delete/meta/main.yml b/roles/atomic_containers_delete/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_containers_delete/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_containers_delete/tasks/main.yml b/roles/atomic_containers_delete/tasks/main.yml new file mode 100644 index 0000000..92cb69a --- /dev/null +++ b/roles/atomic_containers_delete/tasks/main.yml @@ -0,0 +1,10 @@ +--- +# vim: set ft=ansible: +# +- name: Fail if acd_container is undefined + fail: + msg: "acd_container is undefined" + when: acd_container is undefined + +- name: Remove container {{ acd_container }} + command: atomic --assumeyes containers delete {{ acd_container }} diff --git a/roles/atomic_containers_list/meta/main.yml b/roles/atomic_containers_list/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_containers_list/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_containers_list/tasks/main.yml b/roles/atomic_containers_list/tasks/main.yml new file mode 100644 index 0000000..f271a24 --- /dev/null +++ b/roles/atomic_containers_list/tasks/main.yml @@ -0,0 +1,12 @@ +--- +# vim: set ft=ansible: +# +# list containers and save to json +# +- name: List images with --json + command: atomic containers list --json + register: acl + +- name: Save JSON to variable + set_fact: + acl_json: "{{ acl.stdout | to_json | from_json }}" diff --git a/roles/atomic_containers_list_verify/meta/main.yml b/roles/atomic_containers_list_verify/meta/main.yml new file mode 100644 index 0000000..249d575 --- /dev/null +++ b/roles/atomic_containers_list_verify/meta/main.yml @@ -0,0 +1,7 @@ +--- +# vim: set ft=ansible: +# +dependencies: + - role: atomic_containers_list + +allow_duplicates: true diff --git a/roles/atomic_containers_list_verify/tasks/main.yml b/roles/atomic_containers_list_verify/tasks/main.yml new file mode 100644 index 0000000..4216ade --- /dev/null +++ b/roles/atomic_containers_list_verify/tasks/main.yml @@ -0,0 +1,55 @@ +--- +# vim: set ft=ansible: +# +# This role verifies the values of an image from atomic containers list by +# comparing the expected_values dictionary. The unique identifier for the +# containers is image name +# +# Example calling this role: +# - role: atomic_containers_list_verify +# expected_values: +# repo: docker.io/httpd +# id: 21340928304932 +# +- name: Fail if expected_values or expected_values['image_name'] is undefined + fail: + msg: "expected_values or expected_values['image_name'] is undefined" + when: expected_values is undefined or + expected_values['image_name'] is undefined + +- name: Set role facts + set_fact: + aclv_expected: "{{ expected_values }}" + aclv_em: "{{ expect_missing | default(false) | bool }}" + aclv_acl_jq_match: "" + +# acl_json comes from the atomic_containers_list role which is a dependency +# of this role in the meta directory +- name: Get matching list entry + set_fact: + aclv_acl_jq_match: "{{ item }}" + with_items: "{{ acl_json | json_query(query) }}" + vars: + query: "[?image_name=='{{ aclv_expected['image_name'] }}']" + +- name: Fail if no matching image entry + fail: + msg: "No matching container or container is in list when it is not supposed to be" + when: (aclv_acl_jq_match == "" and not aclv_em) or + (aclv_acl_jq_match != "" and aclv_em) + +# There is no way to skip the comparison in the next step if the container +# is expected to not be in the containers list except setting the expected +# dictionary to empty + +- name: Set expected for expected missing case + set_fact: + aclv_expected: {} + when: aclv_em + +- name: Fail if values are incorrect + fail: + msg: "{{ item.key }} is incorrect or does not exist." + when: aclv_acl_jq_match[item.key] is undefined or + item.value not in aclv_acl_jq_match[item.key] + with_dict: "{{ aclv_expected }}" diff --git a/roles/atomic_images_delete/meta/main.yml b/roles/atomic_images_delete/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_images_delete/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_images_delete/tasks/main.yml b/roles/atomic_images_delete/tasks/main.yml index c9c0ca2..a377187 100644 --- a/roles/atomic_images_delete/tasks/main.yml +++ b/roles/atomic_images_delete/tasks/main.yml @@ -1,13 +1,14 @@ --- # vim: set ft=ansible: # -# This role deletes specified container image through the atomic images -# delete command -# -- name: Fail if image is undefined +- name: Fail if aid_image is undefined fail: - msg: "Image is undefined" - when: image is undefined + msg: "aid_image is undefined" + when: aid_image is undefined + +- name: Set options + set_fact: + del_options: "{{ aid_options | default() }}" -- name: Remove specified image - command: atomic --debug --assumeyes images delete {{ image }} +- name: Remove {{ aid_image }} + command: atomic --assumeyes images delete {{ aid_image }} {{ del_options }} diff --git a/roles/atomic_images_list/meta/main.yml b/roles/atomic_images_list/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_images_list/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_images_list/tasks/main.yml b/roles/atomic_images_list/tasks/main.yml new file mode 100644 index 0000000..c8f261d --- /dev/null +++ b/roles/atomic_images_list/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# vim: set ft=ansible: +# +# list images and save to json +# +- name: Set options + set_fact: + images_list_options: "{{ ail_options | default() }}" + +- name: List images with --json + command: atomic images list {{ images_list_options }} --json + register: ail + +- name: Save JSON to variable + set_fact: + ail_json: "{{ ail.stdout | to_json | from_json }}" diff --git a/roles/atomic_images_list_verify/meta/main.yml b/roles/atomic_images_list_verify/meta/main.yml new file mode 100644 index 0000000..7282a3f --- /dev/null +++ b/roles/atomic_images_list_verify/meta/main.yml @@ -0,0 +1,7 @@ +--- +# vim: set ft=ansible: +# +dependencies: + - role: atomic_images_list + +allow_duplicates: true diff --git a/roles/atomic_images_list_verify/tasks/main.yml b/roles/atomic_images_list_verify/tasks/main.yml new file mode 100644 index 0000000..0c889c7 --- /dev/null +++ b/roles/atomic_images_list_verify/tasks/main.yml @@ -0,0 +1,59 @@ +--- +# vim: set ft=ansible: +# +# This role verifies the values of an image from atomic images list by +# comparing the expected_values dictionary. The entry in the list of +# images is determined by the repo property. This role will assume the +# latest tag unless a tag is passed to this role. +# +# Example calling this role: +# - role: atomic_images_list_verify +# expected: +# repo: docker.io/httpd +# +- name: Fail if expected_values or expected_values['repo'] is undefined + fail: + msg: "expected_values or expected_values['repo'] is undefined" + when: expected_values is undefined or + expected_values['repo'] is undefined + +- name: Set facts for role + set_fact: + ailv_expected: "{{ expected_values }}" + ailv_em: "{{ expect_missing | default(false) | bool }}" + ailv_ail_jq_match: "" + ailv_tag: "{{ expected_values['tag'] | default('latest') }}" + +- name: Setup queries + set_fact: + ailv_repo_query: "[?repo=='{{ ailv_expected['repo'] }}']" + ailv_tag_query: "[?tag=='{{ ailv_tag }}']|[0]" + +- name: Get matching list entry + set_fact: + ailv_ail_jq_match: "{{ ail_json | json_query(ailv_repo_query) }}" + +- name: Check for tag in list of images that match the repo + set_fact: + ailv_match: "{{ ailv_ail_jq_match | json_query(ailv_tag_query) }}" + +- name: Fail if no matching image entry + fail: + msg: "No matching image entry or image is in list when it is not supposed to be" + when: (ailv_match == True and ailv_em == True) or + (ailv_match == False and ailv_em == False) + +# There is no way to skip the comparison in the next step if the container +# is expected to not be in the containers list except setting the expected +# dictionary to empty +- name: Set expected for expected missing case + set_fact: + ailv_expected: {} + when: ailv_em + +- name: Fail if values are incorrect + fail: + msg: "Got {{ item.key }}:{{ ailv_match[item.key]}}. Expected {{ item.key }}:{{ item.value }}" + when: ailv_match[item.key] is undefined or + item.value != ailv_match[item.key] + with_dict: "{{ ailv_expected }}" diff --git a/roles/atomic_install/meta/main.yml b/roles/atomic_install/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_install/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_install/tasks/main.yml b/roles/atomic_install/tasks/main.yml new file mode 100644 index 0000000..f6eb3fa --- /dev/null +++ b/roles/atomic_install/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# vim: set ft=ansible: +# +# installs image with atomic cli +# +- name: Fail if ai_image is undefined + fail: + msg: "ai_image is not defined" + when: ai_image is undefined + +- name: Set options + set_fact: + ai_options: "{{ ai_options | default() }}" + +- name: Install image + command: atomic install {{ ai_image }} {{ ai_options }} diff --git a/roles/atomic_pull/meta/main.yml b/roles/atomic_pull/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_pull/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_pull/tasks/main.yml b/roles/atomic_pull/tasks/main.yml index 9a1ce6d..1c3c3b7 100644 --- a/roles/atomic_pull/tasks/main.yml +++ b/roles/atomic_pull/tasks/main.yml @@ -1,18 +1,16 @@ --- # vim: set ft=ansible: # -# This role pulls container image through the atomic pull -# command +# pulls image with atomic cli # -- name: Fail if image is undefined +- name: Fail if apl_image is undefined fail: - msg: "Image is undefined" - when: image is undefined + msg: "apl_image is not defined" + when: apl_image is undefined -- name: Pull container image - command: atomic --debug pull {{ image }} +- name: Set options + set_fact: + pull_options: "{{ apl_options | default() }}" -- name: Verify image exists - command: atomic images list - register: ail - failed_when: image not in ail.stdout +- name: Pull image + command: atomic pull {{ apl_image }} {{ pull_options }} diff --git a/roles/atomic_push/meta/main.yml b/roles/atomic_push/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_push/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_push/tasks/main.yml b/roles/atomic_push/tasks/main.yml new file mode 100644 index 0000000..2fb63ad --- /dev/null +++ b/roles/atomic_push/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# vim: set ft=ansible: +# +# Push image with atomic cli +# +- name: Fail if apsh_image is undefined + fail: + msg: "apsh_image is not defined" + when: apsh_image is undefined + +- name: Set options + set_fact: + push_options: "{{ apsh_options | default() }}" + +- name: Push image + command: atomic push {{ apsh_image }} {{ push_options }} diff --git a/roles/atomic_run/meta/main.yml b/roles/atomic_run/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_run/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_run/tasks/main.yml b/roles/atomic_run/tasks/main.yml new file mode 100644 index 0000000..4e5f373 --- /dev/null +++ b/roles/atomic_run/tasks/main.yml @@ -0,0 +1,12 @@ +--- +# vim: set ft=ansible: +# +# runs container with atomic cli +# +- name: Fail if ar_image is undefined + fail: + msg: "ar_image is not defined" + when: ar_image is undefined + +- name: Run {{ ar_image }} + command: atomic run {{ ar_image }} diff --git a/roles/atomic_stop/meta/main.yml b/roles/atomic_stop/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_stop/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_stop/tasks/main.yml b/roles/atomic_stop/tasks/main.yml new file mode 100644 index 0000000..ac5c43c --- /dev/null +++ b/roles/atomic_stop/tasks/main.yml @@ -0,0 +1,12 @@ +--- +# vim: set ft=ansible: +# +# stops running container with atomic cli +# +- name: Fail if as_container is undefined + fail: + msg: "as_container is not defined" + when: as_container is undefined + +- name: Stop {{ as_container }} + command: atomic stop {{ as_container }} diff --git a/roles/atomic_uninstall/meta/main.yml b/roles/atomic_uninstall/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/atomic_uninstall/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/atomic_uninstall/tasks/main.yml b/roles/atomic_uninstall/tasks/main.yml new file mode 100644 index 0000000..90b54da --- /dev/null +++ b/roles/atomic_uninstall/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# vim: set ft=ansible: +# +# uninstalls image with atomic cli +# +- name: Fail if au_image is undefined + fail: + msg: "au_image is not defined" + when: au_image is undefined + +- name: Set options + set_fact: + au_options: "{{ au_options | default() }}" + +- name: Uninstall image + command: atomic uninstall {{ au_image }} {{ au_options }} diff --git a/roles/docker_commit/meta/main.yml b/roles/docker_commit/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/docker_commit/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/docker_commit/tasks/main.yml b/roles/docker_commit/tasks/main.yml new file mode 100644 index 0000000..b337acd --- /dev/null +++ b/roles/docker_commit/tasks/main.yml @@ -0,0 +1,13 @@ +--- +# +# Commit a change to an image +# + +- name: Fail if dc_commit or dc_image is not defined + fail: + msg: "dc_commit or dc_image is not defined" + when: dc_commit is undefined or + dc_image is undefined + +- name: Commit change + command: docker commit {{ dc_commit }} {{ dc_image }} diff --git a/roles/docker_images/meta/main.yml b/roles/docker_images/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/docker_images/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/docker_images/tasks/main.yml b/roles/docker_images/tasks/main.yml new file mode 100644 index 0000000..95741a8 --- /dev/null +++ b/roles/docker_images/tasks/main.yml @@ -0,0 +1,22 @@ +--- +# vim: set ft=ansible: +# +# list images with docker +# +- name: Set options + set_fact: + images_options: "{{ di_options | default() }}" + +- name: List images + command: docker images {{ images_options }} + register: di_images + when: di_format is undefined + +# The docker format option uses go syntax that also uses double curly braces +# that conflicts Ansibles variable substitution. A separate format option was +# added to work around this. di_format should be in the form: +# {% raw %}'{{.your_format}}'{% endraw %} +- name: List images + command: docker images {{ images_options }} --format={{ di_format }} + register: di_images + when: di_format is defined diff --git a/roles/docker_pull/meta/main.yml b/roles/docker_pull/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/docker_pull/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/docker_pull/tasks/main.yml b/roles/docker_pull/tasks/main.yml new file mode 100644 index 0000000..7e02a42 --- /dev/null +++ b/roles/docker_pull/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# vim: set ft=ansible: +# +# pulls image with docker +# +- name: Fail if dp_image is undefined + fail: + msg: "dp_image is not defined" + when: dp_image is undefined + +- name: Set options + set_fact: + pull_options: "{{ dp_options | default() }}" + +- name: Pull image + command: docker pull {{ dp_image }} {{ pull_options }} diff --git a/roles/docker_rmi/meta/main.yml b/roles/docker_rmi/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/docker_rmi/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/docker_rmi/tasks/main.yml b/roles/docker_rmi/tasks/main.yml new file mode 100644 index 0000000..7fe40cb --- /dev/null +++ b/roles/docker_rmi/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# +# Removes an image +# + +- name: Fail if drmi_image + fail: + msg: "drmi_image is not defined" + when: drmi_image is undefined + +- name: Set optioins + set_fact: + del_options: "{{ drmi_options | default() }}" + +- name: Delete image + command: docker rmi {{ drmi_image }} {{ del_options }} diff --git a/roles/docker_tag/meta/main.yml b/roles/docker_tag/meta/main.yml new file mode 100644 index 0000000..61d3ffe --- /dev/null +++ b/roles/docker_tag/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/roles/docker_tag/tasks/main.yml b/roles/docker_tag/tasks/main.yml new file mode 100644 index 0000000..e1af242 --- /dev/null +++ b/roles/docker_tag/tasks/main.yml @@ -0,0 +1,19 @@ +--- +# +# Tags an image +# + +- name: Fail if dt_image or dt_tag is not defined + fail: + msg: "dt_image or dt_tag is not defined" + when: dt_image is undefined or + dt_tag is undefined + +- debug: + msg: "dt_img: {{ dt_image }}" + +- debug: + msg: "dt_tag: {{ dt_tag }}" + +- name: Tag image + command: docker tag {{ dt_image }} {{ dt_tag }} diff --git a/tests/atomic/README.md b/tests/atomic/README.md new file mode 100644 index 0000000..46f1d95 --- /dev/null +++ b/tests/atomic/README.md @@ -0,0 +1,34 @@ +This playbook tests the atomic commands + +Test Cases +Core Functionality +- atomic images delete +- atomic images list +- atomic images update +- atomic pull +- atomic push +- atomic containers list +- atomic containers delete + +### Prerequisites + - Ansible version 2.2 (other versions are not supported) + + - Configure subscription data (if used) + + If running against a RHEL Atomic Host, you should provide subscription + data that can be used by `subscription-manager`. See + [roles/redhat_subscription/tasks/main.yml](roles/redhat_subscription/tasks/main.yml) + for additional details. + + - Configure the required variables to your liking in [tests/atomic/vars.yml](tests/atomic/vars.yml). + +### Running the Playbook + +To run the test, simply invoke as any other Ansible playbook: + +``` +$ ansible-playbook -i inventory tests/atomic/main.yml +``` + +*NOTE*: You are responsible for providing a host to run the test against and the +inventory file for that host. diff --git a/tests/atomic/callback_plugins b/tests/atomic/callback_plugins new file mode 120000 index 0000000..15b4ae6 --- /dev/null +++ b/tests/atomic/callback_plugins @@ -0,0 +1 @@ +../../callback_plugins \ No newline at end of file diff --git a/tests/atomic/info.txt b/tests/atomic/info.txt new file mode 100644 index 0000000..605b233 --- /dev/null +++ b/tests/atomic/info.txt @@ -0,0 +1,9 @@ +Core Functionality +- atomic images delete +- atomic images list +- atomic images update +- atomic pull +- atomic push +- atomic containers list +- atomic containers delete + diff --git a/tests/atomic/main.yml b/tests/atomic/main.yml new file mode 100644 index 0000000..4aa42cc --- /dev/null +++ b/tests/atomic/main.yml @@ -0,0 +1,527 @@ +--- +# vim: set ft=ansible: +# +- name: Atomic - Setup + hosts: all + become: yes + + tags: + - setup + + vars_files: + - vars.yml + + roles: + # This playbook requires Ansible 2.2 and an Atomic Host + - role: ansible_version_check + avc_major: "2" + avc_minor: "2" + tags: + - ansible_version_check + + # Subscribe if the system is RHEL + - role: redhat_subscription + when: ansible_distribution == 'RedHat' + tags: + - redhat_subscription + +- name: Atomic Fully Qualified Name + hosts: all + become: yes + + tags: + - fq_name + + vars_files: + - vars.yml + + pre_tasks: + - name: Set cockpit container name for RHELAH + set_fact: + cockpit_cname: "registry.access.redhat.com/rhel7/cockpit-ws" + when: ansible_distribution == "RedHat" + + - name: Set cockpit container name for Fedora/CentOS + set_fact: + cockpit_cname: "registry.fedoraproject.org/f25/cockpit" + when: "'CentOS' in ansible_distribution or ansible_distribution == 'Fedora'" + + roles: + - role: atomic_pull + apl_image: "{{ cockpit_cname }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_cname }}" + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_cname }}" + expect_missing: true + + - role: atomic_install + ai_image: "{{ cockpit_cname }}" + + - role: atomic_run + ar_image: "{{ cockpit_cname }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_cname }}" + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_cname }}" + check_mode: false + + - role: atomic_stop + as_container: "{{ aclv_acl_jq_match['id'] }}" + + - role: atomic_containers_delete + acd_container: "{{ aclv_acl_jq_match['id'] }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_cname }}" + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_cname }}" + expect_missing: true + + - role: atomic_uninstall + au_image: "{{ cockpit_cname }}" + + - role: atomic_images_delete + aid_image: "{{ ailv_match['id'] }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_cname }}" + expect_missing: true + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_cname }}" + expect_missing: true + +- name: Atomic Short Name + hosts: all + become: yes + + tags: + - shortname + + vars_files: + - vars.yml + + pre_tasks: + - name: Set cockpit container name for RHELAH + set_fact: + cockpit_short_name: "rhel7/cockpit-ws" + cockpit_fq_name: "registry.access.redhat.com/rhel7/cockpit-ws" + when: ansible_distribution == "RedHat" + + - name: Set cockpit container name for Fedora/CentOS + set_fact: + cockpit_short_name: "cockpit/ws" + cockpit_fq_name: "docker.io/cockpit/ws" + when: "'CentOS' in ansible_distribution or ansible_distribution == 'Fedora'" + + roles: + - role: atomic_pull + apl_image: "{{ cockpit_short_name }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_fq_name }}" + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_short_name }}" + expect_missing: true + + - role: atomic_install + ai_image: "{{ cockpit_short_name }}" + + - role: atomic_run + ar_image: "{{ cockpit_short_name }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_fq_name }}" + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_short_name }}" + check_mode: false + + - role: atomic_stop + as_container: "{{ aclv_acl_jq_match['id'][:12] }}" + + - role: atomic_containers_delete + acd_container: "{{ aclv_acl_jq_match['id'][:12] }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_fq_name }}" + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_short_name }}" + expect_missing: true + + - role: atomic_uninstall + au_image: "{{ cockpit_short_name }}" + + - role: atomic_images_delete + aid_image: "{{ ailv_match['id'][:12] }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_fq_name }}" + expect_missing: true + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_short_name }}" + expect_missing: true + +- name: Atomic fully qualified container name + hosts: all + become: yes + + tags: + - fq_name_name + + vars_files: + - vars.yml + + pre_tasks: + - name: Set cockpit container name for RHELAH + set_fact: + cockpit_cname: "registry.access.redhat.com/rhel7/cockpit-ws" + when: ansible_distribution == "RedHat" + + - name: Set cockpit container name for Fedora/CentOS + set_fact: + cockpit_cname: "registry.fedoraproject.org/f25/cockpit" + when: "'CentOS' in ansible_distribution or ansible_distribution == 'Fedora'" + + - name: Set container name + set_fact: + cp_name: "cockpit" + + roles: + - role: atomic_pull + apl_image: "{{ cockpit_cname }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_cname }}" + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_cname }}" + expect_missing: true + + - role: atomic_install + ai_image: "{{ cockpit_cname }}" + ai_options: "--name={{ cp_name }}" + + - role: atomic_run + ar_image: "{{ cockpit_cname }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_cname }}" + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_cname }}" + check_mode: false + + - role: atomic_stop + as_container: "{{ aclv_acl_jq_match['id'] }}" + + - role: atomic_containers_delete + acd_container: "{{ aclv_acl_jq_match['id'] }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_cname }}" + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_cname }}" + expect_missing: true + + - role: atomic_uninstall + au_image: "{{ cockpit_cname }}" + + - role: atomic_images_delete + aid_image: "{{ ailv_match['id'] }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ cockpit_cname }}" + expect_missing: true + + - role: atomic_containers_list_verify + expected_values: + image_name: "{{ cockpit_cname }}" + expect_missing: true + +- name: Atomic Pull With Tags + hosts: all + become: yes + + tags: + - pull_tags + + vars_files: + - vars.yml + + pre_tasks: + - name: Set cockpit container name for RHELAH + set_fact: + fq_name: "docker.io/busybox" + short_name: "busybox" + tag: 1 + + roles: + - role: atomic_pull + apl_image: "{{ fq_name }}:{{ tag }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ fq_name }}" + tag: "1" + + - role: atomic_images_delete + aid_image: "{{ ailv_match['id'] }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ fq_name }}" + expect_missing: true + + - role: atomic_pull + apl_image: "{{ short_name }}:{{ tag }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ fq_name }}" + tag: "1" + + - role: atomic_images_delete + aid_image: "{{ ailv_match['id'] }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ fq_name }}" + expect_missing: true + +- name: Atomic Pull By Digest + hosts: all + become: yes + + tags: + - pull_digest_simple + + vars_files: + - vars.yml + + pre_tasks: + - name: Set image name + set_fact: + fq_name: "docker.io/busybox" + digest: "sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912" + + roles: + - name: atomic_pull + apl_image: "{{ fq_name }}@{{ digest }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ fq_name }}" + tag: "{{ digest|regex_replace('sha256:') }}" + + # Delete the image to return to a clean state + - role: atomic_images_delete + aid_image: "{{ ailv_match['id'] }}" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ fq_name }}" + expect_missing: true + +- name: Atomic Pull Storage + hosts: all + become: yes + + tags: + - pull_storage + + vars_files: + - vars.yml + + tasks: + - name: Set image name + set_fact: + fq_name: "docker.io/busybox" + + - name: Delete all images + include_role: + name: atomic_images_delete_all + + - name: Pull {{ fq_name }} using ostree + include_role: + name: atomic_pull + vars: + apl_image: "{{ fq_name }}" + apl_options: "--storage=ostree" + + # The TYPE field doesn't show up in the json output so + # we must check for ostree in the output of the command + - name: Fail if ostree storage not in atomic list output + command: atomic images list + register: ail_output + failed_when: > + fq_name not in ail_output.stdout and + "ostree" not in ail_output.stdout + + - name: Delete all images + include_role: + name: atomic_images_delete_all + + - include_role: + name: atomic_pull + vars: + apl_image: "{{ fq_name }}" + apl_options: "--storage=docker" + + # The TYPE field doesn't show up in the json output so + # we must check for ostree in the output of the command + - name: Fail if ostree storage not in atomic list output + command: atomic images list + register: ail_output + failed_when: > + fq_name not in ail_output.stdout and + "docker" not in ail_output.stdout + +- name: Atomic Images Update + hosts: all + become: yes + + tags: + - images_update + + vars_files: + - vars.yml + + pre_tasks: + - name: Set image name + set_fact: + fq_name: "docker.io/alpine" + local_name: "{{ ansible_docker0.ipv4.address}}:5000/alpine" + + # Testing images update is a bit tricky since in the docker world, tags don't + # follow any versioning--latest doesn't really mean latest. Docker and skopeo + # determine if there is an updated image based on the docker image layers. + # In order to test images update, this test uses a private registry and tag + # manipulation in order to commit and push new layers to the private registry + # then update the image. + + roles: + # Setup the private registry + - role: docker_private_registry + + # Pull the latest image + - role: atomic_pull + apl_image: "{{ fq_name }}:latest" + + # Re-tag the image to local name to push it to the private registry + - role: docker_tag + dt_image: "{{ fq_name }}:latest" + dt_tag: "{{ local_name }}:latest" + + # Push the image to the private registry + - role: atomic_push + apsh_image: "{{ local_name }}:latest" + apsh_options: "--anonymous --insecure" + + # Make a change to the original image and get the HOSTNAME to use to + # commit the change + - role: command + cmd: > + docker run docker.io/alpine:latest + bin/sh -c 'echo hello > /test && printenv HOSTNAME' + + # Commit the changes to the image + # Note: cmd_output comes from the command role above + - role: docker_commit + dc_commit: "{{ cmd_output.stdout }}" + dc_image: "{{ fq_name }}:latest" + + # Remove the locally tagged image so we can pull it again from the private + # registry + - role: docker_rmi + drmi_image: "{{ local_name }}:latest" + drmi_options: "-f" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ local_name }}" + tag: "latest" + expect_missing: True + + # Pull the image from the private registry + - role: atomic_pull + apl_image: "{{ local_name }}:latest" + + # Here is the tag manipulation. In order to push an update to the private + # registry, the new commited image must be tagged with the local name so it + # can be pushed to the private registry. The original image needs to be + # saved so it can be tagged back to latest and then get updated from the + # private registry. + - role: docker_tag + dt_image: "{{ local_name }}:latest" + dt_tag: "{{ local_name }}:latest-1" + + # The new commit image needs to be tagged with the private registry name + # so we can push the new layer + - role: docker_tag + dt_image: "{{ fq_name }}:latest" + dt_tag: "{{ local_name }}:latest" + + # Push the new commit to the private registry + - role: atomic_push + apsh_image: "{{ local_name }}:latest" + apsh_options: "--anonymous --insecure" + + # Remove the new commit image + - role: docker_rmi + drmi_image: "{{ local_name }}:latest" + drmi_options: "-f" + + - role: atomic_images_list_verify + expected_values: + repo: "{{ local_name }}" + tag: "latest" + expect_missing: true + + # Re-tag the original image back to latest. At this point, the registry + # contains the new layer image and the one locally is one commit behind. + # For some reason, the arguments passed to docker_tag get swapped only on + # this instance of the call. It only works if we pass the vars like this. + - role: docker_tag + vars: + dt_image: "{{ local_name }}:latest-1" + dt_tag: "{{ local_name }}:latest" + + # Now, the the atomic images update command checks the registry to see if + # there is a new image and updates it + - role: command + cmd: atomic images update {{ local_name }}:latest + output: "Writing manifest to image destination" diff --git a/tests/atomic/roles b/tests/atomic/roles new file mode 120000 index 0000000..148b132 --- /dev/null +++ b/tests/atomic/roles @@ -0,0 +1 @@ +../../roles/ \ No newline at end of file diff --git a/tests/atomic/vars.yml b/tests/atomic/vars.yml new file mode 100644 index 0000000..8f0140e --- /dev/null +++ b/tests/atomic/vars.yml @@ -0,0 +1,3 @@ +--- +g_container_name: etcd +g_container_fq_name: registry.access.redhat.com/rhel7/etcd From f17c869a1a17ed83b3163de88d6a3081c450a603 Mon Sep 17 00:00:00 2001 From: mnguyen Date: Wed, 15 Nov 2017 15:31:37 -0500 Subject: [PATCH 2/8] fixup! Add atomic CLI tests --- tests/atomic/main.yml | 73 ++++++------------------------------------- 1 file changed, 10 insertions(+), 63 deletions(-) diff --git a/tests/atomic/main.yml b/tests/atomic/main.yml index 4aa42cc..aa79b73 100644 --- a/tests/atomic/main.yml +++ b/tests/atomic/main.yml @@ -8,9 +8,6 @@ tags: - setup - vars_files: - - vars.yml - roles: # This playbook requires Ansible 2.2 and an Atomic Host - role: ansible_version_check @@ -33,18 +30,7 @@ - fq_name vars_files: - - vars.yml - - pre_tasks: - - name: Set cockpit container name for RHELAH - set_fact: - cockpit_cname: "registry.access.redhat.com/rhel7/cockpit-ws" - when: ansible_distribution == "RedHat" - - - name: Set cockpit container name for Fedora/CentOS - set_fact: - cockpit_cname: "registry.fedoraproject.org/f25/cockpit" - when: "'CentOS' in ansible_distribution or ansible_distribution == 'Fedora'" + - "{{ ansible_distribution|lower }}.yml" roles: - role: atomic_pull @@ -65,10 +51,6 @@ - role: atomic_run ar_image: "{{ cockpit_cname }}" - - role: atomic_images_list_verify - expected_values: - repo: "{{ cockpit_cname }}" - - role: atomic_containers_list_verify expected_values: image_name: "{{ cockpit_cname }}" @@ -113,20 +95,7 @@ - shortname vars_files: - - vars.yml - - pre_tasks: - - name: Set cockpit container name for RHELAH - set_fact: - cockpit_short_name: "rhel7/cockpit-ws" - cockpit_fq_name: "registry.access.redhat.com/rhel7/cockpit-ws" - when: ansible_distribution == "RedHat" - - - name: Set cockpit container name for Fedora/CentOS - set_fact: - cockpit_short_name: "cockpit/ws" - cockpit_fq_name: "docker.io/cockpit/ws" - when: "'CentOS' in ansible_distribution or ansible_distribution == 'Fedora'" + - "./{{ ansible_distribution|lower }}.yml" roles: - role: atomic_pull @@ -156,6 +125,9 @@ image_name: "{{ cockpit_short_name }}" check_mode: false + # aclv_acl_jq_match is the container entry that matches the image_name + # specified in the atomic_containers_list_verify role above. The + # shortened container id is used to stop and delete the container. - role: atomic_stop as_container: "{{ aclv_acl_jq_match['id'][:12] }}" @@ -195,22 +167,7 @@ - fq_name_name vars_files: - - vars.yml - - pre_tasks: - - name: Set cockpit container name for RHELAH - set_fact: - cockpit_cname: "registry.access.redhat.com/rhel7/cockpit-ws" - when: ansible_distribution == "RedHat" - - - name: Set cockpit container name for Fedora/CentOS - set_fact: - cockpit_cname: "registry.fedoraproject.org/f25/cockpit" - when: "'CentOS' in ansible_distribution or ansible_distribution == 'Fedora'" - - - name: Set container name - set_fact: - cp_name: "cockpit" + - "{{ ansible_distribution|lower }}.yml" roles: - role: atomic_pull @@ -279,9 +236,6 @@ tags: - pull_tags - vars_files: - - vars.yml - pre_tasks: - name: Set cockpit container name for RHELAH set_fact: @@ -329,9 +283,6 @@ tags: - pull_digest_simple - vars_files: - - vars.yml - pre_tasks: - name: Set image name set_fact: @@ -363,9 +314,6 @@ tags: - pull_storage - vars_files: - - vars.yml - tasks: - name: Set image name set_fact: @@ -382,7 +330,8 @@ apl_image: "{{ fq_name }}" apl_options: "--storage=ostree" - # The TYPE field doesn't show up in the json output so + # The TYPE field doesn't show up in the json output (see + # https://github.com/projectatomic/atomic/issues/1129) so # we must check for ostree in the output of the command - name: Fail if ostree storage not in atomic list output command: atomic images list @@ -401,7 +350,8 @@ apl_image: "{{ fq_name }}" apl_options: "--storage=docker" - # The TYPE field doesn't show up in the json output so + # The TYPE field doesn't show up in the json output (see + # https://github.com/projectatomic/atomic/issues/1129) so # we must check for ostree in the output of the command - name: Fail if ostree storage not in atomic list output command: atomic images list @@ -417,9 +367,6 @@ tags: - images_update - vars_files: - - vars.yml - pre_tasks: - name: Set image name set_fact: From 51de90fa1bcdcd95b7d5720a57a91f27d65aca88 Mon Sep 17 00:00:00 2001 From: mnguyen Date: Wed, 15 Nov 2017 15:49:39 -0500 Subject: [PATCH 3/8] fixup! Add atomic CLI tests --- tests/atomic/centos.yml | 5 +++++ tests/atomic/centosdev.yml | 5 +++++ tests/atomic/fedora.yml | 5 +++++ tests/atomic/redhat.yml | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 tests/atomic/centos.yml create mode 100644 tests/atomic/centosdev.yml create mode 100644 tests/atomic/fedora.yml create mode 100644 tests/atomic/redhat.yml diff --git a/tests/atomic/centos.yml b/tests/atomic/centos.yml new file mode 100644 index 0000000..98cc61f --- /dev/null +++ b/tests/atomic/centos.yml @@ -0,0 +1,5 @@ +--- +cockpit_short_name: "cockpit/ws" +cockpit_fq_name: "docker.io/cockpit/ws" +cockpit_cname: "registry.fedoraproject.org/f26/cockpit" +cp_name: "cockpit" diff --git a/tests/atomic/centosdev.yml b/tests/atomic/centosdev.yml new file mode 100644 index 0000000..98cc61f --- /dev/null +++ b/tests/atomic/centosdev.yml @@ -0,0 +1,5 @@ +--- +cockpit_short_name: "cockpit/ws" +cockpit_fq_name: "docker.io/cockpit/ws" +cockpit_cname: "registry.fedoraproject.org/f26/cockpit" +cp_name: "cockpit" diff --git a/tests/atomic/fedora.yml b/tests/atomic/fedora.yml new file mode 100644 index 0000000..98cc61f --- /dev/null +++ b/tests/atomic/fedora.yml @@ -0,0 +1,5 @@ +--- +cockpit_short_name: "cockpit/ws" +cockpit_fq_name: "docker.io/cockpit/ws" +cockpit_cname: "registry.fedoraproject.org/f26/cockpit" +cp_name: "cockpit" diff --git a/tests/atomic/redhat.yml b/tests/atomic/redhat.yml new file mode 100644 index 0000000..153e3d9 --- /dev/null +++ b/tests/atomic/redhat.yml @@ -0,0 +1,5 @@ +--- +cockpit_short_name: "rhel7/cockpit-ws" +cockpit_fq_name: "registry.access.redhat.com/rhel7/cockpit-ws" +cockpit_cname: "registry.access.redhat.com/rhel7/cockpit-ws" +cp_name: "cockpit" From 37a6a334d73dfa0a4c455e18eb76c88a291202f9 Mon Sep 17 00:00:00 2001 From: mnguyen Date: Mon, 20 Nov 2017 15:09:06 -0500 Subject: [PATCH 4/8] fixup! Add atomic CLI tests --- tests/atomic/main.yml | 2 +- tests/atomic/{ => vars}/centos.yml | 0 tests/atomic/{ => vars}/centosdev.yml | 0 tests/atomic/{ => vars}/fedora.yml | 0 tests/atomic/{ => vars}/redhat.yml | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename tests/atomic/{ => vars}/centos.yml (100%) rename tests/atomic/{ => vars}/centosdev.yml (100%) rename tests/atomic/{ => vars}/fedora.yml (100%) rename tests/atomic/{ => vars}/redhat.yml (100%) diff --git a/tests/atomic/main.yml b/tests/atomic/main.yml index aa79b73..5eae68d 100644 --- a/tests/atomic/main.yml +++ b/tests/atomic/main.yml @@ -237,7 +237,7 @@ - pull_tags pre_tasks: - - name: Set cockpit container name for RHELAH + - name: Set container name set_fact: fq_name: "docker.io/busybox" short_name: "busybox" diff --git a/tests/atomic/centos.yml b/tests/atomic/vars/centos.yml similarity index 100% rename from tests/atomic/centos.yml rename to tests/atomic/vars/centos.yml diff --git a/tests/atomic/centosdev.yml b/tests/atomic/vars/centosdev.yml similarity index 100% rename from tests/atomic/centosdev.yml rename to tests/atomic/vars/centosdev.yml diff --git a/tests/atomic/fedora.yml b/tests/atomic/vars/fedora.yml similarity index 100% rename from tests/atomic/fedora.yml rename to tests/atomic/vars/fedora.yml diff --git a/tests/atomic/redhat.yml b/tests/atomic/vars/redhat.yml similarity index 100% rename from tests/atomic/redhat.yml rename to tests/atomic/vars/redhat.yml From 5c685b9275bdf2a369ac27a76e83750032a6d6bb Mon Sep 17 00:00:00 2001 From: mnguyen Date: Mon, 20 Nov 2017 15:12:32 -0500 Subject: [PATCH 5/8] fixup! Add atomic CLI tests --- tests/atomic/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/atomic/main.yml b/tests/atomic/main.yml index 5eae68d..82033f1 100644 --- a/tests/atomic/main.yml +++ b/tests/atomic/main.yml @@ -30,7 +30,7 @@ - fq_name vars_files: - - "{{ ansible_distribution|lower }}.yml" + - "vars/{{ ansible_distribution|lower }}.yml" roles: - role: atomic_pull @@ -95,7 +95,7 @@ - shortname vars_files: - - "./{{ ansible_distribution|lower }}.yml" + - "vars/{{ ansible_distribution|lower }}.yml" roles: - role: atomic_pull @@ -167,7 +167,7 @@ - fq_name_name vars_files: - - "{{ ansible_distribution|lower }}.yml" + - "vars/{{ ansible_distribution|lower }}.yml" roles: - role: atomic_pull From d638c45f9678feea8eea5836dc60d67b78e8e73e Mon Sep 17 00:00:00 2001 From: mnguyen Date: Thu, 30 Nov 2017 15:22:04 -0500 Subject: [PATCH 6/8] fixup! Add atomic CLI tests --- roles/atomic_containers_list/tasks/main.yml | 2 +- roles/atomic_images_list/tasks/main.yml | 2 +- roles/docker_private_registry/tasks/main.yml | 14 +++++++++++++- roles/docker_rmi/tasks/main.yml | 2 +- roles/docker_tag/tasks/main.yml | 6 ------ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/roles/atomic_containers_list/tasks/main.yml b/roles/atomic_containers_list/tasks/main.yml index f271a24..d611239 100644 --- a/roles/atomic_containers_list/tasks/main.yml +++ b/roles/atomic_containers_list/tasks/main.yml @@ -9,4 +9,4 @@ - name: Save JSON to variable set_fact: - acl_json: "{{ acl.stdout | to_json | from_json }}" + acl_json: "{{ acl.stdout | from_json }}" diff --git a/roles/atomic_images_list/tasks/main.yml b/roles/atomic_images_list/tasks/main.yml index c8f261d..9fa8cac 100644 --- a/roles/atomic_images_list/tasks/main.yml +++ b/roles/atomic_images_list/tasks/main.yml @@ -13,4 +13,4 @@ - name: Save JSON to variable set_fact: - ail_json: "{{ ail.stdout | to_json | from_json }}" + ail_json: "{{ ail.stdout | from_json }}" diff --git a/roles/docker_private_registry/tasks/main.yml b/roles/docker_private_registry/tasks/main.yml index c2db1ba..d280259 100644 --- a/roles/docker_private_registry/tasks/main.yml +++ b/roles/docker_private_registry/tasks/main.yml @@ -14,13 +14,25 @@ path: /etc/containers/registries.conf register: reg + - name: Check for TOML formmated registries.conf + command: grep registries.search /etc/containers/registries.conf + register: toml + when: reg.stat.exists + + - name: add toml registeries + replace: + regexp: "\\[registries.insecure\\]\nregistries = \\[\\]" + replace: "[registries.insecure]\nregistries = ['{{ ansible_docker0.ipv4.address }}:5000']" + dest: /etc/containers/registries.conf + when: reg.stat.exists and toml.rc == 0 + - name: add registeries blockinfile: dest: /etc/containers/registries.conf block: | insecure_registries: - {{ ansible_docker0.ipv4.address }}:5000 - when: reg.stat.exists + when: reg.stat.exists and toml.rc == 1 - name: edit /etc/sysconfig/docker file to add private registry replace: diff --git a/roles/docker_rmi/tasks/main.yml b/roles/docker_rmi/tasks/main.yml index 7fe40cb..fc0c189 100644 --- a/roles/docker_rmi/tasks/main.yml +++ b/roles/docker_rmi/tasks/main.yml @@ -8,7 +8,7 @@ msg: "drmi_image is not defined" when: drmi_image is undefined -- name: Set optioins +- name: Set options set_fact: del_options: "{{ drmi_options | default() }}" diff --git a/roles/docker_tag/tasks/main.yml b/roles/docker_tag/tasks/main.yml index e1af242..5deb3e5 100644 --- a/roles/docker_tag/tasks/main.yml +++ b/roles/docker_tag/tasks/main.yml @@ -9,11 +9,5 @@ when: dt_image is undefined or dt_tag is undefined -- debug: - msg: "dt_img: {{ dt_image }}" - -- debug: - msg: "dt_tag: {{ dt_tag }}" - - name: Tag image command: docker tag {{ dt_image }} {{ dt_tag }} From 184d3cfabd7bf694eddbfc160b10c502df26eec8 Mon Sep 17 00:00:00 2001 From: mnguyen Date: Thu, 30 Nov 2017 15:31:13 -0500 Subject: [PATCH 7/8] fixup! Add atomic CLI tests --- roles/docker_private_registry/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/docker_private_registry/tasks/main.yml b/roles/docker_private_registry/tasks/main.yml index d280259..8e40c10 100644 --- a/roles/docker_private_registry/tasks/main.yml +++ b/roles/docker_private_registry/tasks/main.yml @@ -19,14 +19,14 @@ register: toml when: reg.stat.exists - - name: add toml registeries + - name: Add toml registries replace: regexp: "\\[registries.insecure\\]\nregistries = \\[\\]" replace: "[registries.insecure]\nregistries = ['{{ ansible_docker0.ipv4.address }}:5000']" dest: /etc/containers/registries.conf when: reg.stat.exists and toml.rc == 0 - - name: add registeries + - name: Add registries blockinfile: dest: /etc/containers/registries.conf block: | From 9d9990480c2c08bf355e02dbaccc30272bebfd19 Mon Sep 17 00:00:00 2001 From: mnguyen Date: Thu, 30 Nov 2017 16:08:04 -0500 Subject: [PATCH 8/8] fixup! Add atomic CLI tests --- roles/docker_private_registry/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/docker_private_registry/tasks/main.yml b/roles/docker_private_registry/tasks/main.yml index 8e40c10..ee2239e 100644 --- a/roles/docker_private_registry/tasks/main.yml +++ b/roles/docker_private_registry/tasks/main.yml @@ -18,6 +18,7 @@ command: grep registries.search /etc/containers/registries.conf register: toml when: reg.stat.exists + ignore_errors: true - name: Add toml registries replace: