Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

file related modules like file, template that have a mode parameter

ANSIBLE VERSION

ansible 2.3.1.0
config file = /home/kon/venvs/ansible-test/etc/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118]

CONFIGURATION

just an entry for the inventory path

OS / ENVIRONMENT

Linux ktsakiltzidis 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.2 (stretch)
Release:	9.2
Codename:	stretch

SUMMARY

using a loop that passes item in the mode parameter

results in chmod complaining with mode must be in octal or symbolic form

STEPS TO REPRODUCE

- hosts: localhost
tasks:
- name: test file mode
template:
src: testfile.j2
dest: ~/testing/ansible/testfile{{ item.index }}
mode: "{{ item.mode }}"
with_items:
- index: 0
mode: 0600
- index: 1
mode: 0640

EXPECTED RESULTS

no errors, right permissions

ACTUAL RESULTS

TASK [test apt package list] ***************************************************
failed: [localhost] (item={u'index': 0, u'mode': 384}) => {"details": "bad symbolic permission for mode: 384", "failed": true, "gid": 1000, "group": "kon", "item": {"index": 0, "mode": 384}, "mode": "0666", "msg": "mode must be in octal or symbolic form", "owner": "kon", "path": "/home/kon/testing/ansible/testfile0", "size": 0, "state": "file", "uid": 1000}
ok: [localhost] => (item={u'index': 1, u'mode': 416})

Issue 2:
ISSUE TYPE

Bug Report

Feature Idea

Documentation Report

COMPONENT NAME

ansible-playbook

ANSIBLE VERSION

ansible 2.3.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, May 3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)]

CONFIGURATION

host_key_checking = False

OS / ENVIRONMENT

Ansible control server: Red Hat Enterprise Linux Server release 7.4 (Maipo)

Node: Red Hat Enterprise Linux Server release 7.4 (Maipo)

SUMMARY

I have a variable that is a list. Within that list I have a a value called mount_mode set to 0755. When iterating through the list in a loop (with_items) the 0755 value gets interpreted as 493. The only work-around I found is to wrap the 0755 with single-quotes. If I place a variable outside of the list called mode with value 0755 and refer to it in the loop, the 0755 gets interpreted properly without single-quotes.

STEPS TO REPRODUCE

- hosts: servers
vars:
lvm_lvs:
- name: Data Volume
vg: vg_myvg1
lv: lv_data
size: 25g
mount: /data/mydata
mount_owner: root
mount_group: root
mount_mode: 0755
mount_dump: 1
mount_passno: 2
mount_opts: defaults
fstype: xfs
roles:
- { role: lvm }

#Set permissions on mount points
- name: Ensure mount point has desired permissions
file:
path: "{{ item.mount }}"
owner: "{{ item.mount_owner }}"
group: "{{ item.mount_group }}"
mode: "{{ item.mount_mode }}"
with_items: "{{ lvm_lvs }}"

EXPECTED RESULTS

{{ item.mount_mode }} should be interpreted as 0755, but instead it gets interpreted as 493.

ACTUAL RESULTS

