When using the template module within a loop, my mode comes out all 
weird/wrong.  When using stand-alone it works:

- name: test
  template:
    src: "files/sssd.conf"
    dest: "/etc/sssd/sssd.conf"
    mode: 0600
    group: root
    owner: root

- name: Add/Update required files
  template:
    src: "{{item.src}}"
    dest: "{{item.dst}}"
    owner: root
    group: root
    mode: "{{item.mode}}"
  with_items:
    - {src: "files/sssd.conf",
       dst: "/etc/sssd/sssd.conf",
       mode: 0600}
    - {src: "files/krb5.conf",
       dst: "/etc/krb5.conf",
       mode: 0644}
    - {name: "dc1.cer",
       src: "files/dc1.cer",
       dst: "/etc/ssl/certs/dc1.cer",
       mode: 0644}
  notify: restart sssd


Results :
TASK [ldap_users : test] 
********************************************************************************************************************************************************************************************
changed: [ansibletest-oel6]


TASK [ldap_users : Add/Update required files] 
********************************************************************************************************************************************************************************************
failed: [ansibletest-oel6] (item={u'src': u'files/sssd.conf', u'dst': u
'/etc/sssd/sssd.conf', u'mode': 384}) => {"details": "bad symbolic 
permission for mode: 384", "failed": true, "gid": 0, "group": "root", "item"
: {"dst": "/etc/sssd/sssd.conf", "mode": 384, "src": "files/sssd.conf"}, 
"mode": "0416", "msg": "mode must be in octal or symbolic form", "owner": 
"root", "path": "/etc/sssd/sssd.conf", "size": 1445, "state": "file", "uid": 
0}
ok: [ansibletest-oel6] => (item={u'src': u'files/krb5.conf', u'dst': u
'/etc/krb5.conf', u'mode': 420})
ok: [ansibletest-oel6] => (item={u'src': u'files/dc1.cer', u'dst': u
'/etc/ssl/certs/dc1.cer', u'name': u'dc1.cer', u'mode': 420})

As you can see from the above, the test works (confirmed that the mode is 
truly 0600 on the target server).  From the second part of the results, you 
can see that it is trying to tweak the mode different than the test.  The 
first one it bombs on (mode 0600) and the second two (0644) it changes to 
420.... like a umask is being applied.

Is this a bug? or am I doing something wrong?

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9d67bcc1-bdbc-49fe-abca-b1294e2070df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to