Groups
Groups
Sign in
Groups
Groups
Ansible Project
Conversations
About
Send feedback
Help
with_items and when
31 views
Skip to first unread message
Sudhir Kumar
unread,
Oct 25, 2017, 8:17:13 AM
10/25/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Hi,
Basically would like to check if file is present on remote system or not. If not present, then create one, otherwise skip this step.
- name: Checking if files already present
stat:
path: "{{ item }}"
register: file_path
with_items:
- /var/abc.key
- /var/xyz.key
- /var/spk.key
- name: Creating files
file:
path: "{{ item }}"
state: touch
owner: root
group: named
mode: 0644
with_items:
- /var/abc.key
- /var/xyz.key
- /var/spk.key
when: file_path.
stat.exists == False
Any ideas ?
Brian Coca
unread,
Oct 25, 2017, 9:33:18 AM
10/25/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
- copy: content=' ' dest={{item}} force=no
with_items:
- /var/abc.key
...
--
----------
Brian Coca
Sudhir Kumar
unread,
Oct 26, 2017, 6:21:47 AM
10/26/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Thanks Brian..
Reply all
Reply to author
Forward
0 new messages