I swapped the add_host tasks for some group_by's and its working.

Thanks,
Mark

On Monday, January 27, 2014 5:06:58 PM UTC-6, Mark Casey wrote:
>
> Ok, saw the note on the github ticket (thanks, and sorry if filing it was 
> premature). Not sure whether to continue here or there; here I guess...
>
> So for my real use case of this on ec2, I posted more debug 
> output...should that be working? More or less I'm attempting something like 
> this from ansible-examples: 
> https://github.com/ansible/ansible-examples/blob/master/openshift/roles/ec2/tasks/main.yml,
>  
> except these instances already exist so I'm using ec2.py to pull in the 
> tags to use for the provider-agnostic group names, which will then be used 
> when calling deployment roles. This playbook I'm trying to do this grouping 
> in is sort of an intermediary...I have existing plays for these roles and I 
> didn't want to go changing *groups: db* to *groups: tag_ec2type_db* for 
> roles that otherwise have nothing to do with ec2.
>
> Thank you,
> Mark
>
> On Monday, January 27, 2014 3:25:37 PM UTC-6, Mark Casey wrote:
>>
>> Bah! Obfuscation gone wrong...I never know how much is prudent to remove. 
>> :)
>>
>> In my last message, the group webnode==apache2 and db==mysql......I 
>> missed some of them when replacing.
>>
>> Sorry!
>>
>> On Monday, January 27, 2014 3:23:11 PM UTC-6, Mark Casey wrote:
>>>
>>> Yea, seems like it should work. I opened a github issue with a simpler 
>>> localhost test-case.
>>>
>>> https://github.com/ansible/ansible/issues/5791
>>>
>>> A lot of these are obviously redacted :), but I've triple-checked and 
>>> there is no 'apache2' or 'mysql' group there. 
>>>
>>> TASK: [iaas_gather_multi | Add instance to id group] 
>>>> **************************
>>>> <172.31.31.72> ESTABLISH CONNECTION FOR USER: root
>>>> creating host via 'add_host': hostname=172.31.31.72
>>>> added host to group via add_host module: test10
>>>> ok: [172.31.31.72] => {"item": "", "new_groups": ["test10"], 
>>>> "new_host": "172.31.31.72"}
>>>>
>>>> TASK: [iaas_gather_multi | Add instance to type group] 
>>>> ************************
>>>> <172.31.31.72> ESTABLISH CONNECTION FOR USER: root
>>>> creating host via 'add_host': hostname=172.31.31.72
>>>> added host to group via add_host module: webnode
>>>> ok: [172.31.31.72] => {"item": "", "new_groups": ["webnode"], 
>>>> "new_host": "172.31.31.72"}
>>>>
>>>> TASK: [iaas_gather_multi | Add instance to id_type group] 
>>>> *********************
>>>> <172.31.31.72> ESTABLISH CONNECTION FOR USER: root
>>>> creating host via 'add_host': hostname=172.31.31.72
>>>> added host to group via add_host module: test10_webnode
>>>> ok: [172.31.31.72] => {"item": "", "new_groups": ["test10_webnode"], 
>>>> "new_host": "172.31.31.72"}
>>>>
>>>> TASK: [iaas_gather_multi | Add host to provisioning status group] 
>>>> *************
>>>> <172.31.31.72> ESTABLISH CONNECTION FOR USER: root
>>>> creating host via 'add_host': hostname=172.31.31.72
>>>> added host to group via add_host module: host_provisioned_True
>>>> ok: [172.31.31.72] => {"item": "", "new_groups": 
>>>> ["host_provisioned_True"], "new_host": "172.31.31.72"}
>>>>
>>>> TASK: [iaas_gather_multi | debug var=group_names] 
>>>> *****************************
>>>> <172.31.31.72> ESTABLISH CONNECTION FOR USER: root
>>>> ok: [172.31.31.72] => {
>>>>     "group_names": [
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "tag_ec2id_and_ec2type_test10_apache2",
>>>>         "tag_ec2id_test10",
>>>>         "tag_ec2type_apache2",
>>>>         "***********",
>>>>         "type_m1_medium",
>>>>         "us-west-2",
>>>>         "us-west-2b"
>>>>     ],
>>>>     "item": ""
>>>> }
>>>> <172.31.45.13> ESTABLISH CONNECTION FOR USER: root
>>>> ok: [172.31.45.13] => {
>>>>     "group_names": [
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "***********",
>>>>         "tag_ec2id_and_ec2type_test10_mysql",
>>>>         "tag_ec2id_test10",
>>>>         "tag_ec2type_mysql",
>>>>         "***********",
>>>>         "type_m1_medium",
>>>>         "us-west-2",
>>>>         "us-west-2b"
>>>>     ],
>>>>     "item": ""
>>>> }
>>>>
>>>
>>> On Monday, January 27, 2014 1:25:20 PM UTC-6, James Tanner wrote:
>>>>
>>>> I can’t see any reason in the code for this to not work. Could you show 
>>>> us the -vvvv output from ansible-playbook? Maybe something isn’t evaulated 
>>>> the way you expect.
>>>>
>>>> On Jan 27, 2014, at 2:05 PM, Mark Casey <mark....@gmail.com> wrote:
>>>>
>>>> Is it normal for add_host to not work when using ec2.py? I'm in a 
>>>> playbook that is using ec2.py as the inventory source and I'm trying to 
>>>> create a few groups dynamically using ec2 tag values.
>>>>
>>>> When I run debug on the hostvars afterwards, the new group name isn't 
>>>> there.
>>>>
>>>> *Inventory output:*
>>>>
>>>>> jenkins@ip-172-31-35-124:~/jobs/JobName/workspace$ 
>>>>> bin/devtools/ansible/ec2.py --list --refresh-cache
>>>>> ...
>>>>>
>>>>>   "tag_ec2id_test10": [
>>>>>     "172.31.31.72",
>>>>>     "172.31.45.13"
>>>>>   "tag_ec2type_mysql": [
>>>>>     "172.31.25.13"
>>>>>   ],
>>>>>   "tag_ec2type_apache": [
>>>>>     "172.31.31.72"
>>>>>
>>>>> ...
>>>>>
>>>>
>>>>
>>>> *Start of the play*
>>>>  
>>>>
>>>>> - name: Gather ec2 facts
>>>>>   ec2_facts:
>>>>>   when: provider == "ec2"
>>>>>
>>>>> - name: Add instance to iaas-provider-agnostic type group
>>>>>   add_host: hostname={{ inventory_hostname }} groups="{{ 
>>>>> ec2_tag_ec2type }}"
>>>>>   when: provider == "ec2"
>>>>>
>>>>
>>>> *A call to debug on one of these hosts, inserted after the above calls:* 
>>>>
>>>> "ec2_tag_ec2id": "test10", 
>>>>> "ec2_tag_ec2id_and_ec2type": "test10_apache2", 
>>>>> "ec2_tag_ec2type": "apache2", 
>>>>>
>>>>>
>>>>> ...
>>>>>
>>>>> "group_names": [
>>>>> "***************************", 
>>>>> "***************************", 
>>>>> "i-********", 
>>>>> "key_*******", 
>>>>> "security_group_***************************", 
>>>>> "security_group_***************************", 
>>>>> "security_group_***************************", 
>>>>> "***************************", 
>>>>> "***************************", 
>>>>> "tag_ec2id_and_ec2type_test10_apache2", 
>>>>> "tag_ec2id_test10", 
>>>>> "tag_ec2type_apache2", 
>>>>> "tag_provisioned_True", 
>>>>> "type_m1_medium", 
>>>>> "us-west-2", 
>>>>> "us-west-2b"
>>>>>         ], 
>>>>>
>>>>>
>>>> TIA for any insights...hopefully I've just got an obvious typo.
>>>> -Mark 
>>>>
>>>> -- 
>>>> 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.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to