Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backup_file missing when modifying /etc/fstab #533

Open
timothynfarmer opened this issue Feb 27, 2024 · 0 comments
Open

backup_file missing when modifying /etc/fstab #533

timothynfarmer opened this issue Feb 27, 2024 · 0 comments

Comments

@timothynfarmer
Copy link

SUMMARY
ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
ansible [core 2.16.4]
  config file = /Users/user/ansible/playbook/ansible.cfg
  configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/user/ansible/playbook/venv/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/user/ansible/playbook
  executable location = /Users/user/playbook/venv/bin/ansible
  python version = 3.11.4 (main, Aug 21 2023, 11:28:34) [Clang 12.0.5 (clang-1205.0.22.9)] (/Users/user/ansible/playbook/venv/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /Users/user/playbook//ansible_collections
Collection    Version
------------- -------
ansible.posix 1.5.4
CONFIGURATION
ANSIBLE_NOCOWS(/Users/user/ansible/playbook/ansible.cfg) = True
CACHE_PLUGIN(/Users/user/ansible/playbook/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/Users/user/ansible/playbook/ansible.cfg) = ./facts.d/
COLLECTIONS_PATHS(/Users/user/ansible/playbook/ansible.cfg) = ['/Users/user/ansible/playbook']
CONFIG_FILE() = /Users/user/ansible/playbook/ansible.cfg
DEFAULT_ROLES_PATH(/Users/user/ansible/playbook/ansible.cfg) = ['/Users/user/ansible/playbook/roles>
PAGER(env: PAGER) = less
OS / ENVIRONMENT

Target is CentOS 7 server

STEPS TO REPRODUCE

Modify fstab and remove an entry with backup: true

  - name: Print if NFS
    ansible.builtin.debug:
      # msg: "NFS Mount Detected {{ item.dev }}"
      var: item
    when: nfs | length > 0
    vars:
      nfs: "{{ ansible_mounts | community.general.json_query('[?contains(fstype, `nfs`)]') }}"
    with_items: "{{ nfs }}"

  - name: Remove network shares from fstab
    ansible.posix.mount:
      path: "{{ item.mount }}"
      src: "{{ item.device }}"
      state: absent_from_fstab
      backup: yes
    vars:
      nm: "{{ ansible_mounts | community.general.json_query('[?contains(fstype, `nfs`) || contains(fstype, `cifs`)]') }}"
    with_items: "{{ nm }}"
    when: (nm | length) > 0
    register: rem_nfs

  - name: Print out the output
    ansible.builtin.debug:
      var: rem_nfs
EXPECTED RESULTS

I would expect to get the results and have backup_file defined but it's not. It's empty and the backup_file is created.

ACTUAL RESULTS
TASK [Remove network shares from fstab] ******************************************************************************
task path: /Users/user/ansible/playbook/facts.yml:68
Loading collection community.general from /Users/user/ansible/playbook/ansible_collections/community/general
<server> ESTABLISH SSH CONNECTION FOR USER: None
<server> SSH: EXEC sshpass -d44 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o 'ControlPath="/Users/user/.ansible/cp/70666108ae"' server '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<server> (0, b'/home/remote_user\n', b'OpenSSH_9.4p1, LibreSSL 3.3.6\r\ndebug1: Reading configuration data /Users/user/.ssh/config\r\ndebug1: /Users/user/.ssh/config line 1: Applying options for *\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files\r\ndebug1: /etc/ssh/ssh_config line 54: Applying options for *\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 49917\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<server> ESTABLISH SSH CONNECTION FOR USER: None
<server> SSH: EXEC sshpass -d44 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o 'ControlPath="/Users/user/.ansible/cp/70666108ae"' server '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/remote_user/.ansible/tmp `"&& mkdir "` echo /home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965 `" && echo ansible-tmp-1709069096.46433-50785-250687617332965="` echo /home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965 `" ) && sleep 0'"'"''
<server> (0, b'ansible-tmp-1709069096.46433-50785-250687617332965=/home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965\n', b'OpenSSH_9.4p1, LibreSSL 3.3.6\r\ndebug1: Reading configuration data /Users/user/.ssh/config\r\ndebug1: /Users/user/.ssh/config line 1: Applying options for *\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files\r\ndebug1: /etc/ssh/ssh_config line 54: Applying options for *\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 49917\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
Using module file /Users/user/ansible/playbook/ansible_collections/ansible/posix/plugins/modules/mount.py
<server> PUT /Users/user/.ansible/tmp/ansible-local-49445wvxcx9f6/tmpujcbxom0 TO /home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/AnsiballZ_mount.py
<server> SSH: EXEC sshpass -d44 sftp -o BatchMode=no -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o 'ControlPath="/Users/user/.ansible/cp/70666108ae"' '[server]'
<server> (0, b'sftp> put /Users/user/.ansible/tmp/ansible-local-49445wvxcx9f6/tmpujcbxom0 /home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/AnsiballZ_mount.py\n', b'OpenSSH_9.4p1, LibreSSL 3.3.6\r\ndebug1: Reading configuration data /Users/user/.ssh/config\r\ndebug1: /Users/user/.ssh/config line 1: Applying options for *\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files\r\ndebug1: /etc/ssh/ssh_config line 54: Applying options for *\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 49917\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug2: Remote version: 3\r\ndebug2: Server supports extension "[email protected]" revision 1\r\ndebug2: Server supports extension "[email protected]" revision 2\r\ndebug2: Server supports extension "[email protected]" revision 2\r\ndebug2: Server supports extension "[email protected]" revision 1\r\ndebug2: Server supports extension "[email protected]" revision 1\r\ndebug2: Sending SSH2_FXP_REALPATH "."\r\ndebug3: Sent message fd 3 T:16 I:1\r\ndebug3: SSH2_FXP_REALPATH . -> /home/remote_user\r\ndebug3: Looking up /Users/user/.ansible/tmp/ansible-local-49445wvxcx9f6/tmpujcbxom0\r\ndebug2: Sending SSH2_FXP_STAT "/home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/AnsiballZ_mount.py"\r\ndebug3: Sent message fd 3 T:17 I:2\r\ndebug1: stat remote: No such file or directory\r\ndebug2: do_upload: upload local "/Users/user/.ansible/tmp/ansible-local-49445wvxcx9f6/tmpujcbxom0" to remote "/home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/AnsiballZ_mount.py"\r\ndebug2: Sending SSH2_FXP_OPEN "/home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/AnsiballZ_mount.py"\r\ndebug3: Sent dest message SSH2_FXP_OPEN I:3 P:/home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/AnsiballZ_mount.py M:0x001a\r\ndebug3: Sent message SSH2_FXP_WRITE I:5 O:0 S:32768\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 5 32768 bytes at 0\r\ndebug3: Sent message SSH2_FXP_WRITE I:6 O:32768 S:32768\r\ndebug3: Sent message SSH2_FXP_WRITE I:7 O:65536 S:32768\r\ndebug3: Sent message SSH2_FXP_WRITE I:8 O:98304 S:32768\r\ndebug3: Sent message SSH2_FXP_WRITE I:9 O:131072 S:8662\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 6 32768 bytes at 32768\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 7 32768 bytes at 65536\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 8 32768 bytes at 98304\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 9 8662 bytes at 131072\r\ndebug3: Sent message SSH2_FXP_CLOSE I:4\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<server> ESTABLISH SSH CONNECTION FOR USER: None
<server> SSH: EXEC sshpass -d44 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o 'ControlPath="/Users/user/.ansible/cp/70666108ae"' server '/bin/sh -c '"'"'chmod u+x /home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/ /home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/AnsiballZ_mount.py && sleep 0'"'"''
<server> (0, b'', b'OpenSSH_9.4p1, LibreSSL 3.3.6\r\ndebug1: Reading configuration data /Users/user/.ssh/config\r\ndebug1: /Users/user/.ssh/config line 1: Applying options for *\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files\r\ndebug1: /etc/ssh/ssh_config line 54: Applying options for *\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 49917\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<server> ESTABLISH SSH CONNECTION FOR USER: None
<server> SSH: EXEC sshpass -d44 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o 'ControlPath="/Users/user/.ansible/cp/70666108ae"' -tt server '/bin/sh -c '"'"'sudo -H -S -p "[sudo via ansible, key=tqbnxmcuqeslucfeopatabokrmelckkk] password:" -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-tqbnxmcuqeslucfeopatabokrmelckkk ; /usr/bin/python /home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/AnsiballZ_mount.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<server> (0, b'\r\n{"src": "nfs:/mount", "fstab": "/etc/fstab", "backup_file": "", "name": "/nfs/mnt", "dump": "0", "warnings": [], "passno": "0", "changed": true, "boot": "yes", "invocation": {"module_args": {"src": "nfs:/mount", "dump": "0", "boot": true, "fstab": null, "passno": "0", "fstype": null, "state": "absent_from_fstab", "path": "/nfs/mnt", "backup": true, "opts": null}}, "opts": "defaults"}\r\n', b'OpenSSH_9.4p1, LibreSSL 3.3.6\r\ndebug1: Reading configuration data /Users/user/.ssh/config\r\ndebug1: /Users/user/.ssh/config line 1: Applying options for *\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files\r\ndebug1: /etc/ssh/ssh_config line 54: Applying options for *\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 49917\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to server closed.\r\n')
<server> ESTABLISH SSH CONNECTION FOR USER: None
<server> SSH: EXEC sshpass -d44 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o 'ControlPath="/Users/user/.ansible/cp/70666108ae"' server '/bin/sh -c '"'"'rm -f -r /home/remote_user/.ansible/tmp/ansible-tmp-1709069096.46433-50785-250687617332965/ > /dev/null 2>&1 && sleep 0'"'"''
<server> (0, b'', b'OpenSSH_9.4p1, LibreSSL 3.3.6\r\ndebug1: Reading configuration data /Users/user/.ssh/config\r\ndebug1: /Users/user/.ssh/config line 1: Applying options for *\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files\r\ndebug1: /etc/ssh/ssh_config line 54: Applying options for *\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 49917\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
changed: [server] => (item={'block_used': 33668, 'uuid': 'N/A', 'size_total': 26843545600, 'block_total': 102400, 'mount': '/nfs/mnt', 'block_available': 68732, 'size_available': 18017681408, 'fstype': 'nfs4', 'inode_total': 32487664, 'inode_available': 32483900, 'device': 'nfs:/mount', 'inode_used': 3764, 'block_size': 262144, 'options': 'rw,nodev,relatime,vers=4.1,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.28.114.105,local_lock=none,addr=172.28.49.101'}) => {
    "ansible_loop_var": "item",
    "backup_file": "",
    "boot": "yes",
    "changed": true,
    "dump": "0",
    "fstab": "/etc/fstab",
    "invocation": {
        "module_args": {
            "backup": true,
            "boot": true,
            "dump": "0",
            "fstab": null,
            "fstype": null,
            "opts": null,
            "passno": "0",
            "path": "/nfs/mnt",
            "src": "nfs:/mount",
            "state": "absent_from_fstab"
        }
    },
    "item": {
        "block_available": 68732,
        "block_size": 262144,
        "block_total": 102400,
        "block_used": 33668,
        "device": "nfs:/mount",
        "fstype": "nfs4",
        "inode_available": 32483900,
        "inode_total": 32487664,
        "inode_used": 3764,
        "mount": "/nfs/mnt",
        "options": "rw,nodev,relatime,vers=4.1,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.28.114.105,local_lock=none,addr=172.28.49.101",
        "size_available": 18017681408,
        "size_total": 26843545600,
        "uuid": "N/A"
    },
    "name": "/nfs/mnt",
    "opts": "defaults",
    "passno": "0",
    "src": "nfs:/mount"
}

TASK [Print out the output] ******************************************************************************************
task path: /Users/user/ansible/playbook/facts.yml:80
ok: [server] => {
    "rem_nfs": {
        "changed": true,
        "msg": "All items completed",
        "results": [
            {
                "ansible_loop_var": "item",
                "backup_file": "",
                "boot": "yes",
                "changed": true,
                "dump": "0",
                "failed": false,
                "fstab": "/etc/fstab",
                "invocation": {
                    "module_args": {
                        "backup": true,
                        "boot": true,
                        "dump": "0",
                        "fstab": null,
                        "fstype": null,
                        "opts": null,
                        "passno": "0",
                        "path": "/nfs/mnt",
                        "src": "nfs:/mount",
                        "state": "absent_from_fstab"
                    }
                },
                "item": {
                    "block_available": 68732,
                    "block_size": 262144,
                    "block_total": 102400,
                    "block_used": 33668,
                    "device": "nfs:/mount",
                    "fstype": "nfs4",
                    "inode_available": 32483900,
                    "inode_total": 32487664,
                    "inode_used": 3764,
                    "mount": "/nfs/mnt",
                    "options": "rw,nodev,relatime,vers=4.1,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.28.114.105,local_lock=none,addr=172.28.49.101",
                    "size_available": 18017681408,
                    "size_total": 26843545600,
                    "uuid": "N/A"
                },
                "name": "/nfs/mnt",
                "opts": "defaults",
                "passno": "0",
                "src": "nfs:/mount"
            }
        ],
        "skipped": false
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant