community.vmware icon indicating copy to clipboard operation
community.vmware copied to clipboard

vmware_cfg_backup doesn´t create a file

Open Callahan78 opened this issue 3 years ago • 4 comments

COMPONENT NAME community.vmware.vmware_cfg_backup

Hi all, I want to use vmware_cfg_backup module to create config backup from by ESXi 7.0.

My ansible script is:

- hosts: all
  tasks:
     - name: ESXI backup
       local_action:
           module: vmware_cfg_backup
           hostname: name_of_vcenter
           validate_certs: no
           esxi_hostname: name_of_esx_host
           username: [email protected]
           password: *password*
           state: saved
           dest: /tmp/

Script runs successful without erros:

SSH password: 
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ok: [name_of_esx_host]
TASK [ESXI backup] ********************************************************
changed: [name_of_esx_host -> localhost]
PLAY RECAP *********************************************************************
name_of_esx_host        : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  

Syslog in ESX says:

2022-07-16T21:31:00.070Z sftp-server[2828203]: session opened for local user root from [192.168.20.83]
2022-07-16T21:31:00.071Z sftp-server[2828203]: sent status No such file
2022-07-16T21:31:00.071Z sftp-server[2828203]: open "/.ansible/tmp/ansible-tmp-1658007059.7049987-19-49891153652909/AnsiballZ_setup.py" flags WRITE,CREATE,TRUNCATE mode 0600
2022-07-16T21:31:00.077Z sftp-server[2828203]: close "/.ansible/tmp/ansible-tmp-1658007059.7049987-19-49891153652909/AnsiballZ_setup.py" bytes read 0 written 265755
2022-07-16T21:31:00.077Z sftp-server[2828203]: session closed for local user root from [192.168.20.83]
2022-07-16T21:31:00.472Z ansible-setup[2828210]: Invoked with gather_subset=['all'] gather_timeout=10 filter=* fact_path=/etc/ansible/facts.d
2022-07-16T21:31:02.817Z backup.sh[2828224]: Saving current state in /usr/lib/vmware/hostd/docroot/downloads/52614ced-640e-acdc-8423-f1b66c09150c/firmware-backup.$$
2022-07-16T21:31:03.101Z backup.sh[2828224]: Creating ConfigStore Backup
2022-07-16T21:31:03.108Z configStoreBackup[2828323]: ConfigStore backup completed successfully
2022-07-16T21:31:03.108Z configStoreBackup[2828323]: ConfigStore backup completed with rc = 101
2022-07-16T21:31:03.108Z configStoreBackup[2828323]: ConfigStore backup completed successfully
2022-07-16T21:31:03.109Z configStoreBackup[2828323]: ConfigStore backup completed with rc = 101
2022-07-16T21:31:03.217Z backup.sh[2828224]: Locking esx.conf
2022-07-16T21:31:03.273Z backup.sh[2828224]: Creating archive
2022-07-16T21:31:03.368Z backup.sh[2828224]: Unlocked esx.conf
2022-07-16T21:31:03.399Z backup.sh[2828224]: Using key ID  886fb94b-0da2-458b-b2cd-b180ea6a4a0e to encrypt
2022-07-16T21:31:04.335Z addvob[2828374]: Log for VMware ESXi version=7.0.3 build=build-19482537 option=Release
2022-07-16T21:31:04.335Z addvob[2828374]: Could not expand environment variable HOME.
2022-07-16T21:31:04.335Z addvob[2828374]: Could not expand environment variable HOME.
2022-07-16T21:31:04.335Z addvob[2828374]: Using VMware ESXi syslog APIs

For my point of view everthing looks good.

But there is no file in /tmp

I tried many variations of the ansible script and some run withous errors but at the end there is no file . . .

Any suggestions?

Callahan78 avatar Jul 17 '22 20:07 Callahan78

Files identified in the description: None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar Jul 17 '22 20:07 ansibullbot

@Callahan78: Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information.

Here are the items we could not find in your description:

  • component name

Please set the description of this issue with this template: https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE/bug_report.md

click here for bot help

ansibullbot avatar Jul 17 '22 20:07 ansibullbot

Wait a second... this:

SSH password: 
PLAY [all] *********************************************************************

and this:

Syslog in ESX says:

2022-07-16T21:31:00.070Z sftp-server[2828203]: session opened for local user root from [192.168.20.83]
2022-07-16T21:31:00.071Z sftp-server[2828203]: sent status No such file
2022-07-16T21:31:00.071Z sftp-server[2828203]: open "/.ansible/tmp/ansible-tmp-1658007059.7049987-19-49891153652909/AnsiballZ_setup.py" flags WRITE,CREATE,TRUNCATE mode 0600
2022-07-16T21:31:00.077Z sftp-server[2828203]: close "/.ansible/tmp/ansible-tmp-1658007059.7049987-19-49891153652909/AnsiballZ_setup.py" bytes read 0 written 265755

looks a bit like your SSHing into the host and run the module there.

I don't know local_action, but if I understand the documentation correctly it should work. However, could you please try delegate_to: localhost:

- hosts: all
  tasks:
     - name: ESXI backup
       community.vmware.vmware_cfg_backup:
         hostname: name_of_vcenter
         validate_certs: no
         esxi_hostname: name_of_esx_host
         username: [email protected]
         password: *password*
         state: saved
         dest: /tmp/
       delegate_to: localhost

mariolenz avatar Jul 21 '22 11:07 mariolenz

I also tried with delegate_to option (one of the many variations) with exactly the same result. And you´re right, according to the documentation it should work . . . Meanwhile I use the simple way:

- hosts: all
  tasks:
    - name: Run a script using an executable in a system path
      ansible.builtin.shell: /bin/firmwareConfig.py --backup /tmp

Maybe not the finest solution, but it works :-)

Callahan78 avatar Jul 21 '22 19:07 Callahan78