How to copy files in remote system using Ansible

0 votes

Hi Guys,

I have some files in my local system. I want to copy these files into all remote systems. How can I do that in Ansible?

Jul 29, 2020 in Ansible by akhtar
• 38,180 points
294 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to use the copy module in your Ansible command. It allows you to copy files to a remote node. You can use the below command.

[root@localhost ~]# ansible all -m copy -a "src=home.html dest=/var/www/html/"
192.168.0.179 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "checksum": "6b788f3f7b8c05352bccc93a67cc13d92f9a7618",
    "dest": "/var/www/html/home.html",
    "gid": 0,
    "group": "root",
    "md5sum": "4900bfba2c30719632632fc4186083e0",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:httpd_sys_content_t:s0",
    "size": 19,
    "src": "/root/.ansible/tmp/ansible-tmp-1596045930.753713-14383-112197138626631/source",
    "state": "file",
    "uid": 0
}

answered Jul 30, 2020 by MD
• 95,240 points

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

How to disable swap in remote system using Ansible?

Hi@akhtar, You can use the mount module in ...READ MORE

answered Sep 16, 2020 in Ansible by MD
• 95,240 points
1,834 views
0 votes
1 answer

How to install httpd web server in remote node using Ansible?

Hi@akhtar, You need to use the package module in Ansible. ...READ MORE

answered Jul 29, 2020 in Ansible by MD
• 95,240 points
687 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,197 views
+2 votes
1 answer
0 votes
1 answer

How to copy multiple files to remote system using Ansible Playbook?

Hi@akhtar, You can use the copy module in ...READ MORE

answered Sep 16, 2020 in Ansible by MD
• 95,240 points
3,803 views
0 votes
1 answer

How to start httpd service in a remote system using Ansible?

Hi@akhtar, Ansible has a module named service. This ...READ MORE

answered Jul 30, 2020 in Ansible by MD
• 95,240 points
661 views