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 30, 2020 in Ansible by akhtar
• 38,260 points
2,385 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,460 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,460 points
7,658 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 30, 2020 in Ansible by MD
• 95,460 points
2,596 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,034 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,460 points
11,238 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,460 points
3,366 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP