diff options
Diffstat (limited to 'ansible')
19 files changed, 110 insertions, 28 deletions
diff --git a/ansible/roles/application/tasks/transfer-helm-charts.yml b/ansible/roles/application/tasks/transfer-helm-charts.yml index 0cd7c02f..5e4240b6 100644 --- a/ansible/roles/application/tasks/transfer-helm-charts.yml +++ b/ansible/roles/application/tasks/transfer-helm-charts.yml @@ -40,5 +40,5 @@ dest: "{{ helm_home_dir.stdout }}/plugins" directory_mode: true mode: 0755 - with_items: "{{ list_of_plugins.files }}" + loop: "{{ list_of_plugins.files }}" when: app_helm_plugins_directory is defined and app_helm_plugins_directory is not none diff --git a/ansible/roles/nexus/tasks/insert-images.yml b/ansible/roles/nexus/tasks/insert-images.yml index 6c283330..404889f4 100644 --- a/ansible/roles/nexus/tasks/insert-images.yml +++ b/ansible/roles/nexus/tasks/insert-images.yml @@ -18,4 +18,4 @@ push: true load_path: "{{ item.path }}" timeout: 120 - changed_when: false # for idenpotence + changed_when: false # for idempotence diff --git a/ansible/roles/nexus/tasks/runtime-populate.yml b/ansible/roles/nexus/tasks/runtime-populate.yml index ac947ec7..2d90bf22 100644 --- a/ansible/roles/nexus/tasks/runtime-populate.yml +++ b/ansible/roles/nexus/tasks/runtime-populate.yml @@ -8,4 +8,4 @@ # WA: block of tasks cant be executed in iterations # need to iterate over those tasks in include - include: "insert-images.yml" - with_items: "{{ tar_images.files }}" + loop: "{{ tar_images.files }}" diff --git a/ansible/roles/nginx/.yamllint b/ansible/roles/nginx/.yamllint new file mode 100644 index 00000000..ad0be760 --- /dev/null +++ b/ansible/roles/nginx/.yamllint @@ -0,0 +1,11 @@ +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + truthy: disable diff --git a/ansible/roles/nginx/defaults/main.yml b/ansible/roles/nginx/defaults/main.yml index 260de9bf..8bf44197 100644 --- a/ansible/roles/nginx/defaults/main.yml +++ b/ansible/roles/nginx/defaults/main.yml @@ -4,7 +4,7 @@ simulated_hosts: http: nexus: all_simulated_hosts: - "{{ simulated_hosts.git + simulated_hosts.http + simulated_hosts.nexus }}" + "{{ simulated_hosts.git + simulated_hosts.http + simulated_hosts.nexus }}" nginx: ports: diff --git a/ansible/roles/nginx/molecule/default/cleanup.yml b/ansible/roles/nginx/molecule/default/cleanup.yml new file mode 100644 index 00000000..9870a553 --- /dev/null +++ b/ansible/roles/nginx/molecule/default/cleanup.yml @@ -0,0 +1,6 @@ +--- +- name: Cleanup + hosts: all + ignore_unreachable: true + roles: + - cleanup-nginx diff --git a/ansible/roles/nginx/molecule/default/molecule.yml b/ansible/roles/nginx/molecule/default/molecule.yml new file mode 100644 index 00000000..63c47724 --- /dev/null +++ b/ansible/roles/nginx/molecule/default/molecule.yml @@ -0,0 +1,30 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: infrastructure-server + image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6} + pre_build_image: true + privileged: true + override_command: false + volumes: + - /var/lib/docker + groups: + - infrastructure +provisioner: + name: ansible + env: + ANSIBLE_ROLES_PATH: ../../../../test/roles + inventory: + links: + group_vars: ../../../../group_vars + lint: + name: ansible-lint +verifier: + name: testinfra + lint: + name: flake8 diff --git a/ansible/roles/nginx/molecule/default/playbook.yml b/ansible/roles/nginx/molecule/default/playbook.yml new file mode 100644 index 00000000..431bb666 --- /dev/null +++ b/ansible/roles/nginx/molecule/default/playbook.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - nginx diff --git a/ansible/roles/nginx/molecule/default/prepare.yml b/ansible/roles/nginx/molecule/default/prepare.yml new file mode 100644 index 00000000..5c6ff5d8 --- /dev/null +++ b/ansible/roles/nginx/molecule/default/prepare.yml @@ -0,0 +1,8 @@ +--- +- name: Prepare + hosts: all + vars_files: + - ../../../../roles/nginx/defaults/main.yml + roles: + - prepare-docker-dind + - prepare-nginx diff --git a/ansible/roles/resource-data/tasks/unarchive-resource.yml b/ansible/roles/resource-data/tasks/unarchive-resource.yml index 9097ddc8..879a9dfe 100644 --- a/ansible/roles/resource-data/tasks/unarchive-resource.yml +++ b/ansible/roles/resource-data/tasks/unarchive-resource.yml @@ -1,11 +1,11 @@ --- # -# Wrapper to pass through following variables +# Wrapper to pass through following variables: # resources_source_host # resources_dir # resource_source_filename # resource_destination_directory -# And handling target directory creation and possible removal on failure. +# and handle target directory creation and eventual removal on failure. # Idempotence is also handled here as nothing is done if resource_destination_directory # was already created. # @@ -48,9 +48,12 @@ - name: "Cleanup the destination directory {{ resource_destination_directory }} on error" file: - path: "{{ item.path }}" + path: "{{ files_item.path }}" state: absent - with_items: "{{ files_after_fail.files | difference(original_files.files) }}" + loop: "{{ files_after_fail.files | difference(original_files.files) }}" + loop_control: + label: "{{ files_item.path }}" + loop_var: files_item when: files_after_fail is defined - name: "Report failure of upload operation" diff --git a/ansible/test/play-infrastructure/molecule/default/cleanup.yml b/ansible/test/play-infrastructure/molecule/default/cleanup.yml new file mode 100644 index 00000000..9870a553 --- /dev/null +++ b/ansible/test/play-infrastructure/molecule/default/cleanup.yml @@ -0,0 +1,6 @@ +--- +- name: Cleanup + hosts: all + ignore_unreachable: true + roles: + - cleanup-nginx diff --git a/ansible/test/play-resources/molecule/default/playbook.yml b/ansible/test/play-resources/molecule/default/playbook.yml index 50ba233a..096077a2 100644 --- a/ansible/test/play-resources/molecule/default/playbook.yml +++ b/ansible/test/play-resources/molecule/default/playbook.yml @@ -1,6 +1,8 @@ --- -- name: Test resource transfer with ssh +- name: Initialize hosts: all - roles: - - setup - - resource-data + tasks: + - name: Include variables + include_vars: vars.yml + +- import_playbook: ../../../../resources.yml diff --git a/ansible/test/play-resources/molecule/default/prepare.yml b/ansible/test/play-resources/molecule/default/prepare.yml index a4436001..5c8ae654 100644 --- a/ansible/test/play-resources/molecule/default/prepare.yml +++ b/ansible/test/play-resources/molecule/default/prepare.yml @@ -2,4 +2,7 @@ - name: Prepare resource-data hosts: all roles: + - setup - prepare-resource-data + vars_files: + - vars.yml diff --git a/ansible/test/play-resources/molecule/default/group_vars/all.yml b/ansible/test/play-resources/molecule/default/vars.yml index 558eacb2..46ab3e04 100644 --- a/ansible/test/play-resources/molecule/default/group_vars/all.yml +++ b/ansible/test/play-resources/molecule/default/vars.yml @@ -1,5 +1,5 @@ --- -app_data_path: /opt/myleculeapp +app_data_path: /opt/moleculeapp aux_data_path: "{{ app_data_path }}/runtime_images_source_dir" resources_dir: /data resources_filename: resources_package.tar diff --git a/ansible/test/play-resources/molecule/nfs/molecule.yml b/ansible/test/play-resources/molecule/nfs/molecule.yml index 9cff6b8d..11726396 100644 --- a/ansible/test/play-resources/molecule/nfs/molecule.yml +++ b/ansible/test/play-resources/molecule/nfs/molecule.yml @@ -32,13 +32,8 @@ platforms: - name: resource-data provisioner: name: ansible - playbooks: - cleanup: ../default/cleanup.yml env: ANSIBLE_ROLES_PATH: ../../../../roles:../../../roles - inventory: - links: - group_vars: ../default/group_vars lint: name: ansible-lint verifier: diff --git a/ansible/test/play-resources/molecule/nfs/playbook.yml b/ansible/test/play-resources/molecule/nfs/playbook.yml index 88440116..096077a2 100644 --- a/ansible/test/play-resources/molecule/nfs/playbook.yml +++ b/ansible/test/play-resources/molecule/nfs/playbook.yml @@ -1,8 +1,8 @@ --- -- name: Test resource transfer with nfs +- name: Initialize hosts: all - roles: - - setup - - role: resource-data - vars: - resources_on_nfs: true + tasks: + - name: Include variables + include_vars: vars.yml + +- import_playbook: ../../../../resources.yml diff --git a/ansible/test/play-resources/molecule/nfs/prepare.yml b/ansible/test/play-resources/molecule/nfs/prepare.yml index d381ba77..2276f2e8 100644 --- a/ansible/test/play-resources/molecule/nfs/prepare.yml +++ b/ansible/test/play-resources/molecule/nfs/prepare.yml @@ -1,7 +1,7 @@ --- -- name: Prepare resource-data +- name: Prepare hosts: all roles: - - role: prepare-resource-data - vars: - resources_on_nfs: true + - prepare-resource-data + vars_files: + - vars.yml diff --git a/ansible/test/play-resources/molecule/nfs/vars.yml b/ansible/test/play-resources/molecule/nfs/vars.yml new file mode 100644 index 00000000..2cc4d258 --- /dev/null +++ b/ansible/test/play-resources/molecule/nfs/vars.yml @@ -0,0 +1,7 @@ +--- +app_data_path: /opt/moleculeapp +aux_data_path: "{{ app_data_path }}/runtime_images_source_dir" +resources_on_nfs: true +resources_dir: /data +resources_filename: resources_package.tar +aux_resources_filename: aux_resources_package.tar diff --git a/ansible/test/roles/cleanup-nginx/tasks/main.yml b/ansible/test/roles/cleanup-nginx/tasks/main.yml new file mode 100644 index 00000000..94517519 --- /dev/null +++ b/ansible/test/roles/cleanup-nginx/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: Remove saved nginx docker image + delegate_to: localhost + file: + path: /tmp/nginx.tar + state: absent |