TASK [lvm : Ensure mount point has desired permissions] ****************************************************************************************************************
task path: /home/TESTNET/ap574009/rhel5-eol/migrate_9306/roles/lvm/tasks/main.yml:40
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/file.py
<rhel5_test7> ESTABLISH SSH CONNECTION FOR USER: ap574009
<rhel5_test7> SSH: EXEC sshpass -d12 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=ap574009 -o ConnectTimeout=30 -o ControlPath=/home/TESTNET/ap574009/.ansible/cp/1049f838b2 rhel5_test7 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<rhel5_test7> (0, '/home/TESTNET/ap574009\n', 'OpenSSH_7.4p1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 1655\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<rhel5_test7> ESTABLISH SSH CONNECTION FOR USER: ap574009
<rhel5_test7> SSH: EXEC sshpass -d12 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=ap574009 -o ConnectTimeout=30 -o ControlPath=/home/TESTNET/ap574009/.ansible/cp/1049f838b2 rhel5_test7 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447 `" && echo ansible-tmp-1508446533.04-211671926774447="` echo /home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447 `" ) && sleep 0'"'"''
<rhel5_test7> (0, 'ansible-tmp-1508446533.04-211671926774447=/home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447\n', 'OpenSSH_7.4p1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 1655\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<rhel5_test7> PUT /tmp/tmptaK6vo TO /home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447/file.py
<rhel5_test7> SSH: EXEC sshpass -d12 sftp -o BatchMode=no -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=ap574009 -o ConnectTimeout=30 -o ControlPath=/home/TESTNET/ap574009/.ansible/cp/1049f838b2 '[rhel5_test7]'
<rhel5_test7> (0, 'sftp> put /tmp/tmptaK6vo /home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447/file.py\n', 'OpenSSH_7.4p1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 1655\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug2: Remote version: 3\r\ndebug2: Server supports extension "posix-rename@openssh.com" revision 1\r\ndebug2: Server supports extension "statvfs@openssh.com" revision 2\r\ndebug2: Server supports extension "fstatvfs@openssh.com" revision 2\r\ndebug2: Server supports extension "hardlink@openssh.com" revision 1\r\ndebug2: Server supports extension "fsync@openssh.com" revision 1\r\ndebug3: Sent message fd 6 T:16 I:1\r\ndebug3: SSH_FXP_REALPATH . -> /home/TESTNET/ap574009 size 0\r\ndebug3: Looking up /tmp/tmptaK6vo\r\ndebug3: Sent message fd 6 T:17 I:2\r\ndebug3: Received stat reply T:101 I:2\r\ndebug1: Couldn\'t stat remote file: No such file or directory\r\ndebug3: Sent message SSH2_FXP_OPEN I:3 P:/home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447/file.py\r\ndebug3: Sent message SSH2_FXP_WRITE I:4 O:0 S:32768\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 4 32768 bytes at 0\r\ndebug3: Sent message SSH2_FXP_WRITE I:5 O:32768 S:28758\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 5 28758 bytes at 32768\r\ndebug3: Sent message SSH2_FXP_CLOSE I:4\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<rhel5_test7> ESTABLISH SSH CONNECTION FOR USER: ap574009
<rhel5_test7> SSH: EXEC sshpass -d12 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=ap574009 -o ConnectTimeout=30 -o ControlPath=/home/TESTNET/ap574009/.ansible/cp/1049f838b2 rhel5_test7 '/bin/sh -c '"'"'chmod u+x /home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447/ /home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447/file.py && sleep 0'"'"''
<rhel5_test7> (0, '', 'OpenSSH_7.4p1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 1655\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<rhel5_test7> ESTABLISH SSH CONNECTION FOR USER: ap574009
<rhel5_test7> SSH: EXEC sshpass -d12 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=ap574009 -o ConnectTimeout=30 -o ControlPath=/home/TESTNET/ap574009/.ansible/cp/1049f838b2 -tt rhel5_test7 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-pxllydjcdclgergkezgvynrsosfwocjq; /usr/bin/python /home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447/file.py; rm -rf "/home/TESTNET/ap574009/.ansible/tmp/ansible-tmp-1508446533.04-211671926774447/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
<rhel5_test7> (0, '\r\n{"group": "root", "uid": 0, "mode": "0755", "failed": true, "state": "directory", "gid": 0, "secontext": "system_u:object_r:unlabeled_t:s0", "details": "bad symbolic permission for mode: 493", "invocation": {"module_args": {"directory_mode": null, "force": false, "remote_src": null, "path": "/data/mydata", "owner": "root", "follow": false, "group": "root", "unsafe_writes": null, "state": null, "content": null, "serole": null, "diff_peek": null, "setype": null, "selevel": null, "original_basename": null, "regexp": null, "validate": null, "src": null, "seuser": null, "recurse": false, "delimiter": null, "mode": "493", "attributes": null, "backup": null}}, "owner": "root", "path": "/data/mydata", "size": 6, "msg": "mode must be in octal or symbolic form"}\r\n', 'OpenSSH_7.4p1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 1655\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to rhel5_test7 closed.\r\n')
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/file.py
<rhel5_test7> ESTABLISH SSH CONNECTION FOR USER: ap574009
<rhel5_test7> SSH: EXEC sshpass -d12 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=ap574009 -o ConnectTimeout=30 -o ControlPath=/home/TESTNET/ap574009/.ansible/cp/1049f838b2 rhel5_test7 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
failed: [rhel5_test7] (item={u'name': u'Data Volume', u'vg': u'vg_myvg1', u'mount_group': u'root', u'mount': u'/data/mydata', u'fstype': u'xfs', u'lv': u'lv_data', u'mount_owner': u'root', u'mount_mode': 493, u'mount_dump': 1, u'mount_passno': 2, u'mount_opts': u'defaults', u'size': u'25g'}) => {
"details": "bad symbolic permission for mode: 493",
"failed": true,
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"content": null,
"delimiter": null,
"diff_peek": null,
"directory_mode": null,
"follow": false,
"force": false,
"group": "root",
"mode": "493",
"original_basename": null,
"owner": "root",
"path": "/data/mydata",
"recurse": false,
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"state": null,
"unsafe_writes": null,
"validate": null
}
},
"item": {
"fstype": "xfs",
"lv": "lv_data",
"mount": "/data/mydata",
"mount_dump": 1,
"mount_group": "root",
"mount_mode": 493,
"mount_opts": "defaults",
"mount_owner": "root",
"mount_passno": 2,
"name": "Data Volume",
"size": "25g",
"vg": "vg_myvg1"
},
"mode": "0755",
"msg": "mode must be in octal or symbolic form",
"owner": "root",
"path": "/data/mydata",
"secontext": "system_u:object_r:unlabeled_t:s0",
"size": 6,
"state": "directory",
"uid": 0
}