Hello team,
I am getting started with ansible but I have a number of questions. Apologies in advance for the rather noob questions:
1. In my inventory, is there anyway I can specify a single domain for all the hosts e.g.
[myhosts]
hostA
hostB
rather than
[myhosts]
Given the requirement that I might be run tests from outside the domain?
2. Many of my roles need to call supervisor when they have finished so they all use the same handler:
---
- name: restart supervisor
service: name=supervisor state=restarted
However at the moment I have the same duplicated handler file for each role - how can I avoid this and have a single handler file?
3. Is it possible to create strings from list?
I need to create a classpath variable - this is how I do it currently:
classpath: "{{ dest }}jarA.jar:{{ dest }}jarB.jar:{{ dest }}jarC.jar:{{ dest }}jarD.jar"
In Python I could use a loop to do this. Is there any way to do this in Ansible?
4. Do map style structures exist?
Similarly, when I am getting these jars I use a list like this - ideally it would be better to use a map, then generate the list from the map to avoid configuration duplication. Is there any way to achieve this?
- name: my service | Get jars
action: get_url url={{ build_url }}lastSuccessfulBuild/artifact/{{ item }} dest={{ dest }} mode=0440
with_items:
- pathA/jarA
- pathB/jarB
- pathC/jarC
- pathD/jarD
Thanks in advance,
Mark