Hi there

Currently we are running multiple WebSphere environments on one server for 
example DEV, TST, PRE

I get my facts from puppet/foreman.

I want to be able to cater for more than one environment in my playbook. if 
DEV is the only profile specified in my fact file,then it will only 
configure DEV.

Should we get a request for TST or any other environment on the same 
server, then the playbook should skip DEV as its already configured and 
then do TST.

Regards



On Monday, 12 February 2018 11:48:43 UTC+2, J Hawkesworth wrote:
>
> Its not clear to me exactly what you want the result to be after your 
> set_fact processing but I suggest you take a look at json_query plugin as 
> you might be able to use this to just pick out the bits of the result that 
> you need.  See 
> http://docs.ansible.com/ansible/latest/playbooks_filters.html#json-query-filter
>   
>
> One of the nice things about json_query is you can use the JMESPath 
> examples page here: http://jmespath.org/examples.html to try out your 
> queries (just paste your json into an input box and tinker with the query 
> until you get results you need.
>
> Hope this helps,
>
> Jon
>
> On Monday, February 12, 2018 at 7:58:47 AM UTC, Pieter Steyn wrote:
>>
>> Hi guys
>>
>> I need some help with looping my local_facts as I am struggling to match 
>> the key/value
>>
>> Example of my facts file:
>>
>> {
>>   "env": [
>>     "ppe",
>>     "trn"
>>   ],
>>   "websphere_dir": "/WebSphere8",
>>   "tech": "was8",
>>   "profiles": {
>>     "epn-was8-dmgr-ppe": {
>>       "env": "ppe"
>>     },
>>     "epn-was8-dmgr-trn": {
>>       "env": "trn"
>>     },
>>     "epn-was8-node-ppe-01": {
>>       "env": "ppe"
>>     },
>>     "epn-was8-node-trn-01": {
>>       "env": "trn"
>>     }
>>   }
>> }
>>
>>
>>
>> Code in playbook:
>>
>>     - set_fact:
>>         profiles_dicts: |
>>           {% set res = [] -%}
>>           {% for key in ansible_local.was.profiles.keys() -%}
>>             {% for value in ansible_local.was.profiles[key] -%}
>>               {% set ignored = res.extend([{'Server': key, 'ENV':value}]) 
>> -%}
>>            {%- endfor %}
>>           {%- endfor %}
>>           {{ res }}
>>
>>
>> Output:
>>
>> {
>>     "profiles_dicts": [
>>         {
>>             "ENV": "env",
>>             "Server": "epn-was8-dmgr-trn"
>>         },
>>         {
>>             "ENV": "env",
>>             "Server": "epn-was8-node-trn-01"
>>         },
>>         {
>>             "ENV": "env",
>>             "Server": "epn-was8-node-ppe-01"
>>         },
>>         {
>>             "ENV": "env",
>>             "Server": "epn-was8-dmgr-ppe"
>>         }
>>
>>
>> Is it possible to change my loop in order for my output to be ENV to 
>> match PPE or TRN and not env?
>>
>> I am not sure how to achieve this
>>
>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c1f7e273-4982-4680-bf63-41880565ca18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to