[PATCH 01/10] devconfig: prevent ansible-lint no-free-form

Daniel Gomez <[email protected]>
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
From: Daniel Gomez <[email protected]>

Make sure ansible-lint no-free-form is not applied in devconfig tasks
where it will produce incorrect fixes. Adding # noqa: no-free-form
prevents the following from happening when running:

ansible-lint --fix=no-free-form \
    playbooks/roles/devconfig/tasks/main.yml

diff --git a/playbooks/roles/devconfig/tasks/main.yml
b/playbooks/roles/devconfig/tasks/main.yml
index 2ffa433f..a8c0f351 100644
--- a/playbooks/roles/devconfig/tasks/main.yml
+++ b/playbooks/roles/devconfig/tasks/main.yml
@@ -127,19 +127,28 @@

 - name: Check if the developer has a git config
   delegate_to: localhost
-  ansible.builtin.stat: path={{ dev_gitconfig_src }}
+  ansible.builtin.stat:
+    path: "{{"
+    cmd: dev_gitconfig_src }}
   run_once: true
   register: dev_git_config_file

Signed-off-by: Daniel Gomez <[email protected]>
---
 playbooks/roles/devconfig/tasks/main.yml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/playbooks/roles/devconfig/tasks/main.yml b/playbooks/roles/devconfig/tasks/main.yml
index ae16a698..6bd0c1f6 100644
--- a/playbooks/roles/devconfig/tasks/main.yml
+++ b/playbooks/roles/devconfig/tasks/main.yml
@@ -152,19 +152,19 @@
 
 - name: Check if the developer has a git config
   delegate_to: localhost
-  ansible.builtin.stat: path={{ dev_gitconfig_src }}
+  ansible.builtin.stat: path={{ dev_gitconfig_src }} # noqa: no-free-form
   run_once: true
   register: dev_git_config_file
 
 - name: Copy the developer's gitconfig *if* it exists
-  ansible.builtin.copy: src={{ dev_gitconfig_src }} dest={{ dev_gitconfig_dest }}
+  ansible.builtin.copy: src={{ dev_gitconfig_src }} dest={{ dev_gitconfig_dest }} # noqa: no-free-form
   when: dev_git_config_file.stat.exists
 
 - name: Copy the developer's gitconfig *if* it exists to root
   become: true
   become_flags: "su - -c"
   become_method: sudo
-  ansible.builtin.copy: src={{ dev_gitconfig_dest }} dest=/root/ remote_src=yes
+  ansible.builtin.copy: src={{ dev_gitconfig_dest }} dest=/root/ remote_src=yes # noqa: no-free-form
   when: dev_git_config_file.stat.exists
 
 - name: Check if the system has a user vimrc file
@@ -201,11 +201,11 @@
 
 - name: Check if the developer has a configuration file with favorite bash hacks
   delegate_to: localhost
-  ansible.builtin.stat: path={{ dev_bash_config_hacks_src }}
+  ansible.builtin.stat: path={{ dev_bash_config_hacks_src }} # noqa: no-free-form
   register: dev_bash_config_file
 
 - name: Copy the developer's favorite bash hacks over *if* it exists
-  ansible.builtin.copy: src={{ dev_bash_config_hacks_src }} dest={{ dev_bash_config_hacks_dest }}
+  ansible.builtin.copy: src={{ dev_bash_config_hacks_src }} dest={{ dev_bash_config_hacks_dest }} # noqa: no-free-form
   when: dev_bash_config_file.stat.exists
   register: dev_bash_config_file_copied
 
@@ -229,7 +229,7 @@
   become: true
   become_flags: "su - -c"
   become_method: sudo
-  ansible.builtin.copy: src={{ dev_bash_config_hacks_src }} dest=/root/
+  ansible.builtin.copy: src={{ dev_bash_config_hacks_src }} dest=/root/ # noqa: no-free-form
   when: dev_bash_config_file.stat.exists
   register: dev_bash_config_file_copied_root
 

-- 
2.50.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.