status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
try:
mode = self._symbolic_mode_to_octal(path_stat, mode)
except Exception as e:
path = to_text(b_path)
self.fail_json(path=path,
msg="mode must be in octal or symbolic form",
details=to_native(e))
if mode != stat.S_IMODE(mode):
path = to_text(b_path)
self.fail_json(path=path, msg="Invalid mode supplied, only permission info is allowed", details=mode)
prev_mode = stat.S_IMODE(path_stat.st_mode)
if prev_mode != mode:
if diff is not None:
if 'before' not in diff:
diff['before'] = {}
diff['before']['mode'] = '0%03o' % prev_mode
if 'after' not in diff:
diff['after'] = {}
diff['after']['mode'] = '0%03o' % mode
if self.check_mode:
return True
try:
if hasattr(os, 'lchmod'):
os.lchmod(b_path, mode)
else:
if not os.path.islink(b_path):
os.chmod(b_path, mode)
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
else:
underlying_stat = os.stat(b_path)
os.chmod(b_path, mode)
new_underlying_stat = os.stat(b_path)
if underlying_stat.st_mode != new_underlying_stat.st_mode:
os.chmod(b_path, stat.S_IMODE(underlying_stat.st_mode))
except OSError as e:
if os.path.islink(b_path) and e.errno in (
errno.EACCES,
errno.EPERM,
errno.EROFS,
):
pass
elif e.errno in (errno.ENOENT, errno.ELOOP):
pass
else:
raise
except Exception as e:
path = to_text(b_path)
self.fail_json(path=path, msg='chmod failed', details=to_native(e),
exception=traceback.format_exc())
path_stat = os.lstat(b_path)
new_mode = stat.S_IMODE(path_stat.st_mode)
if new_mode != prev_mode:
changed = True
return changed
def set_attributes_if_different(self, path, attributes, changed, diff=None, expand=True):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
if attributes is None:
return changed
b_path = to_bytes(path, errors='surrogate_or_strict')
if expand:
b_path = os.path.expanduser(os.path.expandvars(b_path))
if self.check_file_absent_if_check_mode(b_path):
return True
existing = self.get_file_attributes(b_path, include_version=False)
attr_mod = '='
if attributes.startswith(('-', '+')):
attr_mod = attributes[0]
attributes = attributes[1:]
if existing.get('attr_flags', '') != attributes or attr_mod == '-':
attrcmd = self.get_bin_path('chattr')
if attrcmd:
attrcmd = [attrcmd, '%s%s' % (attr_mod, attributes), b_path]
changed = True
if diff is not None:
if 'before' not in diff:
diff['before'] = {}
diff['before']['attributes'] = existing.get('attr_flags')
if 'after' not in diff:
diff['after'] = {}
diff['after']['attributes'] = '%s%s' % (attr_mod, attributes)
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
if not self.check_mode:
try:
rc, out, err = self.run_command(attrcmd)
if rc != 0 or err:
raise Exception("Error while setting attributes: %s" % (out + err))
except Exception as e:
self.fail_json(path=to_text(b_path), msg='chattr failed',
details=to_native(e), exception=traceback.format_exc())
return changed
def get_file_attributes(self, path, include_version=True):
output = {}
attrcmd = self.get_bin_path('lsattr', False)
if attrcmd:
flags = '-vd' if include_version else '-d'
attrcmd = [attrcmd, flags, path]
try:
rc, out, err = self.run_command(attrcmd)
if rc == 0:
res = out.split()
attr_flags_idx = 0
if include_version:
attr_flags_idx = 1
output['version'] = res[0].strip()
output['attr_flags'] = res[attr_flags_idx].replace('-', '').strip()
output['attributes'] = format_attributes(output['attr_flags'])
except Exception:
pass
return output
@classmethod
def _symbolic_mode_to_octal(cls, path_stat, symbolic_mode):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
"""
This enables symbolic chmod string parsing as stated in the chmod man-page
This includes things like: "u=rw-x+X,g=r-x+X,o=r-x+X"
"""
new_mode = stat.S_IMODE(path_stat.st_mode)
for mode in symbolic_mode.split(','):
permlist = MODE_OPERATOR_RE.split(mode)
opers = MODE_OPERATOR_RE.findall(mode)
users = permlist.pop(0)
use_umask = (users == '')
if users == 'a' or users == '':
users = 'ugo'
if not USERS_RE.match(users):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
raise ValueError("bad symbolic permission for mode: %s" % mode)
for idx, perms in enumerate(permlist):
if not PERMS_RE.match(perms):
raise ValueError("bad symbolic permission for mode: %s" % mode)
for user in users:
mode_to_apply = cls._get_octal_mode_from_symbolic_perms(path_stat, user, perms, use_umask, new_mode)
new_mode = cls._apply_operation_to_mode(user, opers[idx], mode_to_apply, new_mode)
return new_mode
@staticmethod
def _apply_operation_to_mode(user, operator, mode_to_apply, current_mode):
if operator == '=':
if user == 'u':
mask = stat.S_IRWXU | stat.S_ISUID
elif user == 'g':
mask = stat.S_IRWXG | stat.S_ISGID
elif user == 'o':
mask = stat.S_IRWXO | stat.S_ISVTX
inverse_mask = mask ^ PERM_BITS
new_mode = (current_mode & inverse_mask) | mode_to_apply
elif operator == '+':
new_mode = current_mode | mode_to_apply
elif operator == '-':
new_mode = current_mode - (current_mode & mode_to_apply)
return new_mode
@staticmethod
def _get_octal_mode_from_symbolic_perms(path_stat, user, perms, use_umask, prev_mode=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
if prev_mode is None:
prev_mode = stat.S_IMODE(path_stat.st_mode)
is_directory = stat.S_ISDIR(path_stat.st_mode)
has_x_permissions = (prev_mode & EXEC_PERM_BITS) > 0
apply_X_permission = is_directory or has_x_permissions
umask = os.umask(0)
os.umask(umask)
rev_umask = umask ^ PERM_BITS
if apply_X_permission:
X_perms = {
'u': {'X': stat.S_IXUSR},
'g': {'X': stat.S_IXGRP},
'o': {'X': stat.S_IXOTH},
}
else:
X_perms = {
'u': {'X': 0},
'g': {'X': 0},
'o': {'X': 0},
}
user_perms_to_modes = {
'u': {
'r': rev_umask & stat.S_IRUSR if use_umask else stat.S_IRUSR,
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
'w': rev_umask & stat.S_IWUSR if use_umask else stat.S_IWUSR,
'x': rev_umask & stat.S_IXUSR if use_umask else stat.S_IXUSR,
's': stat.S_ISUID,
't': 0,
'u': prev_mode & stat.S_IRWXU,
'g': (prev_mode & stat.S_IRWXG) << 3,
'o': (prev_mode & stat.S_IRWXO) << 6},
'g': {
'r': rev_umask & stat.S_IRGRP if use_umask else stat.S_IRGRP,
'w': rev_umask & stat.S_IWGRP if use_umask else stat.S_IWGRP,
'x': rev_umask & stat.S_IXGRP if use_umask else stat.S_IXGRP,
's': stat.S_ISGID,
't': 0,
'u': (prev_mode & stat.S_IRWXU) >> 3,
'g': prev_mode & stat.S_IRWXG,
'o': (prev_mode & stat.S_IRWXO) << 3},
'o': {
'r': rev_umask & stat.S_IROTH if use_umask else stat.S_IROTH,
'w': rev_umask & stat.S_IWOTH if use_umask else stat.S_IWOTH,
'x': rev_umask & stat.S_IXOTH if use_umask else stat.S_IXOTH,
's': 0,
't': stat.S_ISVTX,
'u': (prev_mode & stat.S_IRWXU) >> 6,
'g': (prev_mode & stat.S_IRWXG) >> 3,
'o': prev_mode & stat.S_IRWXO},
}
for key, value in X_perms.items():
user_perms_to_modes[key].update(value)
def or_reduce(mode, perm):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
return mode | user_perms_to_modes[user][perm]
return reduce(or_reduce, perms, 0)
def set_fs_attributes_if_different(self, file_args, changed, diff=None, expand=True):
changed = self.set_context_if_different(
file_args['path'], file_args['secontext'], changed, diff
)
changed = self.set_owner_if_different(
file_args['path'], file_args['owner'], changed, diff, expand
)
changed = self.set_group_if_different(
file_args['path'], file_args['group'], changed, diff, expand
)
changed = self.set_mode_if_different(
file_args['path'], file_args['mode'], changed, diff, expand
)
changed = self.set_attributes_if_different(
file_args['path'], file_args['attributes'], changed, diff, expand
)
return changed
def check_file_absent_if_check_mode(self, file_path):
return self.check_mode and not os.path.exists(file_path)
def set_directory_attributes_if_different(self, file_args, changed, diff=None, expand=True):
return self.set_fs_attributes_if_different(file_args, changed, diff, expand)
def set_file_attributes_if_different(self, file_args, changed, diff=None, expand=True):
return self.set_fs_attributes_if_different(file_args, changed, diff, expand)
def add_path_info(self, kwargs):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
'''
for results that are files, supplement the info about the file
in the return path with stats about the file path.
'''
path = kwargs.get('path', kwargs.get('dest', None))
if path is None:
return kwargs
b_path = to_bytes(path, errors='surrogate_or_strict')
if os.path.exists(b_path):
(uid, gid) = self.user_and_group(path)
kwargs['uid'] = uid
kwargs['gid'] = gid
try:
user = pwd.getpwuid(uid)[0]
except KeyError:
user = str(uid)
try:
group = grp.getgrgid(gid)[0]
except KeyError:
group = str(gid)
kwargs['owner'] = user
kwargs['group'] = group
st = os.lstat(b_path)
kwargs['mode'] = '0%03o' % stat.S_IMODE(st[stat.ST_MODE])
if os.path.islink(b_path):
kwargs['state'] = 'link'
elif os.path.isdir(b_path):
kwargs['state'] = 'directory'
elif os.stat(b_path).st_nlink > 1:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
kwargs['state'] = 'hard'
else:
kwargs['state'] = 'file'
if self.selinux_enabled():
kwargs['secontext'] = ':'.join(self.selinux_context(path))
kwargs['size'] = st[stat.ST_SIZE]
return kwargs
def _check_locale(self):
'''
Uses the locale module to test the currently set locale
(per the LANG and LC_CTYPE environment settings)
'''
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error:
best_locale = get_best_parsable_locale(self)
locale.setlocale(locale.LC_ALL, best_locale)
os.environ['LANG'] = best_locale
os.environ['LC_ALL'] = best_locale
os.environ['LC_MESSAGES'] = best_locale
except Exception as e:
self.fail_json(msg="An unknown error was encountered while attempting to validate the locale: %s" %
to_native(e), exception=traceback.format_exc())
def _set_internal_properties(self, argument_spec=None, module_parameters=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
if argument_spec is None:
argument_spec = self.argument_spec
if module_parameters is None:
module_parameters = self.params
for k in PASS_VARS:
param_key = '_ansible_%s' % k
if param_key in module_parameters:
if k in PASS_BOOLS:
setattr(self, PASS_VARS[k][0], self.boolean(module_parameters[param_key]))
else:
setattr(self, PASS_VARS[k][0], module_parameters[param_key])
if param_key in self.params:
del self.params[param_key]
else:
if not hasattr(self, PASS_VARS[k][0]):
setattr(self, PASS_VARS[k][0], PASS_VARS[k][1])
def safe_eval(self, value, locals=None, include_exceptions=False):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
return safe_eval(value, locals, include_exceptions)
def _load_params(self):
''' read the input and set the params attribute.
This method is for backwards compatibility. The guts of the function
were moved out in 2.1 so that custom modules could read the parameters.
'''
self.params = _load_params()
def _log_to_syslog(self, msg):
if HAS_SYSLOG:
try:
module = 'ansible-%s' % self._name
facility = getattr(syslog, self._syslog_facility, syslog.LOG_USER)
syslog.openlog(str(module), 0, facility)
syslog.syslog(syslog.LOG_INFO, msg)
except (TypeError, ValueError) as e:
self.fail_json(
msg='Failed to log to syslog (%s). To proceed anyway, '
'disable syslog logging by setting no_target_syslog '
'to True in your Ansible config.' % to_native(e),
exception=traceback.format_exc(),
msg_to_log=msg,
)
def debug(self, msg):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
if self._debug:
self.log('[debug] %s' % msg)
def log(self, msg, log_args=None):
if not self.no_log:
if log_args is None:
log_args = dict()
module = 'ansible-%s' % self._name
if isinstance(module, binary_type):
module = module.decode('utf-8', 'replace')
if not isinstance(msg, (binary_type, text_type)):
raise TypeError("msg should be a string (got %s)" % type(msg))
if isinstance(msg, binary_type):
journal_msg = msg.decode('utf-8', 'replace')
else:
journal_msg = msg
if self._target_log_info:
journal_msg = ' '.join([self._target_log_info, journal_msg])
journal_msg = remove_values(journal_msg, self.no_log_values)
if PY3:
syslog_msg = journal_msg
else:
syslog_msg = journal_msg.encode('utf-8', 'replace')
if has_journal:
journal_args = [("MODULE", os.path.basename(__file__))]
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
for arg in log_args:
name, value = (arg.upper(), str(log_args[arg]))
if name in (
'PRIORITY', 'MESSAGE', 'MESSAGE_ID',
'CODE_FILE', 'CODE_LINE', 'CODE_FUNC',
'SYSLOG_FACILITY', 'SYSLOG_IDENTIFIER',
'SYSLOG_PID',
):
name = "_%s" % name
journal_args.append((name, value))
try:
if HAS_SYSLOG:
facility = getattr(syslog,
self._syslog_facility,
syslog.LOG_USER) >> 3
journal.send(MESSAGE=u"%s %s" % (module, journal_msg),
SYSLOG_FACILITY=facility,
**dict(journal_args))
else:
journal.send(MESSAGE=u"%s %s" % (module, journal_msg),
**dict(journal_args))
except IOError:
self._log_to_syslog(syslog_msg)
else:
self._log_to_syslog(syslog_msg)
def _log_invocation(self):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
''' log that ansible ran the module '''
log_args = dict()
for param in self.params:
canon = self.aliases.get(param, param)
arg_opts = self.argument_spec.get(canon, {})
no_log = arg_opts.get('no_log', None)
if no_log is None and PASSWORD_MATCH.search(param):
log_args[param] = 'NOT_LOGGING_PASSWORD'
self.warn('Module did not set no_log for %s' % param)
elif self.boolean(no_log):
log_args[param] = 'NOT_LOGGING_PARAMETER'
else:
param_val = self.params[param]
if not isinstance(param_val, (text_type, binary_type)):
param_val = str(param_val)
elif isinstance(param_val, text_type):
param_val = param_val.encode('utf-8')
log_args[param] = heuristic_log_sanitize(param_val, self.no_log_values)
msg = ['%s=%s' % (to_native(arg), to_native(val)) for arg, val in log_args.items()]
if msg:
msg = 'Invoked with %s' % ' '.join(msg)
else:
msg = 'Invoked'
self.log(msg, log_args=log_args)
def _set_cwd(self):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
try:
cwd = os.getcwd()
if not os.access(cwd, os.F_OK | os.R_OK):
raise Exception()
return cwd
except Exception:
for cwd in [self.tmpdir, os.path.expandvars('$HOME'), tempfile.gettempdir()]:
try:
if os.access(cwd, os.F_OK | os.R_OK):
os.chdir(cwd)
return cwd
except Exception:
pass
return None
def get_bin_path(self, arg, required=False, opt_dirs=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
'''
Find system executable in PATH.
:param arg: The executable to find.
:param required: if executable is not found and required is ``True``, fail_json
:param opt_dirs: optional list of directories to search in addition to ``PATH``
:returns: if found return full path; otherwise return None
'''
bin_path = None
try:
bin_path = get_bin_path(arg=arg, opt_dirs=opt_dirs)
except ValueError as e:
if required:
self.fail_json(msg=to_text(e))
else:
return bin_path
return bin_path
def boolean(self, arg):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
'''Convert the argument to a boolean'''
if arg is None:
return arg
try:
return boolean(arg)
except TypeError as e:
self.fail_json(msg=to_native(e))
def jsonify(self, data):
try:
return jsonify(data)
except UnicodeError as e:
self.fail_json(msg=to_text(e))
def from_json(self, data):
return json.loads(data)
def add_cleanup_file(self, path):
if path not in self.cleanup_files:
self.cleanup_files.append(path)
def do_cleanup_files(self):
for path in self.cleanup_files:
self.cleanup(path)
def _return_formatted(self, kwargs):
self.add_path_info(kwargs)
if 'invocation' not in kwargs:
kwargs['invocation'] = {'module_args': self.params}
if 'warnings' in kwargs:
if isinstance(kwargs['warnings'], list):
for w in kwargs['warnings']:
self.warn(w)
else:
self.warn(kwargs['warnings'])
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
warnings = get_warning_messages()
if warnings:
kwargs['warnings'] = warnings
if 'deprecations' in kwargs:
if isinstance(kwargs['deprecations'], list):
for d in kwargs['deprecations']:
if isinstance(d, SEQUENCETYPE) and len(d) == 2:
self.deprecate(d[0], version=d[1])
elif isinstance(d, Mapping):
self.deprecate(d['msg'], version=d.get('version'), date=d.get('date'),
collection_name=d.get('collection_name'))
else:
self.deprecate(d)
else:
self.deprecate(kwargs['deprecations'])
deprecations = get_deprecation_messages()
if deprecations:
kwargs['deprecations'] = deprecations
preserved = {}
for k, v in kwargs.items():
if v is None or isinstance(v, bool):
preserved[k] = v
kwargs = remove_values(kwargs, self.no_log_values)
kwargs.update(preserved)
print('\n%s' % self.jsonify(kwargs))
def exit_json(self, **kwargs):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
''' return from the module, without error '''
self.do_cleanup_files()
self._return_formatted(kwargs)
sys.exit(0)
def fail_json(self, msg, **kwargs):
''' return from the module, with an error message '''
kwargs['failed'] = True
kwargs['msg'] = msg
if 'exception' not in kwargs and sys.exc_info()[2] and (self._debug or self._verbosity >= 3):
if PY2:
kwargs['exception'] = 'WARNING: The below traceback may *not* be related to the actual failure.\n' +\
''.join(traceback.format_tb(sys.exc_info()[2]))
else:
kwargs['exception'] = ''.join(traceback.format_tb(sys.exc_info()[2]))
self.do_cleanup_files()
self._return_formatted(kwargs)
sys.exit(1)
def fail_on_missing_params(self, required_params=None):
if not required_params:
return
try:
check_missing_parameters(self.params, required_params)
except TypeError as e:
self.fail_json(msg=to_native(e))
def digest_from_file(self, filename, algorithm):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
''' Return hex digest of local file for a digest_method specified by name, or None if file is not present. '''
b_filename = to_bytes(filename, errors='surrogate_or_strict')
if not os.path.exists(b_filename):
return None
if os.path.isdir(b_filename):
self.fail_json(msg="attempted to take checksum of directory: %s" % filename)
if hasattr(algorithm, 'hexdigest'):
digest_method = algorithm
else:
try:
digest_method = AVAILABLE_HASH_ALGORITHMS[algorithm]()
except KeyError:
self.fail_json(msg="Could not hash file '%s' with algorithm '%s'. Available algorithms: %s" %
(filename, algorithm, ', '.join(AVAILABLE_HASH_ALGORITHMS)))
blocksize = 64 * 1024
infile = open(os.path.realpath(b_filename), 'rb')
block = infile.read(blocksize)
while block:
digest_method.update(block)
block = infile.read(blocksize)
infile.close()
return digest_method.hexdigest()
def md5(self, filename):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
''' Return MD5 hex digest of local file using digest_from_file().
Do not use this function unless you have no other choice for:
1) Optional backwards compatibility
2) Compatibility with a third party protocol
This function will not work on systems complying with FIPS-140-2.
Most uses of this function can use the module.sha1 function instead.
'''
if 'md5' not in AVAILABLE_HASH_ALGORITHMS:
raise ValueError('MD5 not available. Possibly running in FIPS mode')
return self.digest_from_file(filename, 'md5')
def sha1(self, filename):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
''' Return SHA1 hex digest of local file using digest_from_file(). '''
return self.digest_from_file(filename, 'sha1')
def sha256(self, filename):
''' Return SHA-256 hex digest of local file using digest_from_file(). '''
return self.digest_from_file(filename, 'sha256')
def backup_local(self, fn):
'''make a date-marked backup of the specified file, return True or False on success or failure'''
backupdest = ''
if os.path.exists(fn):
ext = time.strftime("%Y-%m-%d@%H:%M:%S~", time.localtime(time.time()))
backupdest = '%s.%s.%s' % (fn, os.getpid(), ext)
try:
self.preserved_copy(fn, backupdest)
except (shutil.Error, IOError) as e:
self.fail_json(msg='Could not make backup of %s to %s: %s' % (fn, backupdest, to_native(e)))
return backupdest
def cleanup(self, tmpfile):
if os.path.exists(tmpfile):
try:
os.unlink(tmpfile)
except OSError as e:
sys.stderr.write("could not cleanup %s: %s" % (tmpfile, to_native(e)))
def preserved_copy(self, src, dest):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
"""Copy a file with preserved ownership, permissions and context"""
#
shutil.copy2(src, dest)
if self.selinux_enabled():
context = self.selinux_context(src)
self.set_context_if_different(dest, context, False)
try:
dest_stat = os.stat(src)
tmp_stat = os.stat(dest)
if dest_stat and (tmp_stat.st_uid != dest_stat.st_uid or tmp_stat.st_gid != dest_stat.st_gid):
os.chown(dest, dest_stat.st_uid, dest_stat.st_gid)
except OSError as e:
if e.errno != errno.EPERM:
raise
current_attribs = self.get_file_attributes(src, include_version=False)
current_attribs = current_attribs.get('attr_flags', '')
self.set_attributes_if_different(dest, current_attribs, True)
def atomic_move(self, src, dest, unsafe_writes=False):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
'''atomically move src to dest, copying attributes from dest, returns true on success
it uses os.rename to ensure this as it is an atomic operation, rest of the function is
to work around limitations, corner cases and ensure selinux context is saved if possible'''
context = None
dest_stat = None
b_src = to_bytes(src, errors='surrogate_or_strict')
b_dest = to_bytes(dest, errors='surrogate_or_strict')
if os.path.exists(b_dest):
try:
dest_stat = os.stat(b_dest)
os.chmod(b_src, dest_stat.st_mode & PERM_BITS)
os.chown(b_src, dest_stat.st_uid, dest_stat.st_gid)
if hasattr(os, 'chflags') and hasattr(dest_stat, 'st_flags'):
try:
os.chflags(b_src, dest_stat.st_flags)
except OSError as e:
for err in 'EOPNOTSUPP', 'ENOTSUP':
if hasattr(errno, err) and e.errno == getattr(errno, err):
break
else:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
raise
except OSError as e:
if e.errno != errno.EPERM:
raise
if self.selinux_enabled():
context = self.selinux_context(dest)
else:
if self.selinux_enabled():
context = self.selinux_default_context(dest)
creating = not os.path.exists(b_dest)
try:
os.rename(b_src, b_dest)
except (IOError, OSError) as e:
if e.errno not in [errno.EPERM, errno.EXDEV, errno.EACCES, errno.ETXTBSY, errno.EBUSY]:
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, to_native(e)), exception=traceback.format_exc())
else:
b_dest_dir = os.path.dirname(b_dest)
b_suffix = os.path.basename(b_dest)
error_msg = None
tmp_dest_name = None
try:
tmp_dest_fd, tmp_dest_name = tempfile.mkstemp(prefix=b'.ansible_tmp', dir=b_dest_dir, suffix=b_suffix)
except (OSError, IOError) as e:
error_msg = 'The destination directory (%s) is not writable by the current user. Error was: %s' % (os.path.dirname(dest), to_native(e))
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
finally:
if error_msg:
if unsafe_writes:
self._unsafe_writes(b_src, b_dest)
else:
self.fail_json(msg=error_msg, exception=traceback.format_exc())
if tmp_dest_name:
b_tmp_dest_name = to_bytes(tmp_dest_name, errors='surrogate_or_strict')
try:
try:
os.close(tmp_dest_fd)
try:
shutil.move(b_src, b_tmp_dest_name)
except OSError:
shutil.copy2(b_src, b_tmp_dest_name)
if self.selinux_enabled():
self.set_context_if_different(
b_tmp_dest_name, context, False)
try:
tmp_stat = os.stat(b_tmp_dest_name)
if dest_stat and (tmp_stat.st_uid != dest_stat.st_uid or tmp_stat.st_gid != dest_stat.st_gid):
os.chown(b_tmp_dest_name, dest_stat.st_uid, dest_stat.st_gid)
except OSError as e:
if e.errno != errno.EPERM:
raise
try:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
os.rename(b_tmp_dest_name, b_dest)
except (shutil.Error, OSError, IOError) as e:
if unsafe_writes and e.errno == errno.EBUSY:
self._unsafe_writes(b_tmp_dest_name, b_dest)
else:
self.fail_json(msg='Unable to make %s into to %s, failed final rename from %s: %s' %
(src, dest, b_tmp_dest_name, to_native(e)), exception=traceback.format_exc())
except (shutil.Error, OSError, IOError) as e:
if unsafe_writes:
self._unsafe_writes(b_src, b_dest)
else:
self.fail_json(msg='Failed to replace file: %s to %s: %s' % (src, dest, to_native(e)), exception=traceback.format_exc())
finally:
self.cleanup(b_tmp_dest_name)
if creating:
umask = os.umask(0)
os.umask(umask)
os.chmod(b_dest, DEFAULT_PERM & ~umask)
try:
os.chown(b_dest, os.geteuid(), os.getegid())
except OSError:
pass
if self.selinux_enabled():
self.set_context_if_different(dest, context, False)
def _unsafe_writes(self, src, dest):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
try:
out_dest = in_src = None
try:
out_dest = open(dest, 'wb')
in_src = open(src, 'rb')
shutil.copyfileobj(in_src, out_dest)
finally:
if out_dest:
out_dest.close()
if in_src:
in_src.close()
except (shutil.Error, OSError, IOError) as e:
self.fail_json(msg='Could not write data to file (%s) from (%s): %s' % (dest, src, to_native(e)),
exception=traceback.format_exc())
def _clean_args(self, args):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
if not self._clean:
to_clean_args = args
if PY2:
if isinstance(args, text_type):
to_clean_args = to_bytes(args)
else:
if isinstance(args, binary_type):
to_clean_args = to_text(args)
if isinstance(args, (text_type, binary_type)):
to_clean_args = shlex.split(to_clean_args)
clean_args = []
is_passwd = False
for arg in (to_native(a) for a in to_clean_args):
if is_passwd:
is_passwd = False
clean_args.append('********')
continue
if PASSWD_ARG_RE.match(arg):
sep_idx = arg.find('=')
if sep_idx > -1:
clean_args.append('%s=********' % arg[:sep_idx])
continue
else:
is_passwd = True
arg = heuristic_log_sanitize(arg, self.no_log_values)
clean_args.append(arg)
self._clean = ' '.join(shlex_quote(arg) for arg in clean_args)
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
return self._clean
def _restore_signal_handlers(self):
if PY2 and sys.platform != 'win32':
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
def run_command(self, args, check_rc=False, close_fds=True, executable=None, data=None, binary_data=False, path_prefix=None, cwd=None,
use_unsafe_shell=False, prompt_regex=None, environ_update=None, umask=None, encoding='utf-8', errors='surrogate_or_strict',
expand_user_and_vars=True, pass_fds=None, before_communicate_callback=None, ignore_invalid_cwd=True, handle_exceptions=True):
'''
Execute a command, returns rc, stdout, and stderr.
The mechanism of this method for reading stdout and stderr differs from
that of CPython subprocess.Popen.communicate, in that this method will
stop reading once the spawned command has exited and stdout and stderr
have been consumed, as opposed to waiting until stdout/stderr are
closed. This can be an important distinction, when taken into account
that a forked or backgrounded process may hold stdout or stderr open
for longer than the spawned command.
:arg args: is the command to run
* If args is a list, the command will be run with shell=False.
* If args is a string and use_unsafe_shell=False it will split args to a list and run with shell=False
* If args is a string and use_unsafe_shell=True it runs with shell=True.
:kw check_rc: Whether to call fail_json in case of non zero RC.
Default False
:kw close_fds: See documentation for subprocess.Popen(). Default True
:kw executable: See documentation for subprocess.Popen(). Default None
:kw data: If given, information to write to the stdin of the command
:kw binary_data: If False, append a newline to the data. Default False
:kw path_prefix: If given, additional path to find the command in.
This adds to the PATH environment variable so helper commands in
the same directory can also be found
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
:kw cwd: If given, working directory to run the command inside
:kw use_unsafe_shell: See `args` parameter. Default False
:kw prompt_regex: Regex string (not a compiled regex) which can be
used to detect prompts in the stdout which would otherwise cause
the execution to hang (especially if no input data is specified)
:kw environ_update: dictionary to *update* environ variables with
:kw umask: Umask to be used when running the command. Default None
:kw encoding: Since we return native strings, on python3 we need to
know the encoding to use to transform from bytes to text. If you
want to always get bytes back, use encoding=None. The default is
"utf-8". This does not affect transformation of strings given as
args.
:kw errors: Since we return native strings, on python3 we need to
transform stdout and stderr from bytes to text. If the bytes are
undecodable in the ``encoding`` specified, then use this error
handler to deal with them. The default is ``surrogate_or_strict``
which means that the bytes will be decoded using the
surrogateescape error handler if available (available on all
python3 versions we support) otherwise a UnicodeError traceback
will be raised. This does not affect transformations of strings
given as args.
:kw expand_user_and_vars: When ``use_unsafe_shell=False`` this argument
dictates whether ``~`` is expanded in paths and environment variables
are expanded before running the command. When ``True`` a string such as
``$SHELL`` will be expanded regardless of escaping. When ``False`` and
``use_unsafe_shell=False`` no path or variable expansion will be done.
:kw pass_fds: When running on Python 3 this argument
dictates which file descriptors should be passed
to an underlying ``Popen`` constructor. On Python 2, this will
set ``close_fds`` to False.
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
:kw before_communicate_callback: This function will be called
after ``Popen`` object will be created
but before communicating to the process.
(``Popen`` object will be passed to callback as a first argument)
:kw ignore_invalid_cwd: This flag indicates whether an invalid ``cwd``
(non-existent or not a directory) should be ignored or should raise
an exception.
:kw handle_exceptions: This flag indicates whether an exception will
be handled inline and issue a failed_json or if the caller should
handle it.
:returns: A 3-tuple of return code (integer), stdout (native string),
and stderr (native string). On python2, stdout and stderr are both
byte strings. On python3, stdout and stderr are text strings converted
according to the encoding and errors parameters. If you want byte
strings on python3, use encoding=None to turn decoding to text off.
'''
self._clean = None
if not isinstance(args, (list, binary_type, text_type)):
msg = "Argument 'args' to run_command must be list or string"
self.fail_json(rc=257, cmd=args, msg=msg)
shell = False
if use_unsafe_shell:
if isinstance(args, list):
args = b" ".join([to_bytes(shlex_quote(x), errors='surrogate_or_strict') for x in args])
else:
args = to_bytes(args, errors='surrogate_or_strict')
if executable:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
executable = to_bytes(executable, errors='surrogate_or_strict')
args = [executable, b'-c', args]
elif self._shell not in (None, '/bin/sh'):
args = [to_bytes(self._shell, errors='surrogate_or_strict'), b'-c', args]
else:
shell = True
else:
if isinstance(args, (binary_type, text_type)):
if PY2:
args = to_bytes(args, errors='surrogate_or_strict')
elif PY3:
args = to_text(args, errors='surrogateescape')
args = shlex.split(args)
if expand_user_and_vars:
args = [to_bytes(os.path.expanduser(os.path.expandvars(x)), errors='surrogate_or_strict') for x in args if x is not None]
else:
args = [to_bytes(x, errors='surrogate_or_strict') for x in args if x is not None]
prompt_re = None
if prompt_regex:
if isinstance(prompt_regex, text_type):
if PY3:
prompt_regex = to_bytes(prompt_regex, errors='surrogateescape')
elif PY2:
prompt_regex = to_bytes(prompt_regex, errors='surrogate_or_strict')
try:
prompt_re = re.compile(prompt_regex, re.MULTILINE)
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
except re.error:
self.fail_json(msg="invalid prompt regular expression given to run_command")
rc = 0
msg = None
st_in = None
env = os.environ.copy()
env.update(self.run_command_environ_update or {})
env.update(environ_update or {})
if path_prefix:
path = env.get('PATH', '')
if path:
env['PATH'] = "%s:%s" % (path_prefix, path)
else:
env['PATH'] = path_prefix
if 'PYTHONPATH' in env:
pypaths = [x for x in env['PYTHONPATH'].split(':')
if x and
not x.endswith('/ansible_modlib.zip') and
not x.endswith('/debug_dir')]
if pypaths and any(pypaths):
env['PYTHONPATH'] = ':'.join(pypaths)
if data:
st_in = subprocess.PIPE
def preexec():
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
self._restore_signal_handlers()
if umask:
os.umask(umask)
kwargs = dict(
executable=executable,
shell=shell,
close_fds=close_fds,
stdin=st_in,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
preexec_fn=preexec,
env=env,
)
if PY3 and pass_fds:
kwargs["pass_fds"] = pass_fds
elif PY2 and pass_fds:
kwargs['close_fds'] = False
if cwd:
cwd = to_bytes(os.path.abspath(os.path.expanduser(cwd)), errors='surrogate_or_strict')
if os.path.isdir(cwd):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
kwargs['cwd'] = cwd
elif not ignore_invalid_cwd:
self.fail_json(msg="Provided cwd is not a valid directory: %s" % cwd)
try:
if self._debug:
self.log('Executing: ' + self._clean_args(args))
cmd = subprocess.Popen(args, **kwargs)
if before_communicate_callback:
before_communicate_callback(cmd)
stdout = b''
stderr = b''
if hasattr(selectors, 'PollSelector'):
selector = selectors.PollSelector()
else:
selector = selectors.SelectSelector()
if data:
if not binary_data:
data += '\n'
if isinstance(data, text_type):
data = to_bytes(data)
selector.register(cmd.stdout, selectors.EVENT_READ)
selector.register(cmd.stderr, selectors.EVENT_READ)
if os.name == 'posix':
fcntl.fcntl(cmd.stdout.fileno(), fcntl.F_SETFL, fcntl.fcntl(cmd.stdout.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK)
fcntl.fcntl(cmd.stderr.fileno(), fcntl.F_SETFL, fcntl.fcntl(cmd.stderr.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK)
if data:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
cmd.stdin.write(data)
cmd.stdin.close()
while True:
events = selector.select(1)
stdout_changed = False
for key, event in events:
b_chunk = key.fileobj.read(32768)
if not b_chunk:
selector.unregister(key.fileobj)
elif key.fileobj == cmd.stdout:
stdout += b_chunk
stdout_changed = True
elif key.fileobj == cmd.stderr:
stderr += b_chunk
if prompt_re and stdout_changed and prompt_re.search(stdout) and not data:
if encoding:
stdout = to_native(stdout, encoding=encoding, errors=errors)
return (257, stdout, "A prompt was encountered while running a command, but no input data was specified")
if (not events or not selector.get_map()) and cmd.poll() is not None:
break
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
elif not selector.get_map() and cmd.poll() is None:
cmd.wait()
break
cmd.stdout.close()
cmd.stderr.close()
selector.close()
rc = cmd.returncode
except (OSError, IOError) as e:
self.log("Error Executing CMD:%s Exception:%s" % (self._clean_args(args), to_native(e)))
if handle_exceptions:
self.fail_json(rc=e.errno, stdout=b'', stderr=b'', msg=to_native(e), cmd=self._clean_args(args))
else:
raise e
except Exception as e:
self.log("Error Executing CMD:%s Exception:%s" % (self._clean_args(args), to_native(traceback.format_exc())))
if handle_exceptions:
self.fail_json(rc=257, stdout=b'', stderr=b'', msg=to_native(e), exception=traceback.format_exc(), cmd=self._clean_args(args))
else:
raise e
if rc != 0 and check_rc:
msg = heuristic_log_sanitize(stderr.rstrip(), self.no_log_values)
self.fail_json(cmd=self._clean_args(args), rc=rc, stdout=stdout, stderr=stderr, msg=msg)
if encoding is not None:
return (rc, to_native(stdout, encoding=encoding, errors=errors),
to_native(stderr, encoding=encoding, errors=errors))
return (rc, stdout, stderr)
def append_to_file(self, filename, str):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
filename = os.path.expandvars(os.path.expanduser(filename))
fh = open(filename, 'a')
fh.write(str)
fh.close()
def bytes_to_human(self, size):
return bytes_to_human(size)
pretty_bytes = bytes_to_human
def human_to_bytes(self, number, isbits=False):
return human_to_bytes(number, isbits)
#
#
is_executable = is_executable
@staticmethod
def get_buffer_size(fd):
try:
buffer_size = fcntl.fcntl(fd, 1032)
except Exception:
try:
buffer_size = select.PIPE_BUF
except Exception:
buffer_size = 9000
return buffer_size
def get_module_path():
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 76,727 |
lineinfile: Fails when creating a backup of Ubuntu 21.10's /etc/resolv.conf (symlink to "../run/systemd/resolve/stub-resolv.conf")
|
### Summary
https://github.com/ansible/ansible/issues/31982 is back.
### Issue Type
Bug Report
### Component Name
lineinfile
### Ansible Version
```console
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```
### Configuration
```console
$ ansible-config dump --only-changed
$
```
### OS / Environment
Ubuntu 21.10 Server in a VirtualBox, on server and clients, nothing special
### Steps to Reproduce
```
- name: "Check DNS configuration: Remove search list"
ansible.builtin.lineinfile:
backup: "yes"
path: "/etc/resolv.conf"
line: "search x.tld"
state: "absent"
- name: "Check DNS configuration: Cache servers present"
ansible.builtin.lineinfile:
backup: "yes"
line: "{{ item }}"
path: "/etc/resolv.conf"
state: "present"
with_items:
- "nameserver x.x.x.x"
- "nameserver y.y.y.y"
```
### Expected Results
The file is modified, a backup is created.
### Actual Results
```console
<x.x.x.x> (1, b'\r\n{"path": "/etc/resolv.conf.2410.2022-01-11@10:36:56~", "details": "Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n", "exception": "Traceback (most recent call last):\\n File \\"/tmp/ansible_ansible.builtin.lineinfile_payload_pvwbc704/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py\\", line 1256, in set_attributes_if_different\\n raise Exception(\\"Error while setting attributes: %s\\" % (out + err))\\nException: Error while setting attributes: /etc/resolv.conf.2410.2022-01-11@10:36:56~: Operation not supported\\n\\n", "failed": true, "msg": "chattr failed", "uid": 101, "gid": 103, "owner": "systemd-resolve", "group": "systemd-resolve", "mode": "0644", "state": "file", "size": 920, "invocation": {"module_args": {"backup": true, "line": "nameserver x.x.x.x", "path": "/etc/resolv.conf", "state": "present", "backrefs": false, "create": false, "firstmatch": false, "unsafe_writes": false, "regexp": null, "insertafter": null, "insertbefore": null, "validate": null, "mode": null, "owner": null, "group": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to x.x.x.x closed.\r\n')
<x.x.x.x> Failed to connect to the host via ssh: Shared connection to x.x.x.x closed.
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4c20d84404 x.x.x.x '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1641897416.2652106-3817-66846454678877/ > /dev/null 2>&1 && sleep 0'"'"''
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ansible.builtin.lineinfile_payload_bccsus14/ansible_ansible.builtin.lineinfile_payload.zip/ansible/module_utils/basic.py", line 1256, in set_attributes_if_different
raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported
failed: [x.x.x.x] (item=nameserver x.x.x.x) => {
"ansible_loop_var": "item",
"changed": false,
"details": "Error while setting attributes: /etc/resolv.conf.2577.2022-01-11@10:36:56~: Operation not supported\n",
"gid": 103,
"group": "systemd-resolve",
"invocation": {
"module_args": {
"attributes": null,
"backrefs": false,
"backup": true,
"create": false,
"firstmatch": false,
"group": null,
"insertafter": null,
"insertbefore": null,
"line": "nameserver x.x.x.x",
"mode": null,
"owner": null,
"path": "/etc/resolv.conf",
"regexp": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"state": "present",
"unsafe_writes": false,
"validate": null
}
},
"item": "nameserver x.x.x.x",
"mode": "0644",
"msg": "chattr failed",
"owner": "systemd-resolve",
"path": "/etc/resolv.conf.2577.2022-01-11@10:36:56~",
"size": 946,
"state": "file",
"uid": 101
}
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/76727
|
https://github.com/ansible/ansible/pull/78707
|
dd0138ba2127eac0e809d68e00ae117df56db77e
|
9b002d2e63ec0d39c7c3025dfd4be7489c82016b
| 2022-01-11T11:07:14Z |
python
| 2023-12-06T17:02:51Z |
lib/ansible/module_utils/basic.py
|
return os.path.dirname(os.path.realpath(__file__))
def __getattr__(importable_name):
"""Inject import-time deprecation warnings.
Specifically, for ``literal_eval()``, ``_literal_eval()``
and ``get_exception()``.
"""
if importable_name == 'get_exception':
deprecate(
msg=f'The `ansible.module_utils.basic.'
f'{importable_name}` function is deprecated.',
version='2.19',
)
from ansible.module_utils.pycompat24 import get_exception
return get_exception
if importable_name in {'literal_eval', '_literal_eval'}:
deprecate(
msg=f'The `ansible.module_utils.basic.'
f'{importable_name}` function is deprecated.',
version='2.19',
)
from ast import literal_eval
return literal_eval
raise AttributeError(
f'cannot import name {importable_name !r} '
f'has no attribute ({__file__ !s})',
)
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
from __future__ import annotations
import base64
import json
import os
import random
import re
import shlex
import stat
import tempfile
from abc import ABC, abstractmethod
from collections.abc import Sequence
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleActionSkip, AnsibleActionFail, AnsibleAuthenticationFailure
from ansible.executor.module_common import modify_module
from ansible.executor.interpreter_discovery import discover_interpreter, InterpreterDiscoveryRequiredError
from ansible.module_utils.common.arg_spec import ArgumentSpecValidator
from ansible.module_utils.errors import UnsupportedError
from ansible.module_utils.json_utils import _filter_non_json_lines
from ansible.module_utils.six import binary_type, string_types, text_type
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.parsing.utils.jsonify import jsonify
from ansible.release import __version__
from ansible.utils.collection_loader import resource_from_fqcr
from ansible.utils.display import Display
from ansible.utils.unsafe_proxy import wrap_var, AnsibleUnsafeText
from ansible.vars.clean import remove_internal_keys
from ansible.utils.plugin_docs import get_versioned_doclink
display = Display()
def _validate_utf8_json(d):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
if isinstance(d, text_type):
d.encode(encoding='utf-8', errors='strict')
elif isinstance(d, dict):
for o in d.items():
_validate_utf8_json(o)
elif isinstance(d, (list, tuple)):
for o in d:
_validate_utf8_json(o)
class ActionBase(ABC):
'''
This class is the base class for all action plugins, and defines
code common to all actions. The base class handles the connection
by putting/getting files and executing commands based on the current
action in use.
'''
_VALID_ARGS = frozenset([])
BYPASS_HOST_LOOP = False
TRANSFERS_FILES = False
_requires_connection = True
_supports_check_mode = True
_supports_async = False
def __init__(self, task, connection, play_context, loader, templar, shared_loader_obj):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
self._task = task
self._connection = connection
self._play_context = play_context
self._loader = loader
self._templar = templar
self._shared_loader_obj = shared_loader_obj
self._cleanup_remote_tmp = False
self._discovered_interpreter_key = None
self._discovered_interpreter = False
self._discovery_deprecation_warnings = []
self._discovery_warnings = []
self._used_interpreter = None
self._display = display
@abstractmethod
def run(self, tmp=None, task_vars=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
""" Action Plugins should implement this method to perform their
tasks. Everything else in this base class is a helper method for the
action plugin to do that.
:kwarg tmp: Deprecated parameter. This is no longer used. An action plugin that calls
another one and wants to use the same remote tmp for both should set
self._connection._shell.tmpdir rather than this parameter.
:kwarg task_vars: The variables (host vars, group vars, config vars,
etc) associated with this task.
:returns: dictionary of results from the module
Implementers of action modules may find the following variables especially useful:
* Module parameters. These are stored in self._task.args
"""
result = {}
if tmp is not None:
result['warning'] = ['ActionModule.run() no longer honors the tmp parameter. Action'
' plugins should set self._connection._shell.tmpdir to share'
' the tmpdir']
del tmp
if self._task.async_val and not self._supports_async:
raise AnsibleActionFail('async is not supported for this task.')
elif self._task.check_mode and not self._supports_check_mode:
raise AnsibleActionSkip('check mode is not supported for this task.')
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
elif self._task.async_val and self._task.check_mode:
raise AnsibleActionFail('check mode and async cannot be used on same task.')
if self._VALID_ARGS:
task_opts = frozenset(self._task.args.keys())
bad_opts = task_opts.difference(self._VALID_ARGS)
if bad_opts:
raise AnsibleActionFail('Invalid options for %s: %s' % (self._task.action, ','.join(list(bad_opts))))
if self._connection._shell.tmpdir is None and self._early_needs_tmp_path():
self._make_tmp_path()
return result
def validate_argument_spec(self, argument_spec=None,
mutually_exclusive=None,
required_together=None,
required_one_of=None,
required_if=None,
required_by=None,
):
"""Validate an argument spec against the task args
This will return a tuple of (ValidationResult, dict) where the dict
is the validated, coerced, and normalized task args.
Be cautious when directly passing ``new_module_args`` directly to a
module invocation, as it will contain the defaults, and not only
the args supplied from the task. If you do this, the module
should not define ``mututally_exclusive`` or similar.
This code is roughly copied from the ``validate_argument_spec``
action plugin for use by other action plugins.
"""
new_module_args = self._task.args.copy()
validator = ArgumentSpecValidator(
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
argument_spec,
mutually_exclusive=mutually_exclusive,
required_together=required_together,
required_one_of=required_one_of,
required_if=required_if,
required_by=required_by,
)
validation_result = validator.validate(new_module_args)
new_module_args.update(validation_result.validated_parameters)
try:
error = validation_result.errors[0]
except IndexError:
error = None
if error:
msg = validation_result.errors.msg
if isinstance(error, UnsupportedError):
msg = f"Unsupported parameters for ({self._load_name}) module: {msg}"
raise AnsibleActionFail(msg)
return validation_result, new_module_args
def cleanup(self, force=False):
"""Method to perform a clean up at the end of an action plugin execution
By default this is designed to clean up the shell tmpdir, and is toggled based on whether
async is in use
Action plugins may override this if they deem necessary, but should still call this method
via super
"""
if force or not self._task.async_val:
self._remove_tmp_path(self._connection._shell.tmpdir)
def get_plugin_option(self, plugin, option, default=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
"""Helper to get an option from a plugin without having to use
the try/except dance everywhere to set a default
"""
try:
return plugin.get_option(option)
except (AttributeError, KeyError):
return default
def get_become_option(self, option, default=None):
return self.get_plugin_option(self._connection.become, option, default=default)
def get_connection_option(self, option, default=None):
return self.get_plugin_option(self._connection, option, default=default)
def get_shell_option(self, option, default=None):
return self.get_plugin_option(self._connection._shell, option, default=default)
def _remote_file_exists(self, path):
cmd = self._connection._shell.exists(path)
result = self._low_level_execute_command(cmd=cmd, sudoable=True)
if result['rc'] == 0:
return True
return False
def _configure_module(self, module_name, module_args, task_vars):
'''
Handles the loading and templating of the module code through the
modify_module() function.
'''
if self._task.delegate_to:
use_vars = task_vars.get('ansible_delegated_vars')[self._task.delegate_to]
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
else:
use_vars = task_vars
split_module_name = module_name.split('.')
collection_name = '.'.join(split_module_name[0:2]) if len(split_module_name) > 2 else ''
leaf_module_name = resource_from_fqcr(module_name)
for mod_type in self._connection.module_implementation_preferences:
if mod_type == '.ps1':
win_collection = 'ansible.windows'
rewrite_collection_names = ['ansible.builtin', 'ansible.legacy', '']
if leaf_module_name in ('stat', 'file', 'copy', 'ping') and \
collection_name in rewrite_collection_names and self._task.action != module_name:
module_name = '%s.win_%s' % (win_collection, leaf_module_name)
elif leaf_module_name == 'async_status' and collection_name in rewrite_collection_names:
module_name = '%s.%s' % (win_collection, leaf_module_name)
if leaf_module_name in ['win_stat', 'win_file', 'win_copy', 'slurp'] and module_args and \
hasattr(self._connection._shell, '_unquote'):
for key in ('src', 'dest', 'path'):
if key in module_args:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
module_args[key] = self._connection._shell._unquote(module_args[key])
result = self._shared_loader_obj.module_loader.find_plugin_with_context(module_name, mod_type, collection_list=self._task.collections)
if not result.resolved:
if result.redirect_list and len(result.redirect_list) > 1:
target_module_name = result.redirect_list[-1]
raise AnsibleError("The module {0} was redirected to {1}, which could not be loaded.".format(module_name, target_module_name))
module_path = result.plugin_resolved_path
if module_path:
break
else:
raise AnsibleError("The module %s was not found in configured module paths" % (module_name))
final_environment = dict()
self._compute_environment_string(final_environment)
become_kwargs = {}
if self._connection.become:
become_kwargs['become'] = True
become_kwargs['become_method'] = self._connection.become.name
become_kwargs['become_user'] = self._connection.become.get_option('become_user',
playcontext=self._play_context)
become_kwargs['become_password'] = self._connection.become.get_option('become_pass',
playcontext=self._play_context)
become_kwargs['become_flags'] = self._connection.become.get_option('become_flags',
playcontext=self._play_context)
for dummy in (1, 2):
try:
(module_data, module_style, module_shebang) = modify_module(module_name, module_path, module_args, self._templar,
task_vars=use_vars,
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
module_compression=C.config.get_config_value('DEFAULT_MODULE_COMPRESSION',
variables=task_vars),
async_timeout=self._task.async_val,
environment=final_environment,
remote_is_local=bool(getattr(self._connection, '_remote_is_local', False)),
**become_kwargs)
break
except InterpreterDiscoveryRequiredError as idre:
self._discovered_interpreter = AnsibleUnsafeText(discover_interpreter(
action=self,
interpreter_name=idre.interpreter_name,
discovery_mode=idre.discovery_mode,
task_vars=use_vars))
discovered_key = 'discovered_interpreter_%s' % idre.interpreter_name
use_vars['ansible_facts'][discovered_key] = self._discovered_interpreter
if not self._task.delegate_to or self._task.delegate_facts:
task_vars['ansible_facts'][discovered_key] = self._discovered_interpreter
self._discovered_interpreter_key = discovered_key
else:
task_vars['ansible_delegated_vars'][self._task.delegate_to]['ansible_facts'][discovered_key] = self._discovered_interpreter
return (module_style, module_shebang, module_data, module_path)
def _compute_environment_string(self, raw_environment_out=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''
Builds the environment string to be used when executing the remote task.
'''
final_environment = dict()
if self._task.environment is not None:
environments = self._task.environment
if not isinstance(environments, list):
environments = [environments]
for environment in environments:
if environment is None or len(environment) == 0:
continue
temp_environment = self._templar.template(environment)
if not isinstance(temp_environment, dict):
raise AnsibleError("environment must be a dictionary, received %s (%s)" % (temp_environment, type(temp_environment)))
final_environment.update(temp_environment)
if len(final_environment) > 0:
final_environment = self._templar.template(final_environment)
if isinstance(raw_environment_out, dict):
raw_environment_out.clear()
raw_environment_out.update(final_environment)
return self._connection._shell.env_prefix(**final_environment)
def _early_needs_tmp_path(self):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''
Determines if a tmp path should be created before the action is executed.
'''
return getattr(self, 'TRANSFERS_FILES', False)
def _is_pipelining_enabled(self, module_style, wrap_async=False):
'''
Determines if we are required and can do pipelining
'''
try:
is_enabled = self._connection.get_option('pipelining')
except (KeyError, AttributeError, ValueError):
is_enabled = self._play_context.pipelining
always_pipeline = self._connection.always_pipeline_modules
become_exception = (self._connection.become.name if self._connection.become else '') != 'su'
conditions = [
self._connection.has_pipelining,
is_enabled or always_pipeline,
module_style == "new",
not C.DEFAULT_KEEP_REMOTE_FILES,
not wrap_async or always_pipeline,
become_exception,
]
return all(conditions)
def _get_admin_users(self):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''
Returns a list of admin users that are configured for the current shell
plugin
'''
return self.get_shell_option('admin_users', ['root'])
def _get_remote_addr(self, tvars):
''' consistently get the 'remote_address' for the action plugin '''
remote_addr = tvars.get('delegated_vars', {}).get('ansible_host', tvars.get('ansible_host', tvars.get('inventory_hostname', None)))
for variation in ('remote_addr', 'host'):
try:
remote_addr = self._connection.get_option(variation)
except KeyError:
continue
break
else:
remote_addr = self._play_context.remote_addr
return remote_addr
def _get_remote_user(self):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
''' consistently get the 'remote_user' for the action plugin '''
remote_user = None
try:
remote_user = self._connection.get_option('remote_user')
except KeyError:
remote_user = getattr(self._connection, 'default_user', None) or self._play_context.remote_user
except AttributeError:
remote_user = self._play_context.remote_user
return remote_user
def _is_become_unprivileged(self):
'''
The user is not the same as the connection user and is not part of the
shell configured admin users
'''
if not self._connection.become:
return False
admin_users = self._get_admin_users()
remote_user = self._get_remote_user()
become_user = self.get_become_option('become_user')
return bool(become_user and become_user not in admin_users + [remote_user])
def _make_tmp_path(self, remote_user=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''
Create and return a temporary path on a remote box.
'''
if getattr(self._connection, '_remote_is_local', False):
tmpdir = C.DEFAULT_LOCAL_TMP
else:
tmpdir = self._remote_expand_user(self.get_shell_option('remote_tmp', default='~/.ansible/tmp'), sudoable=False)
become_unprivileged = self._is_become_unprivileged()
basefile = self._connection._shell._generate_temp_dir_name()
cmd = self._connection._shell.mkdtemp(basefile=basefile, system=become_unprivileged, tmpdir=tmpdir)
result = self._low_level_execute_command(cmd, sudoable=False)
if result['rc'] != 0:
if result['rc'] == 5:
output = 'Authentication failure.'
elif result['rc'] == 255 and self._connection.transport in ('ssh',):
if display.verbosity > 3:
output = u'SSH encountered an unknown error. The output was:\n%s%s' % (result['stdout'], result['stderr'])
else:
output = (u'SSH encountered an unknown error during the connection. '
'We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue')
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
elif u'No space left on device' in result['stderr']:
output = result['stderr']
else:
output = ('Failed to create temporary directory. '
'In some cases, you may have been able to authenticate and did not have permissions on the target directory. '
'Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp", for more error information use -vvv. '
'Failed command was: %s, exited with result %d' % (cmd, result['rc']))
if 'stdout' in result and result['stdout'] != u'':
output = output + u", stdout output: %s" % result['stdout']
if display.verbosity > 3 and 'stderr' in result and result['stderr'] != u'':
output += u", stderr output: %s" % result['stderr']
raise AnsibleConnectionFailure(output)
else:
self._cleanup_remote_tmp = True
try:
stdout_parts = result['stdout'].strip().split('%s=' % basefile, 1)
rc = self._connection._shell.join_path(stdout_parts[-1], u'').splitlines()[-1]
except IndexError:
rc = '/'
if rc == '/':
raise AnsibleError('failed to resolve remote temporary directory from %s: `%s` returned empty string' % (basefile, cmd))
self._connection._shell.tmpdir = rc
return rc
def _should_remove_tmp_path(self, tmp_path):
'''Determine if temporary path should be deleted or kept by user request/config'''
return tmp_path and self._cleanup_remote_tmp and not C.DEFAULT_KEEP_REMOTE_FILES and "-tmp-" in tmp_path
def _remove_tmp_path(self, tmp_path, force=False):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''Remove a temporary path we created. '''
if tmp_path is None and self._connection._shell.tmpdir:
tmp_path = self._connection._shell.tmpdir
if force or self._should_remove_tmp_path(tmp_path):
cmd = self._connection._shell.remove(tmp_path, recurse=True)
tmp_rm_res = self._low_level_execute_command(cmd, sudoable=False)
if tmp_rm_res.get('rc', 0) != 0:
display.warning('Error deleting remote temporary files (rc: %s, stderr: %s})'
% (tmp_rm_res.get('rc'), tmp_rm_res.get('stderr', 'No error string available.')))
else:
self._connection._shell.tmpdir = None
def _transfer_file(self, local_path, remote_path):
"""
Copy a file from the controller to a remote path
:arg local_path: Path on controller to transfer
:arg remote_path: Path on the remote system to transfer into
.. warning::
* When you use this function you likely want to use use fixup_perms2() on the
remote_path to make sure that the remote file is readable when the user becomes
a non-privileged user.
* If you use fixup_perms2() on the file and copy or move the file into place, you will
need to then remove filesystem acls on the file once it has been copied into place by
the module. See how the copy module implements this for help.
"""
self._connection.put_file(local_path, remote_path)
return remote_path
def _transfer_data(self, remote_path, data):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''
Copies the module data out to the temporary module path.
'''
if isinstance(data, dict):
data = jsonify(data)
afd, afile = tempfile.mkstemp(dir=C.DEFAULT_LOCAL_TMP)
afo = os.fdopen(afd, 'wb')
try:
data = to_bytes(data, errors='surrogate_or_strict')
afo.write(data)
except Exception as e:
raise AnsibleError("failure writing module data to temporary file for transfer: %s" % to_native(e))
afo.flush()
afo.close()
try:
self._transfer_file(afile, remote_path)
finally:
os.unlink(afile)
return remote_path
def _fixup_perms2(self, remote_paths, remote_user=None, execute=True):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
"""
We need the files we upload to be readable (and sometimes executable)
by the user being sudo'd to but we want to limit other people's access
(because the files could contain passwords or other private
information. We achieve this in one of these ways:
* If no sudo is performed or the remote_user is sudo'ing to
themselves, we don't have to change permissions.
* If the remote_user sudo's to a privileged user (for instance, root),
we don't have to change permissions
* If the remote_user sudo's to an unprivileged user then we attempt to
grant the unprivileged user access via file system acls.
* If granting file system acls fails we try to change the owner of the
file with chown which only works in case the remote_user is
privileged or the remote systems allows chown calls by unprivileged
users (e.g. HP-UX)
* If the above fails, we next try 'chmod +a' which is a macOS way of
setting ACLs on files.
* If the above fails, we check if ansible_common_remote_group is set.
If it is, we attempt to chgrp the file to its value. This is useful
if the remote_user has a group in common with the become_user. As the
remote_user, we can chgrp the file to that group and allow the
become_user to read it.
* If (the chown fails AND ansible_common_remote_group is not set) OR
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
(ansible_common_remote_group is set AND the chgrp (or following chmod)
returned non-zero), we can set the file to be world readable so that
the second unprivileged user can read the file.
Since this could allow other users to get access to private
information we only do this if ansible is configured with
"allow_world_readable_tmpfiles" in the ansible.cfg. Also note that
when ansible_common_remote_group is set this final fallback is very
unlikely to ever be triggered, so long as chgrp was successful. But
just because the chgrp was successful, does not mean Ansible can
necessarily access the files (if, for example, the variable was set
to a group that remote_user is in, and can chgrp to, but does not have
in common with become_user).
"""
if remote_user is None:
remote_user = self._get_remote_user()
if getattr(self._connection._shell, "_IS_WINDOWS", False):
return remote_paths
if not self._is_become_unprivileged():
if execute:
res = self._remote_chmod(remote_paths, 'u+x')
if res['rc'] != 0:
raise AnsibleError(
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'Failed to set execute bit on remote files '
'(rc: {0}, err: {1})'.format(
res['rc'],
to_native(res['stderr'])))
return remote_paths
become_user = self.get_become_option('become_user')
if execute:
chmod_mode = 'rx'
setfacl_mode = 'r-x'
chmod_acl_mode = '{0} allow read,execute'.format(become_user)
posix_acl_mode = 'A+user:{0}:rx:allow'.format(become_user)
else:
chmod_mode = 'rX'
setfacl_mode = 'r-X'
chmod_acl_mode = '{0} allow read'.format(become_user)
posix_acl_mode = 'A+user:{0}:r:allow'.format(become_user)
res = self._remote_set_user_facl(
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
remote_paths,
become_user,
setfacl_mode)
if res['rc'] == 0:
return remote_paths
if execute:
res = self._remote_chmod(remote_paths, 'u+x')
if res['rc'] != 0:
raise AnsibleError(
'Failed to set file mode or acl on remote temporary files '
'(rc: {0}, err: {1})'.format(
res['rc'],
to_native(res['stderr'])))
res = self._remote_chown(remote_paths, become_user)
if res['rc'] == 0:
return remote_paths
if remote_user in self._get_admin_users():
raise AnsibleError(
'Failed to change ownership of the temporary files Ansible '
'(via chmod nor setfacl) needs to create despite connecting as a '
'privileged user. Unprivileged become user would be unable to read'
' the file.')
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
try:
res = self._remote_chmod([chmod_acl_mode] + list(remote_paths), '+a')
except AnsibleAuthenticationFailure as e:
pass
else:
if res['rc'] == 0:
return remote_paths
res = self._remote_chmod(remote_paths, posix_acl_mode)
if res['rc'] == 0:
return remote_paths
become_link = get_versioned_doclink('playbook_guide/playbooks_privilege_escalation.html')
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
#
#
group = self.get_shell_option('common_remote_group')
if group is not None:
res = self._remote_chgrp(remote_paths, group)
if res['rc'] == 0:
if self.get_shell_option('world_readable_temp'):
display.warning(
'Both common_remote_group and '
'allow_world_readable_tmpfiles are set. chgrp was '
'successful, but there is no guarantee that Ansible '
'will be able to read the files after this operation, '
'particularly if common_remote_group was set to a '
'group of which the unprivileged become user is not a '
'member. In this situation, '
'allow_world_readable_tmpfiles is a no-op. See this '
'URL for more details: %s'
'#risks-of-becoming-an-unprivileged-user' % become_link)
if execute:
group_mode = 'g+rwx'
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
else:
group_mode = 'g+rw'
res = self._remote_chmod(remote_paths, group_mode)
if res['rc'] == 0:
return remote_paths
if self.get_shell_option('world_readable_temp'):
display.warning(
'Using world-readable permissions for temporary files Ansible '
'needs to create when becoming an unprivileged user. This may '
'be insecure. For information on securing this, see %s'
'#risks-of-becoming-an-unprivileged-user' % become_link)
res = self._remote_chmod(remote_paths, 'a+%s' % chmod_mode)
if res['rc'] == 0:
return remote_paths
raise AnsibleError(
'Failed to set file mode on remote files '
'(rc: {0}, err: {1})'.format(
res['rc'],
to_native(res['stderr'])))
raise AnsibleError(
'Failed to set permissions on the temporary files Ansible needs '
'to create when becoming an unprivileged user '
'(rc: %s, err: %s}). For information on working around this, see %s'
'#risks-of-becoming-an-unprivileged-user' % (
res['rc'],
to_native(res['stderr']), become_link))
def _remote_chmod(self, paths, mode, sudoable=False):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''
Issue a remote chmod command
'''
cmd = self._connection._shell.chmod(paths, mode)
res = self._low_level_execute_command(cmd, sudoable=sudoable)
return res
def _remote_chown(self, paths, user, sudoable=False):
'''
Issue a remote chown command
'''
cmd = self._connection._shell.chown(paths, user)
res = self._low_level_execute_command(cmd, sudoable=sudoable)
return res
def _remote_chgrp(self, paths, group, sudoable=False):
'''
Issue a remote chgrp command
'''
cmd = self._connection._shell.chgrp(paths, group)
res = self._low_level_execute_command(cmd, sudoable=sudoable)
return res
def _remote_set_user_facl(self, paths, user, mode, sudoable=False):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''
Issue a remote call to setfacl
'''
cmd = self._connection._shell.set_user_facl(paths, user, mode)
res = self._low_level_execute_command(cmd, sudoable=sudoable)
return res
def _execute_remote_stat(self, path, all_vars, follow, tmp=None, checksum=True):
'''
Get information from remote file.
'''
if tmp is not None:
display.warning('_execute_remote_stat no longer honors the tmp parameter. Action'
' plugins should set self._connection._shell.tmpdir to share'
' the tmpdir')
del tmp
module_args = dict(
path=path,
follow=follow,
get_checksum=checksum,
get_size=False,
checksum_algorithm='sha1',
)
mystat = self._execute_module(module_name='ansible.legacy.stat', module_args=module_args, task_vars=all_vars,
wrap_async=False, ignore_unknown_opts=True)
if mystat.get('failed'):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
msg = mystat.get('module_stderr')
if not msg:
msg = mystat.get('module_stdout')
if not msg:
msg = mystat.get('msg')
raise AnsibleError('Failed to get information on remote file (%s): %s' % (path, msg))
if not mystat['stat']['exists']:
mystat['stat']['checksum'] = '1'
if 'checksum' not in mystat['stat']:
mystat['stat']['checksum'] = ''
elif not isinstance(mystat['stat']['checksum'], string_types):
raise AnsibleError("Invalid checksum returned by stat: expected a string type but got %s" % type(mystat['stat']['checksum']))
return mystat['stat']
def _remote_expand_user(self, path, sudoable=True, pathsep=None):
''' takes a remote path and performs tilde/$HOME expansion on the remote host '''
if not path.startswith('~'):
return path
split_path = path.split(os.path.sep, 1)
expand_path = split_path[0]
if expand_path == '~':
become_user = self.get_become_option('become_user')
if getattr(self._connection, '_remote_is_local', False):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
pass
elif sudoable and self._connection.become and become_user:
expand_path = '~%s' % become_user
else:
expand_path = '~%s' % (self._get_remote_user() or '')
cmd = self._connection._shell.expand_user(expand_path)
data = self._low_level_execute_command(cmd, sudoable=False)
try:
initial_fragment = data['stdout'].strip().splitlines()[-1]
except IndexError:
initial_fragment = None
if not initial_fragment:
cmd = self._connection._shell.pwd()
pwd = self._low_level_execute_command(cmd, sudoable=False).get('stdout', '').strip()
if pwd:
expanded = pwd
else:
expanded = path
elif len(split_path) > 1:
expanded = self._connection._shell.join_path(initial_fragment, *split_path[1:])
else:
expanded = initial_fragment
if '..' in os.path.dirname(expanded).split('/'):
raise AnsibleError("'%s' returned an invalid relative home directory path containing '..'" % self._get_remote_addr({}))
return expanded
def _strip_success_message(self, data):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''
Removes the BECOME-SUCCESS message from the data.
'''
if data.strip().startswith('BECOME-SUCCESS-'):
data = re.sub(r'^((\r)?\n)?BECOME-SUCCESS.*(\r)?\n', '', data)
return data
def _update_module_args(self, module_name, module_args, task_vars, ignore_unknown_opts: bool = False):
if self._task.check_mode:
if not self._supports_check_mode:
raise AnsibleError("check mode is not supported for this operation")
module_args['_ansible_check_mode'] = True
else:
module_args['_ansible_check_mode'] = False
no_target_syslog = C.config.get_config_value('DEFAULT_NO_TARGET_SYSLOG', variables=task_vars)
module_args['_ansible_no_log'] = self._task.no_log or no_target_syslog
module_args['_ansible_debug'] = C.DEFAULT_DEBUG
module_args['_ansible_diff'] = self._task.diff
module_args['_ansible_verbosity'] = display.verbosity
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
module_args['_ansible_version'] = __version__
module_args['_ansible_module_name'] = module_name
module_args['_ansible_syslog_facility'] = task_vars.get('ansible_syslog_facility', C.DEFAULT_SYSLOG_FACILITY)
module_args['_ansible_selinux_special_fs'] = C.DEFAULT_SELINUX_SPECIAL_FS
module_args['_ansible_string_conversion_action'] = C.STRING_CONVERSION_ACTION
module_args['_ansible_socket'] = getattr(self._connection, 'socket_path')
if not module_args['_ansible_socket']:
module_args['_ansible_socket'] = task_vars.get('ansible_socket')
module_args['_ansible_shell_executable'] = self._play_context.executable
module_args['_ansible_keep_remote_files'] = C.DEFAULT_KEEP_REMOTE_FILES
if self._is_become_unprivileged():
module_args['_ansible_tmpdir'] = None
else:
module_args['_ansible_tmpdir'] = self._connection._shell.tmpdir
module_args['_ansible_remote_tmp'] = self.get_shell_option('remote_tmp', default='~/.ansible/tmp')
module_args['_ansible_ignore_unknown_opts'] = ignore_unknown_opts
module_args['_ansible_target_log_info'] = C.config.get_config_value('TARGET_LOG_INFO', variables=task_vars)
def _execute_module(self, module_name=None, module_args=None, tmp=None, task_vars=None, persist_files=False, delete_remote_tmp=None, wrap_async=False,
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
ignore_unknown_opts: bool = False):
'''
Transfer and run a module along with its arguments.
'''
if tmp is not None:
display.warning('_execute_module no longer honors the tmp parameter. Action plugins'
' should set self._connection._shell.tmpdir to share the tmpdir')
del tmp
if delete_remote_tmp is not None:
display.warning('_execute_module no longer honors the delete_remote_tmp parameter.'
' Action plugins should check self._connection._shell.tmpdir to'
' see if a tmpdir existed before they were called to determine'
' if they are responsible for removing it.')
del delete_remote_tmp
tmpdir = self._connection._shell.tmpdir
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
if not self._is_pipelining_enabled("new", wrap_async) and tmpdir is None:
self._make_tmp_path()
tmpdir = self._connection._shell.tmpdir
if task_vars is None:
task_vars = dict()
if module_name is None:
module_name = self._task.action
if module_args is None:
module_args = self._task.args
self._update_module_args(module_name, module_args, task_vars, ignore_unknown_opts=ignore_unknown_opts)
remove_async_dir = None
if wrap_async or self._task.async_val:
async_dir = self.get_shell_option('async_dir', default="~/.ansible_async")
remove_async_dir = len(self._task.environment)
self._task.environment.append({"ANSIBLE_ASYNC_DIR": async_dir})
(module_style, shebang, module_data, module_path) = self._configure_module(module_name=module_name, module_args=module_args, task_vars=task_vars)
display.vvv("Using module file %s" % module_path)
if not shebang and module_style != 'binary':
raise AnsibleError("module (%s) is missing interpreter line" % module_name)
self._used_interpreter = shebang
remote_module_path = None
if not self._is_pipelining_enabled(module_style, wrap_async):
if tmpdir is None:
self._make_tmp_path()
tmpdir = self._connection._shell.tmpdir
remote_module_filename = self._connection._shell.get_remote_filename(module_path)
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
remote_module_path = self._connection._shell.join_path(tmpdir, 'AnsiballZ_%s' % remote_module_filename)
args_file_path = None
if module_style in ('old', 'non_native_want_json', 'binary'):
args_file_path = self._connection._shell.join_path(tmpdir, 'args')
if remote_module_path or module_style != 'new':
display.debug("transferring module to remote %s" % remote_module_path)
if module_style == 'binary':
self._transfer_file(module_path, remote_module_path)
else:
self._transfer_data(remote_module_path, module_data)
if module_style == 'old':
args_data = ""
for k, v in module_args.items():
args_data += '%s=%s ' % (k, shlex.quote(text_type(v)))
self._transfer_data(args_file_path, args_data)
elif module_style in ('non_native_want_json', 'binary'):
self._transfer_data(args_file_path, json.dumps(module_args))
display.debug("done transferring module to remote")
environment_string = self._compute_environment_string()
if remove_async_dir is not None:
del self._task.environment[remove_async_dir]
remote_files = []
if tmpdir and remote_module_path:
remote_files = [tmpdir, remote_module_path]
if args_file_path:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
remote_files.append(args_file_path)
sudoable = True
in_data = None
cmd = ""
if wrap_async and not self._connection.always_pipeline_modules:
(async_module_style, shebang, async_module_data, async_module_path) = self._configure_module(
module_name='ansible.legacy.async_wrapper', module_args=dict(), task_vars=task_vars)
async_module_remote_filename = self._connection._shell.get_remote_filename(async_module_path)
remote_async_module_path = self._connection._shell.join_path(tmpdir, async_module_remote_filename)
self._transfer_data(remote_async_module_path, async_module_data)
remote_files.append(remote_async_module_path)
async_limit = self._task.async_val
async_jid = f'j{random.randint(0, 999999999999)}'
interpreter = shebang.replace('#!', '').strip()
async_cmd = [interpreter, remote_async_module_path, async_jid, async_limit, remote_module_path]
if environment_string:
async_cmd.insert(0, environment_string)
if args_file_path:
async_cmd.append(args_file_path)
else:
async_cmd.append('_')
if not self._should_remove_tmp_path(tmpdir):
async_cmd.append("-preserve_tmp")
cmd = " ".join(to_text(x) for x in async_cmd)
else:
if self._is_pipelining_enabled(module_style):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
in_data = module_data
display.vvv("Pipelining is enabled.")
else:
cmd = remote_module_path
cmd = self._connection._shell.build_module_command(environment_string, shebang, cmd, arg_path=args_file_path).strip()
if remote_files:
remote_files = [x for x in remote_files if x]
self._fixup_perms2(remote_files, self._get_remote_user())
res = self._low_level_execute_command(cmd, sudoable=sudoable, in_data=in_data)
data = self._parse_returned_data(res)
if data.pop("_ansible_suppress_tmpdir_delete", False):
self._cleanup_remote_tmp = False
if 'results' in data and (not isinstance(data['results'], Sequence) or isinstance(data['results'], string_types)):
data['ansible_module_results'] = data['results']
del data['results']
display.warning("Found internal 'results' key in module return, renamed to 'ansible_module_results'.")
remove_internal_keys(data)
if wrap_async:
self._connection._shell.tmpdir = None
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
data['changed'] = True
if 'stdout' in data and 'stdout_lines' not in data:
txt = data.get('stdout', None) or u''
data['stdout_lines'] = txt.splitlines()
if 'stderr' in data and 'stderr_lines' not in data:
txt = data.get('stderr', None) or u''
data['stderr_lines'] = txt.splitlines()
if self._discovered_interpreter_key:
if data.get('ansible_facts') is None:
data['ansible_facts'] = {}
data['ansible_facts'][self._discovered_interpreter_key] = self._discovered_interpreter
if self._discovery_warnings:
if data.get('warnings') is None:
data['warnings'] = []
data['warnings'].extend(self._discovery_warnings)
if self._discovery_deprecation_warnings:
if data.get('deprecations') is None:
data['deprecations'] = []
data['deprecations'].extend(self._discovery_deprecation_warnings)
data = wrap_var(data)
display.debug("done with _execute_module (%s, %s)" % (module_name, module_args))
return data
def _parse_returned_data(self, res):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
try:
filtered_output, warnings = _filter_non_json_lines(res.get('stdout', u''), objects_only=True)
for w in warnings:
display.warning(w)
data = json.loads(filtered_output)
if C.MODULE_STRICT_UTF8_RESPONSE and not data.pop('_ansible_trusted_utf8', None):
try:
_validate_utf8_json(data)
except UnicodeEncodeError:
display.deprecated(
f'Module "{self._task.resolved_action or self._task.action}" returned non UTF-8 data in '
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'the JSON response. This will become an error in the future',
version='2.18',
)
data['_ansible_parsed'] = True
except ValueError:
data = dict(failed=True, _ansible_parsed=False)
data['module_stdout'] = res.get('stdout', u'')
if 'stderr' in res:
data['module_stderr'] = res['stderr']
if res['stderr'].startswith(u'Traceback'):
data['exception'] = res['stderr']
if 'exception' not in data and data['module_stdout'].startswith(u'Traceback'):
data['exception'] = data['module_stdout']
data['msg'] = "MODULE FAILURE"
if self._used_interpreter is not None:
interpreter = re.escape(self._used_interpreter.lstrip('!#'))
match = re.compile('%s: (?:No such file or directory|not found)' % interpreter)
if match.search(data['module_stderr']) or match.search(data['module_stdout']):
data['msg'] = "The module failed to execute correctly, you probably need to set the interpreter."
data['msg'] += '\nSee stdout/stderr for the exact error'
if 'rc' in res:
data['rc'] = res['rc']
return data
def _low_level_execute_command(self, cmd, sudoable=True, in_data=None, executable=None, encoding_errors='surrogate_then_replace', chdir=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
'''
This is the function which executes the low level shell command, which
may be commands to create/remove directories for temporary files, or to
run the module code or python directly when pipelining.
:kwarg encoding_errors: If the value returned by the command isn't
utf-8 then we have to figure out how to transform it to unicode.
If the value is just going to be displayed to the user (or
discarded) then the default of 'replace' is fine. If the data is
used as a key or is going to be written back out to a file
verbatim, then this won't work. May have to use some sort of
replacement strategy (python3 could use surrogateescape)
:kwarg chdir: cd into this directory before executing the command.
'''
display.debug("_low_level_execute_command(): starting")
if chdir:
display.debug("_low_level_execute_command(): changing cwd to %s for this command" % chdir)
cmd = self._connection._shell.append_command('cd %s' % chdir, cmd)
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
if executable:
self._connection._shell.executable = executable
ruser = self._get_remote_user()
buser = self.get_become_option('become_user')
if (sudoable and self._connection.become and
resource_from_fqcr(self._connection.transport) != 'network_cli' and
(C.BECOME_ALLOW_SAME_USER or (buser != ruser or not any((ruser, buser))))):
display.debug("_low_level_execute_command(): using become for this command")
cmd = self._connection.become.build_become_command(cmd, self._connection._shell)
if self._connection.allow_executable:
if executable is None:
executable = self._play_context.executable
cmd = self._connection._shell.append_command(cmd, 'sleep 0')
if executable:
cmd = executable + ' -c ' + shlex.quote(cmd)
display.debug("_low_level_execute_command(): executing: %s" % (cmd,))
if self._connection.transport == 'local':
self._connection.cwd = to_bytes(self._loader.get_basedir(), errors='surrogate_or_strict')
rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
if isinstance(stdout, binary_type):
out = to_text(stdout, errors=encoding_errors)
elif not isinstance(stdout, text_type):
out = to_text(b''.join(stdout.readlines()), errors=encoding_errors)
else:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
out = stdout
if isinstance(stderr, binary_type):
err = to_text(stderr, errors=encoding_errors)
elif not isinstance(stderr, text_type):
err = to_text(b''.join(stderr.readlines()), errors=encoding_errors)
else:
err = stderr
if rc is None:
rc = 0
out = self._strip_success_message(out)
display.debug(u"_low_level_execute_command() done: rc=%d, stdout=%s, stderr=%s" % (rc, out, err))
return dict(rc=rc, stdout=out, stdout_lines=out.splitlines(), stderr=err, stderr_lines=err.splitlines())
def _get_diff_data(self, destination, source, task_vars, content, source_file=True):
#
# di
diff = {}
display.debug("Going to peek to see if file has changed permissions")
peek_result = self._execute_module(
module_name='ansible.legacy.file', module_args=dict(path=destination, _diff_peek=True),
task_vars=task_vars, persist_files=True)
if peek_result.get('failed', False):
display.warning(u"Failed to get diff between '%s' and '%s': %s" % (os.path.basename(source), destination, to_text(peek_result.get(u'msg', u''))))
return diff
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
if peek_result.get('rc', 0) == 0:
if peek_result.get('state') in (None, 'absent'):
diff['before'] = u''
elif peek_result.get('appears_binary'):
diff['dst_binary'] = 1
elif peek_result.get('size') and C.MAX_FILE_SIZE_FOR_DIFF > 0 and peek_result['size'] > C.MAX_FILE_SIZE_FOR_DIFF:
diff['dst_larger'] = C.MAX_FILE_SIZE_FOR_DIFF
else:
display.debug(u"Slurping the file %s" % source)
dest_result = self._execute_module(
module_name='ansible.legacy.slurp', module_args=dict(path=destination),
task_vars=task_vars, persist_files=True)
if 'content' in dest_result:
dest_contents = dest_result['content']
if dest_result['encoding'] == u'base64':
dest_contents = base64.b64decode(dest_contents)
else:
raise AnsibleError("unknown encoding in content option, failed: %s" % to_native(dest_result))
diff['before_header'] = destination
diff['before'] = to_text(dest_contents)
if source_file:
st = os.stat(source)
if C.MAX_FILE_SIZE_FOR_DIFF > 0 and st[stat.ST_SIZE] > C.MAX_FILE_SIZE_FOR_DIFF:
diff['src_larger'] = C.MAX_FILE_SIZE_FOR_DIFF
else:
display.debug("Reading local copy of the file %s" % source)
try:
with open(source, 'rb') as src:
src_contents = src.read()
except Exception as e:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,359 |
Assemble module doesn't pass `content` arg to `_get_diff_data`
|
### Summary
When using the `ansible.builtin.assemble` module with `--diff`, the task fails with the following error:
> Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
`ansible-playbook -vvvv` says the relevant function call happens in [ansible/plugins/action/assemble.py, line 143](https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/assemble.py#L143).
Note: on my local machine that's currently line 144; 143 is on the current devel branch.
The last known working version is 8.6.1
### Issue Type
Bug Report
### Component Name
ansible.builtin.assemble
### Ansible Version
```console
$ ansible --version
ansible [core 2.16.0]
config file = None
configured module search path = ['/Users/albalitz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/albalitz/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 3 2023, 16:20:33) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less
```
### OS / Environment
This happens on my local machine running MacOS Sonoma 14.1.2 (Ansible installed via homebrew) as well as our CI system running in a `python:alpine`-based Docker environment with the same Ansible version as above (Ansible is installed via pip there and updated semi-automatically using renovatebot).
### Steps to Reproduce
This step fails with the error described above:
```yaml
- name: create concatenated file
local_action:
module: assemble
remote_src: false
src: files/some_files/
dest: /tmp/concatenated_file
no_log: true
changed_when: false
check_mode: no
become: no
run_once: true
```
The step works when `--diff` is removed from the `ansible-playbook` command.
### Expected Results
I expected the `assemble` step to run successfully and produce a concatenated file with `--diff` enabled but without printing the diff (due to `no_log: true` - I set that to `false` for debugging purposes to see the error message).
### Actual Results
```console
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: albalitz
<localhost> EXEC /bin/sh -c 'echo ~albalitz && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/albalitz/.ansible/tmp `"&& mkdir "` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" && echo ansible-tmp-1701782995.5552058-23181-40564253413079="` echo /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079 `" ) && sleep 0'
Using module file /opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/modules/stat.py
<localhost> PUT /Users/albalitz/.ansible/tmp/ansible-local-23119muc1g04o/tmp8owc8yoz TO /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/opt/homebrew/Cellar/ansible/9.0.1/libexec/bin/python /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/albalitz/.ansible/tmp/ansible-tmp-1701782995.5552058-23181-40564253413079/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 641, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible/plugins/action/assemble.py", line 144, in run
diff = self._get_diff_data(dest, path, task_vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
fatal: [shorewall-0 -> localhost]: FAILED! => {}
MSG:
Unexpected failure during module execution: ActionBase._get_diff_data() missing 1 required positional argument: 'content'
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82359
|
https://github.com/ansible/ansible/pull/82360
|
a9919dd7f62c9efe17b8acaebf7c627606ae9f66
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
| 2023-12-05T13:53:38Z |
python
| 2023-12-12T16:22:23Z |
lib/ansible/plugins/action/__init__.py
|
raise AnsibleError("Unexpected error while reading source (%s) for diff: %s " % (source, to_native(e)))
if b"\x00" in src_contents:
diff['src_binary'] = 1
else:
if content:
diff['after_header'] = destination
else:
diff['after_header'] = source
diff['after'] = to_text(src_contents)
else:
display.debug(u"source of file passed in")
diff['after_header'] = u'dynamically generated'
diff['after'] = source
if self._task.no_log:
if 'before' in diff:
diff["before"] = u""
if 'after' in diff:
diff["after"] = u" [[ Diff output has been hidden because 'no_log: true' was specified for this result ]]\n"
return diff
def _find_needle(self, dirname, needle):
'''
find a needle in haystack of paths, optionally using 'dirname' as a subdir.
This will build the ordered list of paths to search and pass them to dwim
to get back the first existing file found.
'''
# dw
path_stack = self._task.get_search_path()
# if
return self._loader.path_dwim_relative_stack(path_stack, dirname, needle)
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
from __future__ import annotations
from ansible.cli import CLI
import argparse
import functools
import json
import os.path
import pathlib
import re
import shutil
import sys
import textwrap
import time
import typing as t
from dataclasses import dataclass
from yaml.error import YAMLError
import ansible.constants as C
from ansible import context
from ansible.cli.arguments import option_helpers as opt_help
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.galaxy import Galaxy, get_collections_galaxy_meta_info
from ansible.galaxy.api import GalaxyAPI, GalaxyError
from ansible.galaxy.collection import (
build_collection,
download_collections,
find_existing_collections,
install_collections,
publish_collection,
validate_collection_name,
validate_collection_path,
verify_collections,
SIGNATURE_COUNT_RE,
)
from ansible.galaxy.collection.concrete_artifact_manager import (
ConcreteArtifactsManager,
)
from ansible.galaxy.collection.gpg import GPG_ERROR_MAP
from ansible.galaxy.dependency_resolution.dataclasses import Requirement
from ansible.galaxy.role import GalaxyRole
from ansible.galaxy.token import BasicAuthToken, GalaxyToken, KeycloakToken, NoTokenSentinel
from ansible.module_utils.ansible_release import __version__ as ansible_version
from ansible.module_utils.common.collections import is_iterable
from ansible.module_utils.common.yaml import yaml_dump, yaml_load
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.module_utils import six
from ansible.parsing.dataloader import DataLoader
from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.playbook.role.requirement import RoleRequirement
from ansible.template import Templar
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
from ansible.utils.collection_loader import AnsibleCollectionConfig
from ansible.utils.display import Display
from ansible.utils.plugin_docs import get_versioned_doclink
display = Display()
urlparse = six.moves.urllib.parse.urlparse
SERVER_DEF = [
('url', True, 'str'),
('username', False, 'str'),
('password', False, 'str'),
('token', False, 'str'),
('auth_url', False, 'str'),
('api_version', False, 'int'),
('validate_certs', False, 'bool'),
('client_id', False, 'str'),
('timeout', False, 'int'),
]
SERVER_ADDITIONAL = {
'api_version': {'default': None, 'choices': [2, 3]},
'validate_certs': {'cli': [{'name': 'validate_certs'}]},
'timeout': {'default': C.GALAXY_SERVER_TIMEOUT, 'cli': [{'name': 'timeout'}]},
'token': {'default': None},
}
def with_collection_artifacts_manager(wrapped_method):
"""Inject an artifacts manager if not passed explicitly.
This decorator constructs a ConcreteArtifactsManager and maintains
the related temporary directory auto-cleanup around the target
method invocation.
"""
@functools.wraps(wrapped_method)
def method_wrapper(*args, **kwargs):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
if 'artifacts_manager' in kwargs:
return wrapped_method(*args, **kwargs)
artifacts_manager_kwargs = {'validate_certs': context.CLIARGS.get('resolved_validate_certs', True)}
keyring = context.CLIARGS.get('keyring', None)
if keyring is not None:
artifacts_manager_kwargs.update({
'keyring': GalaxyCLI._resolve_path(keyring),
'required_signature_count': context.CLIARGS.get('required_valid_signature_count', None),
'ignore_signature_errors': context.CLIARGS.get('ignore_gpg_errors', None),
})
with ConcreteArtifactsManager.under_tmpdir(
C.DEFAULT_LOCAL_TMP,
**artifacts_manager_kwargs
) as concrete_artifact_cm:
kwargs['artifacts_manager'] = concrete_artifact_cm
return wrapped_method(*args, **kwargs)
return method_wrapper
def _display_header(path, h1, h2, w1=10, w2=7):
display.display('\n# {0}\n{1:{cwidth}} {2:{vwidth}}\n{3} {4}\n'.format(
path,
h1,
h2,
'-' * max([len(h1), w1]),
'-' * max([len(h2), w2]),
cwidth=w1,
vwidth=w2,
))
def _display_role(gr):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
install_info = gr.install_info
version = None
if install_info:
version = install_info.get("version", None)
if not version:
version = "(unknown version)"
display.display("- %s, %s" % (gr.name, version))
def _display_collection(collection, cwidth=10, vwidth=7, min_cwidth=10, min_vwidth=7):
display.display('{fqcn:{cwidth}} {version:{vwidth}}'.format(
fqcn=to_text(collection.fqcn),
version=collection.ver,
cwidth=max(cwidth, min_cwidth),
vwidth=max(vwidth, min_vwidth)
))
def _get_collection_widths(collections):
if not is_iterable(collections):
collections = (collections, )
fqcn_set = {to_text(c.fqcn) for c in collections}
version_set = {to_text(c.ver) for c in collections}
fqcn_length = len(max(fqcn_set or [''], key=len))
version_length = len(max(version_set or [''], key=len))
return fqcn_length, version_length
def validate_signature_count(value):
match = re.match(SIGNATURE_COUNT_RE, value)
if match is None:
raise ValueError(f"{value} is not a valid signature count value")
return value
@dataclass
class RoleDistributionServer:
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
_api: t.Union[GalaxyAPI, None]
api_servers: list[GalaxyAPI]
@property
def api(self):
if self._api:
return self._api
for server in self.api_servers:
try:
if u'v1' in server.available_api_versions:
self._api = server
break
except Exception:
continue
if not self._api:
self._api = self.api_servers[0]
return self._api
class GalaxyCLI(CLI):
'''Command to manage Ansible roles and collections.
None of the CLI tools are designed to run concurrently with themselves.
Use an external scheduler and/or locking to ensure there are no clashing operations.
'''
name = 'ansible-galaxy'
SKIP_INFO_KEYS = ("name", "description", "readme_html", "related", "summary_fields", "average_aw_composite", "average_aw_score", "url")
def __init__(self, args):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
self._raw_args = args
self._implicit_role = False
if len(args) > 1:
if args[1] not in ['-h', '--help', '--version'] and 'role' not in args and 'collection' not in args:
args.insert(1, 'role')
self._implicit_role = True
if args[1:3] == ['role', 'login']:
display.error(
"The login command was removed in late 2020. An API key is now required to publish roles or collections "
"to Galaxy. The key can be found at https://galaxy.ansible.com/me/preferences, and passed to the "
"ansible-galaxy CLI via a file at {0} or (insecurely) via the `--token` "
"command-line argument.".format(to_text(C.GALAXY_TOKEN_PATH)))
sys.exit(1)
self.api_servers = []
self.galaxy = None
self.lazy_role_api = None
super(GalaxyCLI, self).__init__(args)
def init_parser(self):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
''' create an options parser for bin/ansible '''
super(GalaxyCLI, self).init_parser(
desc="Perform various Role and Collection related operations.",
)
common = opt_help.ArgumentParser(add_help=False)
common.add_argument('-s', '--server', dest='api_server', help='The Galaxy API server URL')
common.add_argument('--api-version', type=int, choices=[2, 3], help=argparse.SUPPRESS)
common.add_argument('--token', '--api-key', dest='api_key',
help='The Ansible Galaxy API key which can be found at '
'https://galaxy.ansible.com/me/preferences.')
common.add_argument('-c', '--ignore-certs', action='store_true', dest='ignore_certs', help='Ignore SSL certificate validation errors.', default=None)
common.add_argument('--timeout', dest='timeout', type=int,
help="The time to wait for operations against the galaxy server, defaults to 60s.")
opt_help.add_verbosity_options(common)
force = opt_help.ArgumentParser(add_help=False)
force.add_argument('-f', '--force', dest='force', action='store_true', default=False,
help='Force overwriting an existing role or collection')
github = opt_help.ArgumentParser(add_help=False)
github.add_argument('github_user', help='GitHub username')
github.add_argument('github_repo', help='GitHub repository')
offline = opt_help.ArgumentParser(add_help=False)
offline.add_argument('--offline', dest='offline', default=False, action='store_true',
help="Don't query the galaxy API when creating roles")
default_roles_path = C.config.get_configuration_definition('DEFAULT_ROLES_PATH').get('default', '')
roles_path = opt_help.ArgumentParser(add_help=False)
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
roles_path.add_argument('-p', '--roles-path', dest='roles_path', type=opt_help.unfrack_path(pathsep=True),
default=C.DEFAULT_ROLES_PATH, action=opt_help.PrependListAction,
help='The path to the directory containing your roles. The default is the first '
'writable one configured via DEFAULT_ROLES_PATH: %s ' % default_roles_path)
collections_path = opt_help.ArgumentParser(add_help=False)
collections_path.add_argument('-p', '--collections-path', dest='collections_path', type=opt_help.unfrack_path(pathsep=True),
action=opt_help.PrependListAction,
help="One or more directories to search for collections in addition "
"to the default COLLECTIONS_PATHS. Separate multiple paths "
"with '{0}'.".format(os.path.pathsep))
cache_options = opt_help.ArgumentParser(add_help=False)
cache_options.add_argument('--clear-response-cache', dest='clear_response_cache', action='store_true',
default=False, help='Clear the existing server response cache.')
cache_options.add_argument('--no-cache', dest='no_cache', action='store_true', default=False,
help='Do not use the server response cache.')
type_parser = self.parser.add_subparsers(metavar='TYPE', dest='type')
type_parser.required = True
collection = type_parser.add_parser('collection', help='Manage an Ansible Galaxy collection.')
collection.set_defaults(func=self.execute_collection)
collection_parser = collection.add_subparsers(metavar='COLLECTION_ACTION', dest='action')
collection_parser.required = True
self.add_download_options(collection_parser, parents=[common, cache_options])
self.add_init_options(collection_parser, parents=[common, force])
self.add_build_options(collection_parser, parents=[common, force])
self.add_publish_options(collection_parser, parents=[common])
self.add_install_options(collection_parser, parents=[common, force, cache_options])
self.add_list_options(collection_parser, parents=[common, collections_path])
self.add_verify_options(collection_parser, parents=[common, collections_path])
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
role = type_parser.add_parser('role', help='Manage an Ansible Galaxy role.')
role.set_defaults(func=self.execute_role)
role_parser = role.add_subparsers(metavar='ROLE_ACTION', dest='action')
role_parser.required = True
self.add_init_options(role_parser, parents=[common, force, offline])
self.add_remove_options(role_parser, parents=[common, roles_path])
self.add_delete_options(role_parser, parents=[common, github])
self.add_list_options(role_parser, parents=[common, roles_path])
self.add_search_options(role_parser, parents=[common])
self.add_import_options(role_parser, parents=[common, github])
self.add_setup_options(role_parser, parents=[common, roles_path])
self.add_info_options(role_parser, parents=[common, roles_path, offline])
self.add_install_options(role_parser, parents=[common, force, roles_path])
def add_download_options(self, parser, parents=None):
download_parser = parser.add_parser('download', parents=parents,
help='Download collections and their dependencies as a tarball for an '
'offline install.')
download_parser.set_defaults(func=self.execute_download)
download_parser.add_argument('args', help='Collection(s)', metavar='collection', nargs='*')
download_parser.add_argument('-n', '--no-deps', dest='no_deps', action='store_true', default=False,
help="Don't download collection(s) listed as dependencies.")
download_parser.add_argument('-p', '--download-path', dest='download_path',
default='./collections',
help='The directory to download the collections to.')
download_parser.add_argument('-r', '--requirements-file', dest='requirements',
help='A file containing a list of collections to be downloaded.')
download_parser.add_argument('--pre', dest='allow_pre_release', action='store_true',
help='Include pre-release versions. Semantic versioning pre-releases are ignored by default')
def add_init_options(self, parser, parents=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
galaxy_type = 'collection' if parser.metavar == 'COLLECTION_ACTION' else 'role'
init_parser = parser.add_parser('init', parents=parents,
help='Initialize new {0} with the base structure of a '
'{0}.'.format(galaxy_type))
init_parser.set_defaults(func=self.execute_init)
init_parser.add_argument('--init-path', dest='init_path', default='./',
help='The path in which the skeleton {0} will be created. The default is the '
'current working directory.'.format(galaxy_type))
init_parser.add_argument('--{0}-skeleton'.format(galaxy_type), dest='{0}_skeleton'.format(galaxy_type),
default=C.GALAXY_COLLECTION_SKELETON if galaxy_type == 'collection' else C.GALAXY_ROLE_SKELETON,
help='The path to a {0} skeleton that the new {0} should be based '
'upon.'.format(galaxy_type))
obj_name_kwargs = {}
if galaxy_type == 'collection':
obj_name_kwargs['type'] = validate_collection_name
init_parser.add_argument('{0}_name'.format(galaxy_type), help='{0} name'.format(galaxy_type.capitalize()),
**obj_name_kwargs)
if galaxy_type == 'role':
init_parser.add_argument('--type', dest='role_type', action='store', default='default',
help="Initialize using an alternate role type. Valid types include: 'container', "
"'apb' and 'network'.")
def add_remove_options(self, parser, parents=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
remove_parser = parser.add_parser('remove', parents=parents, help='Delete roles from roles_path.')
remove_parser.set_defaults(func=self.execute_remove)
remove_parser.add_argument('args', help='Role(s)', metavar='role', nargs='+')
def add_delete_options(self, parser, parents=None):
delete_parser = parser.add_parser('delete', parents=parents,
help='Removes the role from Galaxy. It does not remove or alter the actual '
'GitHub repository.')
delete_parser.set_defaults(func=self.execute_delete)
def add_list_options(self, parser, parents=None):
galaxy_type = 'role'
if parser.metavar == 'COLLECTION_ACTION':
galaxy_type = 'collection'
list_parser = parser.add_parser('list', parents=parents,
help='Show the name and version of each {0} installed in the {0}s_path.'.format(galaxy_type))
list_parser.set_defaults(func=self.execute_list)
list_parser.add_argument(galaxy_type, help=galaxy_type.capitalize(), nargs='?', metavar=galaxy_type)
if galaxy_type == 'collection':
list_parser.add_argument('--format', dest='output_format', choices=('human', 'yaml', 'json'), default='human',
help="Format to display the list of collections in.")
def add_search_options(self, parser, parents=None):
search_parser = parser.add_parser('search', parents=parents,
help='Search the Galaxy database by tags, platforms, author and multiple '
'keywords.')
search_parser.set_defaults(func=self.execute_search)
search_parser.add_argument('--platforms', dest='platforms', help='list of OS platforms to filter by')
search_parser.add_argument('--galaxy-tags', dest='galaxy_tags', help='list of galaxy tags to filter by')
search_parser.add_argument('--author', dest='author', help='GitHub username')
search_parser.add_argument('args', help='Search terms', metavar='searchterm', nargs='*')
def add_import_options(self, parser, parents=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
import_parser = parser.add_parser('import', parents=parents, help='Import a role into a galaxy server')
import_parser.set_defaults(func=self.execute_import)
import_parser.add_argument('--no-wait', dest='wait', action='store_false', default=True,
help="Don't wait for import results.")
import_parser.add_argument('--branch', dest='reference',
help='The name of a branch to import. Defaults to the repository\'s default branch '
'(usually master)')
import_parser.add_argument('--role-name', dest='role_name',
help='The name the role should have, if different than the repo name')
import_parser.add_argument('--status', dest='check_status', action='store_true', default=False,
help='Check the status of the most recent import request for given github_'
'user/github_repo.')
def add_setup_options(self, parser, parents=None):
setup_parser = parser.add_parser('setup', parents=parents,
help='Manage the integration between Galaxy and the given source.')
setup_parser.set_defaults(func=self.execute_setup)
setup_parser.add_argument('--remove', dest='remove_id', default=None,
help='Remove the integration matching the provided ID value. Use --list to see '
'ID values.')
setup_parser.add_argument('--list', dest="setup_list", action='store_true', default=False,
help='List all of your integrations.')
setup_parser.add_argument('source', help='Source')
setup_parser.add_argument('github_user', help='GitHub username')
setup_parser.add_argument('github_repo', help='GitHub repository')
setup_parser.add_argument('secret', help='Secret')
def add_info_options(self, parser, parents=None):
info_parser = parser.add_parser('info', parents=parents, help='View more details about a specific role.')
info_parser.set_defaults(func=self.execute_info)
info_parser.add_argument('args', nargs='+', help='role', metavar='role_name[,version]')
def add_verify_options(self, parser, parents=None):
|
closed
|
ansible/ansible
|
https://github.com/ansible/ansible
| 82,175 |
ansible-galaxy role import always exits 0 even if import failed
|
### Summary
When a role import fails, the galaxy cli code does not alter the exit code for the command accordingly. It is always zero.
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py#L1818C1-L1833C17
```
if context.CLIARGS['check_status'] or context.CLIARGS['wait']:
# Get the status of the import
msg_list = []
finished = False
while not finished:
task = self.api.get_import_task(task_id=task[0]['id'])
for msg in task[0]['summary_fields']['task_messages']:
if msg['id'] not in msg_list:
display.display(msg['message_text'], color=colors[msg['message_type']])
msg_list.append(msg['id'])
if task[0]['state'] in ['SUCCESS', 'FAILED']:
finished = True
else:
time.sleep(10)
return 0
```
The code knows the task is "finished" if state is either SUCCESS or FAILED, but the FAILED state does not affect the return value.
### Issue Type
Bug Report
### Component Name
ansible-galaxy
### Ansible Version
```console
(venv) [jtanner@p1 galaxy_ng.role_exception_logging]$ ansible-galaxy --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying
out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible-galaxy [core 2.17.0.dev0] (devel fd009a073a) last updated 2023/11/08 12:01:58 (GMT -400)
config file = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.cfg
configured module search path = ['/home/jtanner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/lib/ansible
ansible collection location = /home/jtanner/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/ansible.core/bin/ansible-galaxy
python version = 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/home/jtanner/workspace/github/jctanner.redhat/galaxy_ng.role_exception_logging/venv/bin/python)
jinja version = 3.1.2
libyaml = True
```
### Configuration
```console
N/A
```
### OS / Environment
Fedora 38
### Steps to Reproduce
1. Setup a galaxy server
2. ansible-galaxy role import -vvvv nephelaiio ansible-role-packetbeat
### Expected Results
The ansible-galaxy command should exit non-zero if the task is in a FAILED state.
### Actual Results
```console
exit 0
```
### Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
|
https://github.com/ansible/ansible/issues/82175
|
https://github.com/ansible/ansible/pull/82193
|
7f2ad7eea673233223948e0d2a9fc5ee683040ce
|
fe81164fe548d79fbcd0024836d5f7474403c95d
| 2023-11-08T17:14:35Z |
python
| 2023-12-12T18:59:19Z |
lib/ansible/cli/galaxy.py
|
galaxy_type = 'collection'
verify_parser = parser.add_parser('verify', parents=parents, help='Compare checksums with the collection(s) '
'found on the server and the installed copy. This does not verify dependencies.')
verify_parser.set_defaults(func=self.execute_verify)
verify_parser.add_argument('args', metavar='{0}_name'.format(galaxy_type), nargs='*', help='The installed collection(s) name. '
'This is mutually exclusive with --requirements-file.')
verify_parser.add_argument('-i', '--ignore-errors', dest='ignore_errors', action='store_true', default=False,
help='Ignore errors during verification and continue with the next specified collection.')
verify_parser.add_argument('--offline', dest='offline', action='store_true', default=False,
help='Validate collection integrity locally without contacting server for '
'canonical manifest hash.')
verify_parser.add_argument('-r', '--requirements-file', dest='requirements',
help='A file containing a list of collections to be verified.')
verify_parser.add_argument('--keyring', dest='keyring', default=C.GALAXY_GPG_KEYRING,
help='The keyring used during signature verification')
verify_parser.add_argument('--signature', dest='signatures', action='append',
help='An additional signature source to verify the authenticity of the MANIFEST.json before using '
'it to verify the rest of the contents of a collection from a Galaxy server. Use in '
'conjunction with a positional collection name (mutually exclusive with --requirements-file).')
valid_signature_count_help = 'The number of signatures that must successfully verify the collection. This should be a positive integer ' \
'or all to signify that all signatures must be used to verify the collection. ' \
'Prepend the value with + to fail if no valid signatures are found for the collection (e.g. +all).'
ignore_gpg_status_help = 'A space separated list of status codes to ignore during signature verification (for example, NO_PUBKEY FAILURE). ' \
'Descriptions for the choices can be seen at L(https://github.com/gpg/gnupg/blob/master/doc/DETAILS#general-status-codes).' \
'Note: specify these after positional arguments or use -- to separate them.'
verify_parser.add_argument('--required-valid-signature-count', dest='required_valid_signature_count', type=validate_signature_count,
help=valid_signature_count_help, default=C.GALAXY_REQUIRED_VALID_SIGNATURE_COUNT)
verify_parser.add_argument('--ignore-signature-status-code', dest='ignore_gpg_errors', type=str, action='append',
help=opt_help.argparse.SUPPRESS, default=C.GALAXY_IGNORE_INVALID_SIGNATURE_STATUS_CODES,
choices=list(GPG_ERROR_MAP.keys()))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.