...
 
Commits (2)
......@@ -14,7 +14,8 @@
fi ;
register: "source_result"
changed_when: false
failed_when: "{{source_result.rc}} != 0"
failed_when: "source_result.rc != 0"
- name: "Examine target file '{{target}}'"
raw:
if test -f "{{target}}" ;
......@@ -43,21 +44,23 @@
register: "target_result"
changed_when: false
failed_when: false
- name: "Copy source file to target file"
delegate_to: "localhost"
raw: |
scp "{{source}}" "{{inventory_hostname}}:{{target}}"
when: "{{target_result.rc}} == 2 or {{target_result.rc}} == 3"
when: "target_result.rc == 2 or target_result.rc == 3"
register: "result"
changed_when: "{{result.rc}} == 0"
failed_when: "{{result.rc}} != 0"
changed_when: "result.rc == 0"
failed_when: "result.rc != 0"
- name: "Set target file attributes"
raw: |
chmod "{{mode}}" "{{target}}" &&
chown "{{owner}}" "{{target}}" &&
chgrp "{{group}}" "{{target}}" ;
when: "{{target_result.rc}} == 1 or {{target_result.rc}} == 3"
when: "target_result.rc == 1 or target_result.rc == 3"
register: "result"
changed_when: "{{result.rc}} == 0"
failed_when: "{{result.rc}} != 0"
changed_when: "result.rc == 0"
failed_when: "result.rc != 0"
...
......@@ -5,6 +5,7 @@
register: "result"
changed_when: false
failed_when: "result.rc != 0"
- name: "{% if variable is defined %}\
Set '{{variable}}' and '{{variable}}_array' to standard output of command\
{% else %}\
......@@ -13,5 +14,5 @@ Set no variable\
set_fact:
"{{variable}}_array": "{{result.stdout_lines}}"
"{{variable}}": "{{result.stdout_lines[0]}}"
when: variable is defined
when: "variable is defined"
...
......@@ -32,18 +32,18 @@
- name: "Write to the target file '{{target}}'"
raw: |
printf "{{content}}" > "{{target}}"
when: "{{target_result.rc}} == 2 or {{target_result.rc}} == 3"
when: "target_result.rc == 2 or target_result.rc == 3"
register: "result"
changed_when: "{{result.rc}} == 0"
failed_when: "{{result.rc}} != 0"
changed_when: "result.rc == 0"
failed_when: "result.rc != 0"
- name: "Set the attributes of the target file '{{target}}'"
raw: |
chmod "{{mode}}" "{{target}}" &&
chown "{{owner}}" "{{target}}" &&
chgrp "{{group}}" "{{target}}" ;
when: "{{target_result.rc}} == 1 or {{target_result.rc}} == 3"
when: "target_result.rc == 1 or target_result.rc == 3"
register: "result"
changed_when: "{{result.rc}} == 0"
failed_when: "{{result.rc}} != 0"
changed_when: "result.rc == 0"
failed_when: "result.rc != 0"
...