I am new to ansible and need suggestion as I how to perform different task in different hosts.
I need to setup jdk & wls in one host and move the binaries(jdk/wls) from same server to other servers.
I was able to setup on one server(01) but want to move to other hosts(02/03) instead of setting up.What is the ideal approach to do without copying to temporary location & iterate on other servers.
Do you have a specific question about the above playbook?
If configuration of different hosts is VERY different, like one is a database server and one is not, this is where you would write two plays, each applying different tasks/roles to each.
Otherwise, it’s a case of setting inventory variables on specific groups or hosts.
They are similar application hosts & want to move files from host1 to host2/3.Once I setup jdk & wls binaries simply want to move files to other hosts.
How to setup inventory variables on specific groups or hosts.& call/use it in playbook.
main.yml
- hosts: a-server
user: auser
gather_facts: yes
roles:
hosts
[a-server]
vmxxx1-x.x
Currently I setup only one server in hosts file for a-server & want to extend the playbook to copy files on to other hosts.
-Vinay
Ansible “copy” works from the control machine, not between arbitrary sets of servers.
If you’re ok with that, use the copy module.
if not, you would need to use “fetch” to grab it first, then “copy” to push it out to others. I’ll admit that’s a very uncommon use case though, and better if you can centralize.
Hello Michael:
Can you please share a sample playbook to use fetch & copy operation?
Thanks for your help.
-Vinay