summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2019-06-04 12:47:20 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2019-06-04 12:47:20 +0200
commit76e017afde67940e80efeaec546c04bef2dadff2 (patch)
tree885df0233f8bf50b3e921b03dc318f4ef3442c43
parent8636d184d6c07df9ef74941a0d4343d61b95c5d4 (diff)
Replace 'with_items' loop statements with 'loop' keyword
As of Ansible 2.5 'loop' keyword is a recommended way for looping statements instead of 'with_dict'. Change-Id: I19e00cc27e13955e2056840fd4ce99841bc824ad Issue-ID: OOM-1887 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
-rw-r--r--ansible/roles/application/tasks/transfer-helm-charts.yml2
-rw-r--r--ansible/roles/nexus/tasks/insert-images.yml2
-rw-r--r--ansible/roles/nexus/tasks/runtime-populate.yml2
-rw-r--r--ansible/roles/resource-data/tasks/unarchive-resource.yml11
-rw-r--r--patches/onap-patch-role/tasks/main.yml8
5 files changed, 14 insertions, 11 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/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/patches/onap-patch-role/tasks/main.yml b/patches/onap-patch-role/tasks/main.yml
index fb81f200..38d0ab92 100644
--- a/patches/onap-patch-role/tasks/main.yml
+++ b/patches/onap-patch-role/tasks/main.yml
@@ -4,14 +4,14 @@
- name: Check presence of files for NPM patching
stat:
path: "{{ app_helm_charts_infra_directory }}/{{ item }}"
- with_items:
+ loop:
- common/dgbuilder/templates/deployment.yaml
register: npm_files_check
- name: Check presence of files for nexus domain resolving
stat:
path: "{{ app_helm_charts_infra_directory }}/{{ item }}"
- with_items:
+ loop:
- oof/charts/oof-cmso/charts/oof-cmso-service/resources/config/msosimulator.sh
register: hosts_files_check
@@ -22,7 +22,7 @@
line: '\g<1>npm set registry "http://nexus.{{ ansible_nodename }}/repository/npm-private/";'
backrefs: yes
state: present
- with_items: "{{ npm_files_check.results }}"
+ loop: "{{ npm_files_check.results }}"
when: item.stat.exists
- name: Patch OOM - nexus domain resolving
@@ -32,5 +32,5 @@
line: '\g<1>{{ cluster_ip }} {{ simulated_hosts.nexus | join(" ") }} >> /etc/hosts;'
backrefs: yes
state: present
- with_items: "{{ hosts_files_check.results }}"
+ loop: "{{ hosts_files_check.results }}"
when: item.stat.exists