From 9e1d3d6e62abf5d0da26a296bcd235f37a54d9c6 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 26 Mar 2018 10:23:13 +0100 Subject: xci: playbooks: Fixes various ansible-lint warnings In preparation for adding support for the 'ansible-lint' tool we fix various problems in our playbooks to make the tool happy before we make it mandatory. Some of the problems that are fixed here are - [ANSIBLE0011] All tasks should be named - [ANSIBLE0012] Commands should not change things if nothing needs doing - [ANSIBLE0013] Use shell only when shell functionality is required - [ANSIBLE0010] Package installs should not use latest installer-type:osa deploy-scenario:os-nosdn-nofeature Change-Id: I66c759d3932a414b81b2846393d2d98ce80c0b6d Signed-off-by: Markos Chandras --- xci/playbooks/roles/bootstrap-host/tasks/network.yml | 10 ++++++++-- xci/playbooks/roles/bootstrap-host/tasks/time.yml | 5 ++++- xci/playbooks/roles/configure-nfs/tasks/main.yml | 2 +- xci/playbooks/roles/prepare-functest/tasks/main.yml | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) (limited to 'xci/playbooks/roles') diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network.yml b/xci/playbooks/roles/bootstrap-host/tasks/network.yml index 01edf459..ea9060e6 100644 --- a/xci/playbooks/roles/bootstrap-host/tasks/network.yml +++ b/xci/playbooks/roles/bootstrap-host/tasks/network.yml @@ -37,7 +37,12 @@ name: 8021q state: present - name: ensure interfaces.d folder is empty - shell: "/bin/rm -rf /etc/network/interfaces.d/*" + file: + state: "{{ item }}" + path: "/etc/network/interfaces.d" + with_items: + - absent + - directory - name: ensure interfaces file is updated template: src: "{{ ansible_os_family | lower }}/{{ ansible_hostname }}.interface.j2" @@ -122,7 +127,8 @@ poll: 0 when: ansible_os_family | lower == "redhat" -- local_action: +- name: Wait for host to come back to life + local_action: module: wait_for host: "{{ ansible_host }}" delay: 15 diff --git a/xci/playbooks/roles/bootstrap-host/tasks/time.yml b/xci/playbooks/roles/bootstrap-host/tasks/time.yml index 4b3bf95a..9eca769d 100644 --- a/xci/playbooks/roles/bootstrap-host/tasks/time.yml +++ b/xci/playbooks/roles/bootstrap-host/tasks/time.yml @@ -10,13 +10,16 @@ - name: install chrony package: name: "chrony" - state: latest + state: present - name: restart chrony service: name: "{{ (ansible_pkg_mgr == 'apt') | ternary('chrony', 'chronyd') }}" state: restarted - name: synchronize time shell: "chronyc -a 'burst 4/4' && chronyc -a makestep" + args: + executable: /bin/bash + changed_when: True register: chrony_got_time until: chrony_got_time.rc == 0 retries: 5 diff --git a/xci/playbooks/roles/configure-nfs/tasks/main.yml b/xci/playbooks/roles/configure-nfs/tasks/main.yml index 25e81496..3b349ad6 100644 --- a/xci/playbooks/roles/configure-nfs/tasks/main.yml +++ b/xci/playbooks/roles/configure-nfs/tasks/main.yml @@ -47,7 +47,7 @@ - name: Install the NFS server package package: name: "{{ nfs_server_package }}" - state: latest + state: present - name: restart NFS service service: diff --git a/xci/playbooks/roles/prepare-functest/tasks/main.yml b/xci/playbooks/roles/prepare-functest/tasks/main.yml index 2797ce43..ad578bfd 100644 --- a/xci/playbooks/roles/prepare-functest/tasks/main.yml +++ b/xci/playbooks/roles/prepare-functest/tasks/main.yml @@ -30,9 +30,11 @@ shell: "ip a | grep {{ gateway_ip }}" register: gateway_ip_result ignore_errors: True + changed_when: False - name: add public network gateway command: "ip addr add {{ gateway_ip_mask }} brd {{ broadcast_ip }} dev {{ gateway_interface }}" + changed_when: False when: gateway_ip_result|failed - name: prepare environment file for functest -- cgit 1.2.3-korg