1 |
On 12/01/2015 17:10, Stefan G. Weichinger wrote: |
2 |
> On 11.01.2015 17:36, Alan McKinnon wrote: |
3 |
> |
4 |
>> The trick is to use a system that guarantees you a unique "label" or |
5 |
>> identifier for each host. |
6 |
>> |
7 |
>> Perhaps {{ customer_name }}/{{ hostname }} works? |
8 |
>> |
9 |
>> This would fail if you have two customers with the same company name |
10 |
>> (rare, but not impossible) or customers have machines with the same name |
11 |
>> (silly, but possible). In that case, you'd probably have to go with |
12 |
>> UUIDs or similar. |
13 |
> |
14 |
> Where do I get |
15 |
> |
16 |
> {{ customer_name }} |
17 |
> |
18 |
> from? |
19 |
> |
20 |
> Where to define or set? |
21 |
> |
22 |
> example? |
23 |
|
24 |
|
25 |
You'd have to define it yourself in your plays somewhere |
26 |
|
27 |
Several ways present themselves: |
28 |
|
29 |
- Group customers together by customer name and use the group name. |
30 |
|
31 |
- Define the customer directly in the inventory. Generally it isn't |
32 |
recommended to define variable there, but I think this is one of the few |
33 |
case where it does make sense. Sort of like this: |
34 |
|
35 |
acme_web_server ansible_ssh_host=1.2.3.4 customer=acme |
36 |
|
37 |
{{ customer }} then is available for that host whenever the host is in scope |
38 |
|
39 |
|
40 |
|
41 |
One thing you'll find with ansible is there's always a way to do |
42 |
something, often more than one way (like perl). And all ways often make |
43 |
sense (unlike perl) |
44 |
|
45 |
|
46 |
-- |
47 |
Alan McKinnon |
48 |
alan.mckinnon@×××××.com |