How to copy to remote servers

97 views
Skip to first unread message

vinay....@gmail.com

unread,
Oct 24, 2014, 6:19:45 PM10/24/14
to ansible...@googlegroups.com
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.

===========
   playbook
===========
---
- name: Check for fmw path exists
  stat: path=/a/b
  register: check_fmw_path
- name: fmw folder exists
  debug: msg=' Folder already exists'
  when: check_fmw_path.stat.exists
- name: Missing directory

  file: path=/a/b state=directory owner=test group=testgrp mode=755
  when: check_fmw_path.stat.exists == false
- name: Check for jdk path exists
  stat: path=/c/d
  register: check_jdk_path
- name: jdk folder exists
  debug: msg='jdk Folder already exists'
  when: check_jdk_path.stat.exists
- name: Missing jdk directory

  file: path=/c/d state=directory owner=test group=testgrp mode=755
  when: check_jdk_path.stat.exists == false
- name: Copying the jdk binaries
  copy: src=/temp/jdk-7u60-linux-x64.tar.gz dest=/c/d owner=test group=testgrp mode=755
- name: Extracting jdk binaries
  command: chdir=/c/d /bin/tar zxvf jdk-7u60-linux-x64.tar.gz
- name: Setting up Weblogic binaries using silent mode
  shell: /temp/wls_binaries.sh
==

Please suggest

-Vinay

Michael DeHaan

unread,
Oct 24, 2014, 8:10:38 PM10/24/14
to ansible...@googlegroups.com
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.



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d64aeb63-9511-4341-b76b-965fc505177d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

vinay....@gmail.com

unread,
Oct 25, 2014, 2:04:56 PM10/25/14
to ansible...@googlegroups.com
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:
    - weblogic

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

Michael DeHaan

unread,
Oct 30, 2014, 1:04:40 PM10/30/14
to ansible...@googlegroups.com
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.



vinay....@gmail.com

unread,
Nov 4, 2014, 1:09:11 PM11/4/14
to ansible...@googlegroups.com
Hello Michael:

Can you please share a sample playbook to use fetch & copy operation?
Thanks for your help.

-Vinay
Reply all
Reply to author
Forward
0 new messages