We are needing the same thing.
My understanding is that the inventory modules are expected to be modified
for your own needs.
We modified ec2.py to strip off the ec2_tag prefix so that we could group
things without renaming all roles to ec2_tag... or having to write a large
and rapidly changing config hosts file.
Our difficulty is that limiting with ec2.py is done via ec2.ini and this
forces a workflow of templating out ec2.ini in stage 1 and using it in
stage 2.
This frequently causes mis-targeting.
The problem seems to me that --limit is not passed through to the inventory
modules.
Is there a design choice for this, or could ansible inventory module be
modified to allow this (and perhaps other efficiency filters like region)?
Right now, limit is only applied after the inventory is gathered which
makes the group 'all' your entire fleet rather than that specified by
--limit.
On Tuesday, October 6, 2015 at 7:39:38 AM UTC-5, Bedwyr Humphreys wrote:
>
> Hi,
>
> I'm trying to use a dynamic inventory to configure Softlayer hosts. My
> scripts are working with a static inventory file where I specify things like
>
> [BACKUP_SERVER]
> 10.000.00.00
> [JIRA]
> 10.111.11.11
>
> Now i want to move to using a dynamic inventory using softlayer.py from
> ansible/contrib/inventory
>
> This returns the following structure:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *{ "_meta": { "hostvars": { "159.xxx.xx.xx": {
> "datacenter": { "id": 999, "longName": "Xxxx 2",
> "name": "xxx02", "statusId": 2 },
> "domain": "softlayer.com <http://softlayer.com>",
> "fullyQualifiedDomainName": "xxxx.softlayer.com
> <http://xxxx.softlayer.com>", "globalIdentifier":
> "xxxx-xxx-xxxx-xxxx-xxxxxxxxxx", "hostname": "yyyyy", "id":
> 11327741, "maxCpu": 1, "maxMemory": 8192,
> "powerState": { "keyName": "RUNNING", "name":
> "Running" }, "primaryBackendIpAddress": "10.XXX.XX.XX",
> "primaryIpAddress": "159.XXX.XXX.XX", "status": {
> "keyName": "ACTIVE", "name": "Active" },
> "tagReferences": [] }*
>
> ...
>
> So my questions are .. how do I filter hosts in a playbook with a dynamic
> inventory?
>
> I would have previously done:
> ---
> - hosts: JIRA
>
> but now I would like to filter by *hostname* or (more usefully)
> *tagReferences
> - *how is this possible?
>
> Secondly, I would like ansible to ssh via the internal 10.xxx IP addresses
> not the external 159.xxx ones. Is this possible?
>
> Thanks,
> Bedwyr
>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/3146cd26-f503-4f35-91b9-8f11ab73028a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.