0
votes

this is a part of code:

- name: backup tomcat_jira_init.tar.gz
  archive:
    path: /etc/init.d/tomcat_jira
    dest: /home/alessio/Jira_Backup2/tomcat_jira_init.tar.gz

the error is :

TASK [backup tomcat_jira_init.tar.gz] **********************************************************************************************************************************
fatal: [node-1]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 172.27.5.40 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_robzvq/ansible_module_archive.py\", line 486, in \r\n main()\r\n File \"/tmp/ansible_robzvq/ansible_module_archive.py\", line 434, in main\r\n f_out = gzip.open(dest, 'wb')\r\n File \"/usr/lib64/python2.7/gzip.py\", line 34, in open\r\n return GzipFile(filename, mode, compresslevel)\r\n File \"/usr/lib64/python2.7/gzip.py\", line 94, in __init__\r\n fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')\r\nIOError: [Errno 2] No such file or directory: '/home/alessio/Jira_Backup2/'\r\n", "msg": "MODULE FAILURE", "rc": 1} to retry, use: --limit @/home/alessio/apache-basic-playbook/test3.retry

Any suggestions?

1
The message provided is self-explanatory - Baptiste Mille-Mathias
yes, I understood the problem: the problem is that the remote machine looks for that path in its machine and not in my own fregandosene command "remote_src: yes" In fact, if I remove it, it works but I would like it to run directly in the machine from which I launch the command .. - Aless1995

1 Answers

0
votes

You are confusing local modules and remote modules. Remember that Ansible fundamentally builds a script, uploads that to the remote machine and then executes it on the remote machine. Remembering that, it makes sense that both the path and dest refer to the remote machine, not the 'controller' machine. For the majority of modules, the scripts produced have no clue that they were generated elsewhere and uploaded to the target machine.

You need to archive your file out to a temporary file, fetch it using the fetch module, then delete (or not) the temporary archive at the remote end.

- name: backup tomcat_jira_init.tar.gz
  archive:
    path: /etc/init.d/tomcat_jira
    dest: /tmp/tomcat_jira_init.tar.gz

- name: pull the aerchive from the remote machine
  fetch:
    src: /tmp/tomcat_jira_init.tar.gz
    dest: /home/alessio/Jira_Backup2/
    flat: yes

- name: (optionally) delete the temp archive at the remote end
  file:
    path: /tmp/tomcat_jira_init.tar.gz
    state: absent