Ansible Playbook Succeeds on One GCP VM but has No Effect on Another Identical VM

Hello all, I am encountering an issue with an Ansible playbook that runs successfully on one GCP Ubuntu VM us3tab01 but has no effect on another identical VM us3tab02. Both VMs are configured similarly, and Ansible can successfully ping both hosts.

create-file.yaml

---
- name: Create a file in the home directory
  hosts: tab_clusters
  become: true 
  become_user: tableau-admin
  gather_facts: true
  tasks:
    - name: Create empty file
      file:
        path: "/home/tableau-admin/test.log"
        state: touch
        mode: '0644'

hosts.ini

[tab_clusters]
us3tab01 ansible_host=us3tab01 ansible_ssh_private_key_file=XXXX
us3tab02 ansible_host=us3tab02 ansible_ssh_private_key_file=XXXX
  • ansible
  • ansible-playbook

Steps Taken:

I’ve verified the following:

  1. Successful ansible -m ping to both VMs
  2. Identical playbook code
  3. SSH key permissions for the user
  4. I’ve tried Increasing Ansible verbosity(-vvv)
  5. Manually SSH’ing into us3tab02 VM as a tableau-admin user and can successfully create a file with no issues.

Details:

  • Ansible Version: 2.16.7
  • OS: Ubuntu 20.04 on both VMs
  • SSH Connectivity: Verified, Ansible can ping both VMs successfully.
  • User: tableau-admin exists on both VMs with identical permissions.
  • Disk Space: Adequate on both VMs.
  • Filesystem: No errors detected.

Despite these checks, the playbook executes successfully on us3tab01 and us3tab02 but does not create the specified files in the us3tab02 interestingly the file is created successfully in the us3tab01 VM. The specific verbose output does not show any errors and executed success.

I’ve searched for similar issues on the forum, but haven’t found a solution that works in my case. Any help would be greatly appreciated!

Hi,

but has no effect on another identical VM

What do you mean precisely ? Is your tasks marked as ‘changed’ on both hosts when you run your playbook, or is there something else to infer what you say ?

Could you post output for a fresh ansible-playbook run (with no existing file at specified destination) ? Also the exact command you’re running.

Manually SSH’ing into us3tab02 VM as a tableau-admin user and can successfully create a file with no issues.

Dumb question perhaps, but did you try manually create this file on the same defined path as your task’s ?

I’ve tried Increasing Ansible verbosity(-vvv)

Did you see something different between your task on both hosts ?

Is there something else in your playbook you’re not showing in your post ? Other tasks or handlers perhaps ?

Would it be possible “/home/tableau-admin/” mountpoint to be on a shared storage to both VM ?

Also, please note become_user is not the same as ansible_user; with this playbook as is, you are authenticating on remote hosts as the user you are logged in on your control node (or the one defined in your potential ssh client config), then task would be run on remote hosts with ‘tableau-admin’ user using sudo. Have you manually tried this exact scenario ?

Could it be possible you forgot to pass sudo password to your command, or have not configured sudoers on remote hosts to run this module passwordless ?
I doubt it if you indeed provisioned and configured both hosts the same way, but better ask !