From 414053634d145436e383224b689d7b76e09749ba Mon Sep 17 00:00:00 2001 From: Riccardo Pittau Date: Tue, 25 Aug 2020 15:03:13 +0200 Subject: [PATCH] ansible-lint: fix error 504 Do not use 'local_action', use 'delegate_to: localhost' Change-Id: I6c91afca04544e9b2b11b563cf43d5048c13cc67 --- .ansible-lint | 1 - .../tasks/ssh_public_key_path.yaml | 8 ++++++-- .../bifrost-ironic-install/tasks/set_ssh_private_key.yml | 8 ++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index e8541068c..c4ca66662 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -3,7 +3,6 @@ skip_list: - '208' # File permissions not mentioned - '301' # Commands should not change things if nothing needs doing - '502' # All tasks should be named - - '504' # Do not use 'local_action', use 'delegate_to: localhost' - '601' # Don't compare to literal True/False - '602' # Don't compare to empty string - '701' # meta/main.yml should contain relevant info diff --git a/playbooks/roles/bifrost-configdrives-dynamic/tasks/ssh_public_key_path.yaml b/playbooks/roles/bifrost-configdrives-dynamic/tasks/ssh_public_key_path.yaml index 781e05b58..559ee0f72 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/tasks/ssh_public_key_path.yaml +++ b/playbooks/roles/bifrost-configdrives-dynamic/tasks/ssh_public_key_path.yaml @@ -13,13 +13,17 @@ # limitations under the License. --- - name: "Defined ssh_public_key_path - Check to see if there is a file where the ssh_public_key_path is defined" - local_action: stat path={{ ssh_public_key_path }} + stat: + path: "{{ ssh_public_key_path }}" register: test_ssh_public_key_path when: ssh_public_key_path is defined + delegate_to: localhost - name: "Defined ssh_public_key_path - Error if ssh_public_key_path is not valid" - local_action: fail msg="ssh_public_key_path is not valid." + fail: + msg: "ssh_public_key_path is not valid." when: test_ssh_public_key_path.stat.exists == false + delegate_to: localhost - name: "Defined ssh_public_key_path - Read SSH public key in" set_fact: ssh_public_key="{{ lookup('file', ssh_public_key_path ) }}" diff --git a/playbooks/roles/bifrost-ironic-install/tasks/set_ssh_private_key.yml b/playbooks/roles/bifrost-ironic-install/tasks/set_ssh_private_key.yml index 959d3a4ce..989c88695 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/set_ssh_private_key.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/set_ssh_private_key.yml @@ -1,11 +1,15 @@ --- - name: "Defined ssh_private_key_path - Check to see if there is a file where the ssh_private_key_path is defined" - local_action: stat path={{ ssh_private_key_path }} + stat: + path: "{{ ssh_private_key_path }}" register: test_ssh_private_key_path + delegate_to: localhost - name: "Defined ssh_private_key_path - Error if ssh_private_key_path is not valid" - local_action: fail msg="ssh_private_key_path is not valid." + fail: + msg: "ssh_private_key_path is not valid." when: test_ssh_private_key_path.stat.exists == false + delegate_to: localhost - name: "Defined ssh_private_key_path - Read SSH private key in" set_fact: ssh_private_key="{{ lookup('file', ssh_private_key_path ) }}"