]> git.phdru.name Git - ansible.git/blobdiff - playbooks/debian/roles/root/tasks/mc.yml
Feat: Use module `stat` instead of command `test`
[ansible.git] / playbooks / debian / roles / root / tasks / mc.yml
index 655514aa69d4e9ff574f87e33014cdeafd6c557f..dbb78bad25e8639dc1a4e7d4f3e34284f15d6bdf 100644 (file)
@@ -1,13 +1,13 @@
 - name: "Setup root mc - check mc links"
   become: true
-  command: test -L ~root/.cache/mc -a -L ~root/.config/mc -a -L ~root/.local/share/mc
-  failed_when: false
+  stat:
+    path: "{{ item }}"
   register: links_exist
-  changed_when: links_exist.rc != 0
+  loop: ['~root/.cache/mc', '~root/.config/mc', '~root/.local/share/mc']
 
 - debug:
     msg: "mc links have already been created"
-  when: links_exist.rc == 0
+  when: links_exist.results|selectattr('stat.islnk')|list|length == 3
 
 - name: "Setup root mc - create directories for mc links"
   become: true
@@ -16,7 +16,7 @@
     state: directory
     mode: "0700"
   loop: ['.cache', '.config', '.local/share']
-  when: links_exist.rc != 0
+  when: links_exist.results|selectattr('stat.islnk')|list|length == 3
 
 - name: "Setup root mc - remove mc directories"
   become: true
@@ -24,7 +24,7 @@
     path: "~root/{{ item }}"
     state: absent
   loop: ['.cache/mc', '.config/mc', '.local/share/mc']
-  when: links_exist.rc != 0
+  when: links_exist.results|selectattr('stat.islnk')|list|length == 3
 
 - name: "Setup root mc - link mc directories (1)"
   become: true
@@ -34,7 +34,7 @@
     src: "../.mc"
     force: yes
   loop: ['.cache/mc', '.config/mc']
-  when: links_exist.rc != 0
+  when: links_exist.results|selectattr('stat.islnk')|list|length == 3
 
 - name: "Setup root mc - link mc directories (2)"
   become: true
@@ -44,7 +44,7 @@
     src: "../../.mc"
     force: yes
   loop: ['.local/share/mc']
-  when: links_exist.rc != 0
+  when: links_exist.results|selectattr('stat.islnk')|list|length == 3
 
 - name: "Setup root mc - overwrite files from ~phd/admin"
   become: true
@@ -57,4 +57,3 @@
     mode: "0600"
     force: yes
   loop: ['hotlist', 'ini', 'panels.ini']
-