On 27. juni 2016 20:09, Oscar Hodgson wrote:

Ansible 2.2.0

Copy module documentation says, "Options / force: the default is yes, which
will replace the remote file when contents are different than the source.
If no, the file will only be transferred if the destination does not exist."

A sample playbook:

---

- hosts: localhost

   tasks:
     - file:
         dest: "{{ item }}"
         state: absent
       with_items:
         - /tmp/passwd
         - /tmp/ntp.conf

     - copy:
         src: "{{ item.src }}"
         dest: /tmp
         force: "{{ item.force }}"
       with_items:
         - { src: /etc/passwd, force: yes }
         - { src: /etc/ntp.conf, force: no }

     - command: 'ls /tmp/passwd /tmp/ntp.conf'

The documentation leads me to believe that /tmp/ntp.conf should be present
at the end of this play.  Am I missing something?

If you run ansible-playbook with -v you'll see this message
  "dest": "/tmp",
  "msg": "file already exists",

So the destination /tmp do exist and the ntp.conf is not created.
If you set the "dest: /tmp/" (trailing slash) and you run ansible-playbook with -v you get this
  "dest": "/tmp/ntp.conf"
and it work as you expected.

If it's a feature or a bug I don't know, I guess it's a feature.

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/57718703.7090906%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to