I want to use the "target" also as a variable not just for hosts file

11 views
Skip to first unread message

Gb Gb

unread,
Oct 26, 2016, 12:14:15 PM10/26/16
to Ansible Project
ansible-playbook msi_install.yml -vvv

The problems( in red)
- the find command is OK
- but instead of getting the value of the target host like "199.121.121.1" i am getting "win_host1"
- where should I define the varible "repoPath" i have few more variable related only for the localhost like "repoReleasePath" etc...(alll mounted in linux to windows)

file name: win_global.yml
---
 - include: "msi_install.yml comp_name=COMP1 target=win_host1"
 - include: "msi_install.yml comp_name=COMP2 target=win_host1"
 - include: "msi_install.yml comp_name=COMP3 target=win_host2"
 - include: "msi_install.yml comp_name=COMP4 target=win_host2"



file name: hosts.yml
---
[localhost]

[win_servers]
win_host1: ansible_host=199.121.121.1
win_host1: ansible_host=199.199.33.33



file name: msi_install.yml
---
 - hosts: localhost
   tasks:
   name: find latest msi (mounted in linux)
# the repoPath is mounting also in linux to windows
   shell: find {{repoPath}} -type f -iname  "{{comp_name}}*" | tail -n1
   register: msi_name
   
   name: copy msi to target window host
   shell: cp {{ hostvars.localhost.msi_name.stdout }} {{ target }}

Reply all
Reply to author
Forward
0 new messages