Re: [ansible-project] nested with_items
How do I access that as a var? I am accessing each component as part of a uri call in the include tasks statement. On Thu, Jun 18, 2020, 6:22 AM Stefan Hornburg (Racke) wrote: > On 6/18/20 1:11 PM, Nicholas Britton wrote: > > So with that option I would have two more include tasks prior where I > set the the next to vars? > > > > Any other options to keep it in one play? > > > > You could also use the product filter > ( > https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#product-filters > ): > > Assign your current list to a variable, e.g asset_list and combine it with > lists for environment and time: > > with_items: "{{ asset_list | product(['prod', 'nonprod']) | > product(['1800', '2200', '0200', '0400']) }}" > > This will run over all possible combinations of the items in these three > lists. > > Regards >Racke > > > On Wed, Jun 17, 2020, 11:59 PM Dick Visser <mailto:dick.vis...@geant.org>> wrote: > > > > I usually handle this by looping over include_tasks. So each level > has its own file with tasks, and includes > > another task to 'go down' one level so to speak. > > > > > > > > On Wed, 17 Jun 2020 at 22:15, Nicholas Britton < > britton.nicho...@gmail.com <mailto:britton.nicho...@gmail.com>> wrote: > > > > I have a senerio where i think a nested with_items would work , > but i am not seeing any examples where there are > > multiple keys. > > > > > > Today i have a with_items that looks like this: > > > > | > > - name: Include vmware workflow for Tag Setups > > include_tasks: > tasks/vmworkflow_assetgroup_create_tags_include.yml > > with_items: > > - {segname: 'bu1', segabv: '1', btype: 'Image Backup', > ptype: 'pi', driveselect: '0', ret: '30', tagtype: > > 'Image Only', tagbg: 'bu1' } > > - {segname: 'bu2', segabv: '2', btype: 'Image Backup', > ptype: 'pi', driveselect: '0', ret: '30', tagtype: > > 'Image Only', tagbg: 'bu2' } > > - {segname: 'bu3', segabv: '3', btype: 'Image Backup', > ptype: 'pi', driveselect: '0', ret: '30', tagtype: > > 'Image Only', tagbg: 'bu3' } > > - {segname: 'bu1', segabv: '1', btype: 'Image with DB > Backup', ptype: 'pd', driveselect: '2', ret: '30', > > tagtype: 'DB Backup', tagbg: 'bu1' } > > - {segname: 'bu2', segabv: '2', btype: 'Image with DB > Backup', ptype: 'pd', driveselect: '2', ret: '30', > > tagtype: 'DB Backup', tagbg: 'bu2' } > > - {segname: 'bu3', segabv: '3', btype: 'Image with DB > Backup', ptype: 'pd', driveselect: '2', ret: '30', > > tagtype: 'DB Backup', tagbg: 'bu3' } > > > > | > > > > But i need to repeat each of these with two more pecies of data > and thought a nested would be better than > > created 7 more of each one listed above. > > > > I need to device enviornment with prod or nonprod and time with > 1800, 2200, 0200, 0400 > > > > so the included task would then have : > > - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: > 'pi', driveselect: '0', ret: '30', tagtype: 'Image > > Only', tagbg: 'bu1' } prod 1800 > > - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: > 'pi', driveselect: '0', ret: '30', tagtype: 'Image > > Only', tagbg: 'bu1' } prod 2200 > > - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: > 'pi', driveselect: '0', ret: '30', tagtype: 'Image > > Only', tagbg: 'bu1' } prod 0200 > > - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: > 'pi', driveselect: '0', ret: '30', tagtype: 'Image > > Only', tagbg: 'bu1' } prod 0400 > > - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: > 'pi', driveselect: '0', ret: '30', tagtype: 'Image > > Only', tagbg: 'bu1' } nonprod 1800 > > - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: > 'pi', driveselect: '0', ret: '30', tagtype: 'Image > > Only', tagbg: 'bu1' } nonprod 2200 > > - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: > 'pi', driveselect: '0', ret: '30', tagtype: 'Image > > Only', tagbg: 'bu1' } nonprod 0200 > > - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: > 'pi', driveselect: '0', ret: '30', tagtype: 'Image > > Only', tagbg: 'bu1' } nonprod 0400 > > > > al
Re: [ansible-project] nested with_items
So with that option I would have two more include tasks prior where I set the the next to vars? Any other options to keep it in one play? On Wed, Jun 17, 2020, 11:59 PM Dick Visser wrote: > I usually handle this by looping over include_tasks. So each level has > its own file with tasks, and includes another task to 'go down' one level > so to speak. > > > > On Wed, 17 Jun 2020 at 22:15, Nicholas Britton > wrote: > >> I have a senerio where i think a nested with_items would work , but i am >> not seeing any examples where there are multiple keys. >> >> >> Today i have a with_items that looks like this: >> >> - name: Include vmware workflow for Tag Setups >> include_tasks: tasks/vmworkflow_assetgroup_create_tags_include.yml >> with_items: >> - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } >> - {segname: 'bu2', segabv: '2', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu2' } >> - {segname: 'bu3', segabv: '3', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu3' } >> - {segname: 'bu1', segabv: '1', btype: 'Image with DB Backup', >> ptype: 'pd', driveselect: '2', ret: '30', tagtype: 'DB Backup', tagbg: >> 'bu1' } >> - {segname: 'bu2', segabv: '2', btype: 'Image with DB Backup', >> ptype: 'pd', driveselect: '2', ret: '30', tagtype: 'DB Backup', tagbg: >> 'bu2' } >> - {segname: 'bu3', segabv: '3', btype: 'Image with DB Backup', >> ptype: 'pd', driveselect: '2', ret: '30', tagtype: 'DB Backup', tagbg: >> 'bu3' } >> >> >> But i need to repeat each of these with two more pecies of data and >> thought a nested would be better than created 7 more of each one listed >> above. >> >> I need to device enviornment with prod or nonprod and time with 1800, >> 2200, 0200, 0400 >> >> so the included task would then have : >> - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } prod 1800 >> - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } prod 2200 >> - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } prod 0200 >> - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } prod 0400 >> - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } nonprod >> 1800 >> - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } nonprod >> 2200 >> - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } nonprod >> 0200 >> - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', >> driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } nonprod >> 0400 >> >> all as variables that i can call within the include. Currently i am >> calling the rest with item.segname, item.segabv, etc... >> >> >> thoughts or am i stuck with just having a longer list of with items? >> >> -- >> 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 view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/e142aeec-a748-4d31-836c-c48bafd9e517o%40googlegroups.com >> <https://groups.google.com/d/msgid/ansible-project/e142aeec-a748-4d31-836c-c48bafd9e517o%40googlegroups.com?utm_medium=email_source=footer> >> . >> > -- > Sent from a mobile device - please excuse the brevity, spelling and > punctuation. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ansible-project/fXzPHqJTLLY/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > ansible-project+unsubscr...@googlegroups.com. > To view this discussion on the web visit > ht
[ansible-project] nested with_items
I have a senerio where i think a nested with_items would work , but i am not seeing any examples where there are multiple keys. Today i have a with_items that looks like this: - name: Include vmware workflow for Tag Setups include_tasks: tasks/vmworkflow_assetgroup_create_tags_include.yml with_items: - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } - {segname: 'bu2', segabv: '2', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu2' } - {segname: 'bu3', segabv: '3', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu3' } - {segname: 'bu1', segabv: '1', btype: 'Image with DB Backup', ptype: 'pd', driveselect: '2', ret: '30', tagtype: 'DB Backup', tagbg: 'bu1' } - {segname: 'bu2', segabv: '2', btype: 'Image with DB Backup', ptype: 'pd', driveselect: '2', ret: '30', tagtype: 'DB Backup', tagbg: 'bu2' } - {segname: 'bu3', segabv: '3', btype: 'Image with DB Backup', ptype: 'pd', driveselect: '2', ret: '30', tagtype: 'DB Backup', tagbg: 'bu3' } But i need to repeat each of these with two more pecies of data and thought a nested would be better than created 7 more of each one listed above. I need to device enviornment with prod or nonprod and time with 1800, 2200, 0200, 0400 so the included task would then have : - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } prod 1800 - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } prod 2200 - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } prod 0200 - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } prod 0400 - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } nonprod 1800 - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } nonprod 2200 - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } nonprod 0200 - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', driveselect: '0', ret: '30', tagtype: 'Image Only', tagbg: 'bu1' } nonprod 0400 all as variables that i can call within the include. Currently i am calling the rest with item.segname, item.segabv, etc... thoughts or am i stuck with just having a longer list of with items? -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e142aeec-a748-4d31-836c-c48bafd9e517o%40googlegroups.com.
Re: [ansible-project] Re: Inventory for playbooks with all uri calls ran local
It does thanks!! I had the same crazy idea this morning too. Using a dummy name did the trick. On Tue, Jun 16, 2020, 10:07 AM Dakota Heyman wrote: > I recently ran into this same situation! > > The best way I got around it is to set up a single inventory file and > create an "all" group with the variable *ansible_connection: "local"* > This way, you can create whatever hosts you want and ansible won't attempt > to actually ssh to any of them, it will know to connect locally (unless you > want to override ansible_connection on a host level). > > Example: > all: > vars: > ansible_connection: "local" > children: > dbservers: > vars: > foo: "bar" > hosts: > dbserver1: > sys: "TEST" > > Hope that helps! > - Dakota > > On Tuesday, June 16, 2020 at 2:23:35 AM UTC-4, Nicholas Britton wrote: >> >> I am trying to see how I can setup an inventory file for an application >> that is all managed by uri calls. >> >> I have multiple end points that will end up with some different vars by >> host. But I have the host as 127.0.0.1 since everything runs local I >> thought that would be the way to do it. >> >> I am finding that since I have the same host in different groups it's >> taking the last car that gets set for all the groups, as designed from what >> I can see. Is the best option a different inventory file for each end point? >> >> -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ansible-project/rmngFmlJ8DE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > ansible-project+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/2b1e990f-6cd3-477d-8f26-fd15fa554b7bo%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/2b1e990f-6cd3-477d-8f26-fd15fa554b7bo%40googlegroups.com?utm_medium=email_source=footer> > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAN946jQ_fk2ixcDAjx34z-ShNMhcKC8_nVcegjLaee4LXGkWsA%40mail.gmail.com.
Re: [ansible-project] Create and add to a multi field array
I dont have much data at the moment since I am using a few test playbooks with static set vars to see if nested include task statements would work. Which it did. The part I am missing is after the nested includes that run in a loop, I want to print a summary of specifc vars to the screen for confirmation to the user running the playbook. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9e9b896f-009d-4a61-8347-b56be88c939co%40googlegroups.com.
[ansible-project] Inventory for playbooks with all uri calls ran local
I am trying to see how I can setup an inventory file for an application that is all managed by uri calls. I have multiple end points that will end up with some different vars by host. But I have the host as 127.0.0.1 since everything runs local I thought that would be the way to do it. I am finding that since I have the same host in different groups it's taking the last car that gets set for all the groups, as designed from what I can see. Is the best option a different inventory file for each end point? -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d1892d28-7e6b-4d51-b4be-8bf37cb92e66o%40googlegroups.com.
[ansible-project] Create and add to a multi field array
I am trying to find away that i can create an array that i can reference later that would be built through a series of include_task plays. Through the plays i will specific pieces of data that i care to keep for use later. My layout is as: main.yml -- inlcude_tasks.yml with loop -- include_task statements (3) So i have a main playbook, that has a include_tasks play that is calling another task list that is then calling three more include_tasks.I am doing it this way to as i loop through each item at the main.yml play i am able to work with a single dataset through each uri call to keep passing key data. When i am done with the last include_task i would like to add 6 vars that i care about to a single array so i can reference them later. Something like : group, type, asset, location, etc. This would be something i would loop through to do more stuff later. Thoughts?? -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1a580898-9548-4410-bf6e-6e132ca9effeo%40googlegroups.com.
Re: [ansible-project] uri body call needs [] instead of {}
Thank everyone for the help.Once i lined up the - correctly it worked. That was a nice trick to learn. relationships: storageServers: data: - type: storageServer id: "PureDisk:{{mediaserver}}.{{domain}}" On Saturday, December 14, 2019 at 11:48:54 AM UTC-6, Nicholas Britton wrote: > > Okay I can try that. Looks like you added a . In front of each line but > the last one that needs to be a list? Did I see that correct? > > On Sat, Dec 14, 2019, 9:41 AM Vladimir Botka wrote: > >> Hi Nicholas, >> >> On Sat, 14 Dec 2019 05:34:22 -0800 (PST) >> Nicholas Britton wrote: >> >> > When i try that i get a syntax error. >> > >> > fatal: [127.0.0.1]: FAILED! => { >> > "reason": "Syntax Error while loading YAML.\n >> >> Indentation is wrong. (Disregard my previous email.) >> >> > > > body: >> > > > data: >> > > > . type: diskPool >> > > > . attributes: >> > > > . name: server_dpm >> > > > . diskVolumes: >> > > > . [name: PureDiskVolume] >> > > > . maximumIoStreams: >> > > > . limitIoStreams: true >> > > > . streamsPerVolume: 75 >> > > > .relationships: >> > > >.storageServers: >> > > > data: >> > > > type: storageServer >> > > > id: 'PureDisk:server.domain' >> >> Cheers, >> >> -vlado >> > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/251465de-272f-4b9b-87b0-5aef037b446d%40googlegroups.com.
Re: [ansible-project] uri body call needs [] instead of {}
Okay I can try that. Looks like you added a . In front of each line but the last one that needs to be a list? Did I see that correct? On Sat, Dec 14, 2019, 9:41 AM Vladimir Botka wrote: > Hi Nicholas, > > On Sat, 14 Dec 2019 05:34:22 -0800 (PST) > Nicholas Britton wrote: > > > When i try that i get a syntax error. > > > > fatal: [127.0.0.1]: FAILED! => { > > "reason": "Syntax Error while loading YAML.\n > > Indentation is wrong. (Disregard my previous email.) > > > > > body: > > > > data: > > > > . type: diskPool > > > > . attributes: > > > > . name: server_dpm > > > > . diskVolumes: > > > > . [name: PureDiskVolume] > > > > . maximumIoStreams: > > > > . limitIoStreams: true > > > > . streamsPerVolume: 75 > > > > .relationships: > > > >.storageServers: > > > > data: > > > > type: storageServer > > > > id: 'PureDisk:server.domain' > > Cheers, > > -vlado > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAN946jTb9HzjhB7FLgfudHL9QBfmfmVOCegVAVng4FUrK0jLkw%40mail.gmail.com.
Re: [ansible-project] uri body call needs [] instead of {}
When i try that i get a syntax error. fatal: [127.0.0.1]: FAILED! => { "reason": "Syntax Error while loading YAML.\n did not find expected '-' indicator\n\nThe error appears to be in '/home/nbritton/ansible/gts-core-storage-operations/netbackup/tasks/msdp.create.include.yml': line 78, column 17, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n - type: storageServer\nid: 'PureDisk:server'\n ^ here\nThis one looks easy to fix. It seems that there is a value started\nwith a quote, and the YAML parser is expecting to see the line ended\nwith the same kind of quote. For instance:\n\nwhen: \"ok\" in result.stdout\n\nCould be written as:\n\n when: '\"ok\" in result.stdout'\n\nOr equivalently:\n\n when: \"'ok' in result.stdout\"\n" } On Saturday, December 14, 2019 at 2:35:55 AM UTC-6, Stefan Hornburg (Racke) wrote: > > On 12/14/19 12:46 AM, Nicholas Britton wrote: > > The problem is I don't know how to make ansible send the right bracket. > Testing from swagger I know what it expects. > > > > Hello Nicholas, > > try to use a list instead of a dict: > > data: > - type: storageServer > id: 'PureDisk:server.domain' > > Regards > Racke > > > On Fri, Dec 13, 2019, 5:16 PM Dick Visser <mailto:dick@geant.org >> wrote: > > > > You’re sending something that doesn’t work, and you seem to know > exactly what the problem is, and also what format > > _does_ work. So the solution is... send that? > > > > Or am I missing something > > > > > > > > On Fri, 13 Dec 2019 at 22:09, Nicholas Britton <mailto:britton...@gmail.com >> wrote: > > > > I am working on some uri calls with netbackup and with swagger > shows that it only works with [] but the uri > > modual is using {}. Any thoughts or tricks to get that to > format correctly? > > > > > > For example i am sending a body uri body of: > > > > | > > - name: Create MSDP Disk Pool > > uri: > > url: "{{baseurl}}storage/disk-pools" > > method: POST > > body_format: json > > status_code: 201 > > headers: > > authorization: "{{login.json.token}}" > > content-type: application/vnd.netbackup+json;version=3.0 > > body: > > data: > > type: diskPool > > attributes: > > name: server_dpm > > diskVolumes: > > [name: PureDiskVolume] > > maximumIoStreams: > > limitIoStreams: true > > streamsPerVolume: 75 > > relationships: > > storageServers: > > data: > > type: storageServer > > id: 'PureDisk:server.domain' > > validate_certs: no > > return_content: yes > > register: dp_create > > > > | > > > > Which produces this: > > > > | > > "body": { > > "data": { > > "attributes": { > > "diskVolumes": [ > > { > > "name": "PureDiskVolume" > > } > > ], > > "maximumIoStreams": { > > "limitIoStreams": true, > > "streamsPerVolume": 75 > > }, > > "name": "server_dpm" > > }, > > "relationships": { > > "storageServers": { > > "data": { > > "id": "PureDisk:server.domain", > > "
Re: [ansible-project] uri body call needs [] instead of {}
Is it the - in front of type that makes it a list over a dict? On Sat, Dec 14, 2019, 2:35 AM Stefan Hornburg (Racke) wrote: > On 12/14/19 12:46 AM, Nicholas Britton wrote: > > The problem is I don't know how to make ansible send the right bracket. > Testing from swagger I know what it expects. > > > > Hello Nicholas, > > try to use a list instead of a dict: > > data: > - type: storageServer > id: 'PureDisk:server.domain' > > Regards > Racke > > > On Fri, Dec 13, 2019, 5:16 PM Dick Visser <mailto:dick.vis...@geant.org>> wrote: > > > > You’re sending something that doesn’t work, and you seem to know > exactly what the problem is, and also what format > > _does_ work. So the solution is... send that? > > > > Or am I missing something > > > > > > > > On Fri, 13 Dec 2019 at 22:09, Nicholas Britton < > britton.nicho...@gmail.com <mailto:britton.nicho...@gmail.com>> wrote: > > > > I am working on some uri calls with netbackup and with swagger > shows that it only works with [] but the uri > > modual is using {}. Any thoughts or tricks to get that to > format correctly? > > > > > > For example i am sending a body uri body of: > > > > | > > - name: Create MSDP Disk Pool > > uri: > > url: "{{baseurl}}storage/disk-pools" > > method: POST > > body_format: json > > status_code: 201 > > headers: > > authorization: "{{login.json.token}}" > > content-type: application/vnd.netbackup+json;version=3.0 > > body: > > data: > > type: diskPool > > attributes: > > name: server_dpm > > diskVolumes: > > [name: PureDiskVolume] > > maximumIoStreams: > > limitIoStreams: true > > streamsPerVolume: 75 > > relationships: > > storageServers: > > data: > > type: storageServer > > id: 'PureDisk:server.domain' > > validate_certs: no > > return_content: yes > > register: dp_create > > > > | > > > > Which produces this: > > > > | > > "body": { > > "data": { > > "attributes": { > > "diskVolumes": [ > > { > > "name": "PureDiskVolume" > > } > > ], > > "maximumIoStreams": { > > "limitIoStreams": true, > > "streamsPerVolume": 75 > > }, > > "name": "server_dpm" > > }, > > "relationships": { > > "storageServers": { > > "data": { > > "id": "PureDisk:server.domain", > > "type": "storageServer" > > } > > } > > }, > > "type": "diskPool" > > } > > }, > > > > > > | > > > > While swagger produces it as this: > > > > | > > working: > > > > > > { > > "data": { > > "type": "diskPool", > > "attributes": { > > "name": "server_dpm", > > "diskVolumes": [ > > { > > "name": "PureDiskVolume" > > } > > ], > > > >
Re: [ansible-project] uri body call needs [] instead of {}
The problem is I don't know how to make ansible send the right bracket. Testing from swagger I know what it expects. On Fri, Dec 13, 2019, 5:16 PM Dick Visser wrote: > You’re sending something that doesn’t work, and you seem to know exactly > what the problem is, and also what format _does_ work. So the solution > is... send that? > > Or am I missing something > > > > On Fri, 13 Dec 2019 at 22:09, Nicholas Britton > wrote: > >> I am working on some uri calls with netbackup and with swagger shows that >> it only works with [] but the uri modual is using {}. Any thoughts or >> tricks to get that to format correctly? >> >> >> For example i am sending a body uri body of: >> >> - name: Create MSDP Disk Pool >> uri: >> url: "{{baseurl}}storage/disk-pools" >> method: POST >> body_format: json >> status_code: 201 >> headers: >> authorization: "{{login.json.token}}" >> content-type: application/vnd.netbackup+json;version=3.0 >> body: >> data: >> type: diskPool >> attributes: >> name: server_dpm >> diskVolumes: >> [name: PureDiskVolume] >> maximumIoStreams: >> limitIoStreams: true >> streamsPerVolume: 75 >> relationships: >> storageServers: >> data: >> type: storageServer >> id: 'PureDisk:server.domain' >> validate_certs: no >> return_content: yes >> register: dp_create >> >> >> Which produces this: >> >> "body": { >> "data": { >> "attributes": { >> "diskVolumes": [ >> { >> "name": "PureDiskVolume" >> } >> ], >> "maximumIoStreams": { >> "limitIoStreams": true, >> "streamsPerVolume": 75 >> }, >> "name": "server_dpm" >> }, >> "relationships": { >> "storageServers": { >> "data": { >> "id": "PureDisk:server.domain", >> "type": "storageServer" >> } >> } >> }, >> "type": "diskPool" >> } >> }, >> >> >> >> While swagger produces it as this: >> >> working: >> >> >> { >> "data": { >> "type": "diskPool", >> "attributes": { >> "name": "server_dpm", >> "diskVolumes": [ >> { >> "name": "PureDiskVolume" >> } >> ], >> >> "maximumIoStreams": { >> "limitIoStreams": true, >> "streamsPerVolume": 75 >> } >> >> }, >> "relationships": { >> "storageServers": { >> "data": [ >> { >> "type": "storageServer", >> "id": "PureDisk:server.domain" >> } >> ] >> } >> } >> } >> } >> >> >> >> -- >> 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 view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/d248f94f-431a-43d7-8ab3-08d9ae619796%40googlegroups.com >> <https://groups.google.com/d/msgid/ansible-project/d248f94f-431a-43d7-8ab3-08d9ae619796%40googlegroups.com?utm_medium=email_source=footer> >> . >> > -- > Sent from a mobile device - please excuse the brevity, spelling and > punctuation. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ansible-project/Aci8dPvAc1A/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > ansible-project+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CAL8fbwP%3DaETutURieZSYAD%2B%2B71--zX%2BNHOY4y7EGXLtp98Eozg%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CAL8fbwP%3DaETutURieZSYAD%2B%2B71--zX%2BNHOY4y7EGXLtp98Eozg%40mail.gmail.com?utm_medium=email_source=footer> > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAN946jTZfpZShJGx5cTP%3D8KcpzFBoyRkZjt3EcufqyZD3OHSmQ%40mail.gmail.com.
[ansible-project] uri body call needs [] instead of {}
I am working on some uri calls with netbackup and with swagger shows that it only works with [] but the uri modual is using {}. Any thoughts or tricks to get that to format correctly? For example i am sending a body uri body of: - name: Create MSDP Disk Pool uri: url: "{{baseurl}}storage/disk-pools" method: POST body_format: json status_code: 201 headers: authorization: "{{login.json.token}}" content-type: application/vnd.netbackup+json;version=3.0 body: data: type: diskPool attributes: name: server_dpm diskVolumes: [name: PureDiskVolume] maximumIoStreams: limitIoStreams: true streamsPerVolume: 75 relationships: storageServers: data: type: storageServer id: 'PureDisk:server.domain' validate_certs: no return_content: yes register: dp_create Which produces this: "body": { "data": { "attributes": { "diskVolumes": [ { "name": "PureDiskVolume" } ], "maximumIoStreams": { "limitIoStreams": true, "streamsPerVolume": 75 }, "name": "server_dpm" }, "relationships": { "storageServers": { "data": { "id": "PureDisk:server.domain", "type": "storageServer" } } }, "type": "diskPool" } }, While swagger produces it as this: working: { "data": { "type": "diskPool", "attributes": { "name": "server_dpm", "diskVolumes": [ { "name": "PureDiskVolume" } ], "maximumIoStreams": { "limitIoStreams": true, "streamsPerVolume": 75 } }, "relationships": { "storageServers": { "data": [ { "type": "storageServer", "id": "PureDisk:server.domain" } ] } } } } -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d248f94f-431a-43d7-8ab3-08d9ae619796%40googlegroups.com.
[ansible-project] user input problem
Right now the user input will come when the user runs the main playbook. The playbook is a series of include_tasks's.While the inventory file contains vars but i would like the user input to help select what vars to use through the plays. Example of vars in inventory would be: ams03: hosts: localhost vars: ui: 886000428027 vmc01: am1vmhost1,am1vmhost2,am1vmhost3,am1vmhost4,am1vmhost5,am1vmhost6,am1vmhost7,am1vmhost8 vmc02: "'am1vmhost9','am1vmhost10','am1vmhost11','am1vmhost12','am1vmhost13','am1vmhost14','am1vmhost15','am1vmhost16'" vmc01ports: ['CL5-A' , 'CL5-B' , 'CL6-A' , 'CL6-B'] vmc02ports: ['CL7-A' , 'CL7-B' , 'CL8-A' , 'CL8-B'] But the user will select what vmc## should be used Through out the playbook the right hosts and ports need to be selected, but i am unsure how to ensure that. In the future the input will come from an online form or other tool, but the values could still be passed the same. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b1e9cd35-4427-4bf4-ab11-fba91ffb39c4%40googlegroups.com.
Re: [ansible-project] list seen as unicode, not sure why or how to correct
Thank you! That helped me connect the dots. I found the extra space and its working like a champ. Thank you again! On Thursday, August 29, 2019 at 9:23:50 AM UTC-5, Kai Stian Olstad wrote: > > On 29.08.2019 15:48, Nicholas Britton wrote: > > Thank you. I see what your doing there and why.That makes since > > to me. > > > > The part i dont follow 100% is the string part. Would you mind > > breaking > > that down for me? I also notice when i put that in my task list > > that > > the coloars for the next task change, does that indicate a problem? > > I can try, hopefully is understandable. > > > The join filter take a list and join each element in the list with a > string. > So the list is joined by the string ',' > > The list > [10, 11, 12] > > becomes with join("','") > > 10','11','12 > > Tilde, ~ , is string concatenation in Jinja so it will be > > "'" ~ "10','11','12" ~ "'" > > That becomes > > '10','11','12' > > The color change is because the syntax highlighting is confused by all > the quotes and multiline YAML, but there is no problem. > It looks like you are using vim, if you install this plugin it will > handle this without problem. >https://github.com/pearofducks/ansible-vim > > > > [image: 2019-08-29_8-31-34.png] > > I also notice the string puts a space at the end, and if i create two > > test > > stings one without the space and one with, it works without but not > > with: > > > > test1: "'10','11','12','13','14','15','16','9'" > > test2: "'10','11','12','13','14','15','16','9' " > > The space I guess is because you have a space after }} in the set_fact > task. > You can turn on highlighting of trailing whitespace in vim so they are > more easily spotted. > > > > TASK [String] > > > *** > > > > ok: [localhost] > > > > > > TASK [debug - string] > > > *** > > > > ok: [localhost] => { > > "msg": "'10','11','12','13','14','15','16','9' " > > } > > > > > > > > I also tried to add a replace filter in a couple of different ways, but > > they all seem to have a quoting problem that i am not seeing: > > > > - name: String > > set_fact: > > hostgrpnum_s: >- > > {{ "'" ~ hostgroupnum_l | join("','") ~ "'" }} > > The space is at the end of this line. > > > -- > Kai Stian Olstad > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/77cb58c6-2432-48de-817a-7f51b484293d%40googlegroups.com.
Re: [ansible-project] list seen as unicode, not sure why or how to correct
Thank you. I see what your doing there and why.That makes since to me. The part i dont follow 100% is the string part. Would you mind breaking that down for me? I also notice when i put that in my task list that the coloars for the next task change, does that indicate a problem? [image: 2019-08-29_8-31-34.png] I also notice the string puts a space at the end, and if i create two test stings one without the space and one with, it works without but not with: test1: "'10','11','12','13','14','15','16','9'" test2: "'10','11','12','13','14','15','16','9' " TASK [String] *** ok: [localhost] TASK [debug - string] *** ok: [localhost] => { "msg": "'10','11','12','13','14','15','16','9' " } I also tried to add a replace filter in a couple of different ways, but they all seem to have a quoting problem that i am not seeing: - name: String set_fact: hostgrpnum_s: >- {{ "'" ~ hostgroupnum_l | join("','") ~ "'" }} - name: debug - string debug: msg: "{{hostgrpnum_s | replace(" ", "") }}" The offending line appears to be: debug: msg: "{{hostgrpnum_s | replace(" ", "") }}" ^ here On Thursday, August 29, 2019 at 6:46:15 AM UTC-5, Kai Stian Olstad wrote: > > On 28.08.2019 17:36, Nicholas Britton wrote: > > So i am trying to pull the hostgroupnumber since i need to use the list > > with a uri query that will use a in statement. The api > > documentation > > shows that the the variable to search in the in statement, needs to > > look > > like: "'value1','value2','value3'" > > After reading thru everything I think it boils down to this. > > You have list on int's >[10, 11, 12, 13, 14, 15, 16, 9] > > that you need to be a string looking like > > '10','11','12','13','14','15','16','9' > > And since it's going to be used in a url you probably need to url encode > it too. > > > > Here is the set of tasks that i am using to generate the list variable: > > > > --- > > - name: Set facts > > set_fact: > > hostgroup_l: [] > > hostgroupnum_l: [] > > You don't need this if you do my proposed changes bellow. > > > > - name: create list of hostgroups > > set_fact: > > hostgroup_l: "{{hostgroup_l}} + > > ['{{item.hostGroup.hostGroupName}}']" > > with_items: "{{hostgroups.json.data}}" > > This is a lot faster > >- name: create list of hostgroups > set_fact: >hostgroup_l: "{{ hostgroups.json.data | > map(attribute='hostGroup.hostGroupName') | list }}" > > > > - name: create list of hostgroups ids > > set_fact: > > hostgroupnum_l: "{{hostgroupnum_l}} + > > ['{{item.hostGroup.hostGroupNumber}}']" > > with_items: "{{hostgroups.json.data}}" > >- name: create list of hostgroups ids > set_fact: >hostgroupnum_l: "{{ hostgroups.json.data | > map(attribute='hostGroup.hostGroupNumber' | list }}" > > > So to get this to a string you can do this > >- name: String > set_fact: >hostgrpnum_s: >- > {{ "'" ~ hostgroupnum_l | join("','") ~ "'" }} > > Here I'm using muliline YAML so I avoid problem with qoutes since you > don't need qoutes at the start and end. > > And you can use urlencode filter to get proper url format. > > -- > Kai Stian Olstad > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ab732364-08de-4318-b8e5-38c710ae651a%40googlegroups.com.
Re: [ansible-project] list seen as unicode, not sure why or how to correct
I tried to play with that some yesterday but did not have much luck. What can I provide you to help you help me? On Wed, Aug 28, 2019, 2:20 AM Kai Stian Olstad < ansible-project+l...@olstad.com> wrote: > On 27.08.2019 23:46, Nicholas Britton wrote: > > That provides me this: > > > > TASK [debug number on array after unuiqe] > > > *** > > ok: [localhost] => { > > "msg": "'\"10\"'" > > } > > > > > > how do i clean that up to only get the value 10 out of it? > > > > The end result i am expecting is for the list to look like: > > > > '10','11','15' > > It's hard to give a solution since you have not provided all the > information we need. > But you can create a comma separated string with the join filter. > > https://jinja.palletsprojects.com/en/2.10.x/templates/#join > > > -- > Kai Stian Olstad > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ansible-project/iSuFH-mE420/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > ansible-project+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/f3a327f758d28469bfaaef20b805e836%40olstad.com > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAN946jT_owS-Z87bFSYm8hL8geoNacqPanVnTrOdfku5qB5pFA%40mail.gmail.com.
Re: [ansible-project] list seen as unicode, not sure why or how to correct
That provides me this: TASK [debug number on array after unuiqe] *** ok: [localhost] => { "msg": "'\"10\"'" } how do i clean that up to only get the value 10 out of it? The end result i am expecting is for the list to look like: '10','11','15' On Tuesday, August 27, 2019 at 3:51:35 PM UTC-5, Kai Stian Olstad wrote: > > On 27.08.2019 22:32, Nicholas Britton wrote: > > And this error when the next uri call attempts to use it, notice, how at > > the end i puts the list in unicode format, and the url does not know how > to > > interpret that. > > TASK [list sessions for 886000428027 - ams] > > > * > > > > fatal: [localhost]: FAILED! => {"changed": false, "connection": "close", > > "content": " > 2.0//EN\">\n\n400 Bad > > Request\n\nBad Request\nYour browser > sent > > a request that this server could not understand. > />\n\n\n", "content_length": "226", "content_type": > "text/html; > > charset=iso-8859-1", "date": "Tue, 27 Aug 2019 20:26:28 GMT", "elapsed": > 0, > > "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", > > "redirected": false, "server": "Apache", "status": 400, "url": " > https://ip/ConfigurationManager/v1/views/lun-paths?$query=ldev.storageDeviceId%20eq%20'886000428027'%20and%20hostGroup.hostGroupNumber%20in%20'[u'10', > > > > u'11', u'12', u'13', u'14', u'15', u'16', u'9']'"} > > You can use the to_json filter to get "clean" json output. > > > -- > Kai Stian Olstad > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/923d0d66-8060-4f3e-b43c-b3f009bcb235%40googlegroups.com.
[ansible-project] list seen as unicode, not sure why or how to correct
I am building a list with output stored from a uri call: - name: Get hostgroup info uri: url: "{{baseurl}}views/host-groups?$query=hostGroup.storageDeviceId%20eq%20'{{ui}}'%20and%20hostGroup.hostGroupName%20in%20[{{vmc02}}]" method: get validate_certs: no headers: Authorization: "Session {{login.json.token}}" Accept: "application/json" Content-Type: "application/json" register: hostgroups - name: create list of hostgroups ids set_fact: hostgroupnum_l: "{{hostgroupnum_l}} + ['{{item.hostGroup.hostGroupNumber}}']" with_items: "{{hostgroups.json.data}}" But when the data is debuged it gives me this difference if i look at one item or multiple: TASK [debug hostgroup list object] ** ok: [localhost] => { "msg": [ "10", "11", "12", "13", "14", "15", "16", "9" ] } TASK [debug hostgroupnumber output] * ok: [localhost] => { "msg": "u'10'" } And this error when the next uri call attempts to use it, notice, how at the end i puts the list in unicode format, and the url does not know how to interpret that. TASK [list sessions for 886000428027 - ams] * fatal: [localhost]: FAILED! => {"changed": false, "connection": "close", "content": "\n\n400 Bad Request\n\nBad Request\nYour browser sent a request that this server could not understand.\n\n\n", "content_length": "226", "content_type": "text/html; charset=iso-8859-1", "date": "Tue, 27 Aug 2019 20:26:28 GMT", "elapsed": 0, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "redirected": false, "server": "Apache", "status": 400, "url": "https://ip/ConfigurationManager/v1/views/lun-paths?$query=ldev.storageDeviceId%20eq%20'886000428027'%20and%20hostGroup.hostGroupNumber%20in%20'[u'10', u'11', u'12', u'13', u'14', u'15', u'16', u'9']'"} Thoughts? -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/68cd892f-628b-43a5-8477-63c13c979b1c%40googlegroups.com.
[ansible-project] inventory file for playbooks with only uri calls
I am working on a set of playbooks for a hitachi storage automation. They utilize a cmrest server, that manages the connection to each storage array. So all of the tasks are ran on the localhost to the same url base, but there is a var in the path that indicates what storage array to run against. I was looking at the inventory file as an option to set the vars for each storage array. Each storage array would be a group, but since they all have localhost, the var overwrites because it belongs to multiple groups. Does anyone have an idea of how i can achieve this or something similar to this? Here is an example of the inventory file i started with: [amsterdam] localhost [amsterdam:vars] ui=886000428027 hostss=esx001,esx002,esx003 [singapore] localhost [singapore:vars] ui=4 [all:vars] baseurl="https://10.123.123.123:23351/ConfigurationManager/v1/; -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/40a9c937-abb6-4e19-bf0b-648ef3b6b1c3%40googlegroups.com.
[ansible-project] Re: loop through a json object
I got this figured out. I needed to add a step before, to create a list with all the values , then find the max of it. On Monday, August 26, 2019 at 12:42:47 PM UTC-5, Nicholas Britton wrote: > > Thank you, that has helped alot. > > I was looking at the max option: > > - name: debug - show max lun number > debug: > msg: "{{item.lun.lun}}" > loop: "{{luns.json.data}}" > when: "{{item.lun.lun | max}}" > > > But it returns the following: > TASK [debug - show max lun number] > > fatal: [127.0.0.1]: FAILED! => {"msg": "The conditional check > '{{item.lun.lun | max}}' failed. The error was: Unexpected templating type > error occurred on ({{item.lun.lun | max}}): 'int' object is not > iterable\n\nThe error appears to be in > '/home/nbritton/ansible/gts-core-storage-operations/hds/get_luninfo.yml': > line 65, column 5, but may\nbe elsewhere in the file depending on the exact > syntax problem.\n\nThe offending line appears to be:\n\n\n - name: debug - > show max lun number\n^ here\n"} > > The value i am after is the last one in the output here: > > TASK [debug new vars] > * > ok: [127.0.0.1] => { > "msg": "am1vmhost12,CL8-B,15,83,SFTP,6" > } > > > > > On Friday, August 23, 2019 at 3:22:58 PM UTC-5, Nicholas Britton wrote: >> >> I am trying to loop through a json object that is returned and list out >> key pieces of information, or later on do something with these key peices >> of information from each object. I have been trying to do this with >> JMESpath examples but have not had much luck. Would anyone be able to >> help point me in the right direction. >> >> For this example i am trying to pull out hostGroup.hostGroupdId, >> hostGroup.hostgroupname, ldev.ldevid, lun.lun, lun.lunid >> >> Here is a sample of the output returned from json_out.json: >> >> TASK [debug lunpaths] >> *** >> ok: [127.0.0.1] => { >> "msg": { >> "count": 4, >> "data": [ >> { >> "hostGroup": { >> "hostGroupId": "CL7-A,15", >> "hostGroupName": "host12", >> "hostGroupNumber": 15, >> "hostMode": "VMWARE_EX", >> "hostModeOptions": [ >> 54, >> 63 >> ], >> "portId": "CL7-A", >> "storageDeviceId": "88600099" >> }, >> "ldev": { >> "attributes": [ >> "CVS", >> "HDT" >> ], >> "blockCapacity": 2147483648, >> "byteFormatCapacity": "1.00 T", >> "clprId": 0, >> "dataReductionMode": "disabled", >> "dataReductionStatus": "DISABLED", >> "emulationType": "OPEN-V-CVS", >> "isDefined": true, >> "isFullAllocationEnabled": false, >> "isRelocationEnabled": true, >> "label": "BackupSFTP", >> "ldevId": 82, >> "mpBladeId": 0, >> "numOfUsedBlock": 3096576, >> "poolId": 0, >> "status": "NML", >> "storageDeviceId": "88600099", >> "tierLevel": "all", >> "tierLevelForNewPageAllocation": "M", >> "usedCapacityPerTierLevel1&quo
[ansible-project] Re: loop through a json object
Thank you, that has helped alot. I was looking at the max option: - name: debug - show max lun number debug: msg: "{{item.lun.lun}}" loop: "{{luns.json.data}}" when: "{{item.lun.lun | max}}" But it returns the following: TASK [debug - show max lun number] fatal: [127.0.0.1]: FAILED! => {"msg": "The conditional check '{{item.lun.lun | max}}' failed. The error was: Unexpected templating type error occurred on ({{item.lun.lun | max}}): 'int' object is not iterable\n\nThe error appears to be in '/home/nbritton/ansible/gts-core-storage-operations/hds/get_luninfo.yml': line 65, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: debug - show max lun number\n^ here\n"} The value i am after is the last one in the output here: TASK [debug new vars] * ok: [127.0.0.1] => { "msg": "am1vmhost12,CL8-B,15,83,SFTP,6" } On Friday, August 23, 2019 at 3:22:58 PM UTC-5, Nicholas Britton wrote: > > I am trying to loop through a json object that is returned and list out > key pieces of information, or later on do something with these key peices > of information from each object. I have been trying to do this with > JMESpath examples but have not had much luck. Would anyone be able to > help point me in the right direction. > > For this example i am trying to pull out hostGroup.hostGroupdId, > hostGroup.hostgroupname, ldev.ldevid, lun.lun, lun.lunid > > Here is a sample of the output returned from json_out.json: > > TASK [debug lunpaths] > *** > ok: [127.0.0.1] => { > "msg": { > "count": 4, > "data": [ > { > "hostGroup": { > "hostGroupId": "CL7-A,15", > "hostGroupName": "host12", > "hostGroupNumber": 15, > "hostMode": "VMWARE_EX", > "hostModeOptions": [ > 54, > 63 > ], > "portId": "CL7-A", > "storageDeviceId": "88600099" > }, > "ldev": { > "attributes": [ > "CVS", > "HDT" > ], > "blockCapacity": 2147483648, > "byteFormatCapacity": "1.00 T", > "clprId": 0, > "dataReductionMode": "disabled", > "dataReductionStatus": "DISABLED", > "emulationType": "OPEN-V-CVS", > "isDefined": true, > "isFullAllocationEnabled": false, > "isRelocationEnabled": true, > "label": "BackupSFTP", > "ldevId": 82, > "mpBladeId": 0, > "numOfUsedBlock": 3096576, > "poolId": 0, > "status": "NML", > "storageDeviceId": "88600099", > "tierLevel": "all", > "tierLevelForNewPageAllocation": "M", > "usedCapacityPerTierLevel1": 1512, > "usedCapacityPerTierLevel2": 0 > }, > "lun": { > "lun": 5, > "lunId": "CL7-A,15,5", > "storageDeviceId": "886000428027" > } > }, > { > "hostGroup": { > "hostGroupId": "CL7-B,15", > "hostGroupName": "host12", >
[ansible-project] Re: loop through a json object
I got it to work with this: - name : print all hostgroups debug: msg: "{{item.hostGroup.hostGroupName}},{{item.hostGroup.hostGroupId}}" loop: "{{sessions.json.data}}" when: item.hostGroup.hostGroupName | regex_search('.*am1.*')(.*\.9$) I cant get the regex to work right.I am looking to match am1 anywhere in the string, but end with specific numbers such as 1-8 or 9-16. Any help there would be appreciated. My next step will be to figure out how to do a loop and do something with that data.such as execute a uri block that will use the item. as inputs to the body of the uri call. I have not had much luck locating what i think would do that, if someone has an example that would be great. On Friday, August 23, 2019 at 3:22:58 PM UTC-5, Nicholas Britton wrote: > > I am trying to loop through a json object that is returned and list out > key pieces of information, or later on do something with these key peices > of information from each object. I have been trying to do this with > JMESpath examples but have not had much luck. Would anyone be able to > help point me in the right direction. > > For this example i am trying to pull out hostGroup.hostGroupdId, > hostGroup.hostgroupname, ldev.ldevid, lun.lun, lun.lunid > > Here is a sample of the output returned from json_out.json: > > TASK [debug lunpaths] > *** > ok: [127.0.0.1] => { > "msg": { > "count": 4, > "data": [ > { > "hostGroup": { > "hostGroupId": "CL7-A,15", > "hostGroupName": "host12", > "hostGroupNumber": 15, > "hostMode": "VMWARE_EX", > "hostModeOptions": [ > 54, > 63 > ], > "portId": "CL7-A", > "storageDeviceId": "88600099" > }, > "ldev": { > "attributes": [ > "CVS", > "HDT" > ], > "blockCapacity": 2147483648, > "byteFormatCapacity": "1.00 T", > "clprId": 0, > "dataReductionMode": "disabled", > "dataReductionStatus": "DISABLED", > "emulationType": "OPEN-V-CVS", > "isDefined": true, > "isFullAllocationEnabled": false, > "isRelocationEnabled": true, > "label": "BackupSFTP", > "ldevId": 82, > "mpBladeId": 0, > "numOfUsedBlock": 3096576, > "poolId": 0, > "status": "NML", > "storageDeviceId": "88600099", > "tierLevel": "all", > "tierLevelForNewPageAllocation": "M", > "usedCapacityPerTierLevel1": 1512, > "usedCapacityPerTierLevel2": 0 > }, > "lun": { > "lun": 5, > "lunId": "CL7-A,15,5", > "storageDeviceId": "886000428027" > } > }, > { > "hostGroup": { > "hostGroupId": "CL7-B,15", > "hostGroupName": "host12", > "hostGroupNumber": 15, > "hostMode": "VMWARE_EX", > "hostModeOptions": [ > 54, > 63 > ], > "portId": "CL7-B", > "storageDeviceId": "88600099" > }, > "ldev": { > "attr
Re: [ansible-project] loop through a json object
It's going to be used as input for a uri request. I will want to loop through each hostgroup and repeat until done with the list. I have not looked yet but I will also want to filter the list by the name. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAN946jT_QRkL%2B3g8ai9ze%2BUxF12FEC7RH8kO9FSmyvZzOzfcvQ%40mail.gmail.com.
[ansible-project] Delete based on directory size
I have been looking for a module for something similar to the du command. I would like to have a play that looks at the log directory to detect if it's a certian size or larger and if so find the sub folders with gbs of data and remove or tar that data up. So far I am not finding that and parsing the return of the du command is not is not somethig I am having luck with. Has anyone tried to do something similar? Have any ideas or pointers for me? -- 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/27c07b39-4955-4645-8e61-e68b96872da6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] json filter
I have been trying to work with the filter for json responces but i am not having much luck. I can print out a line of intrest, but i am not able to iteriate over the other objects in the response when i try to loop through it. Here is the response i get from the uri call : TASK [debug var assets] * ok: [127.0.0.1] => { "msg": { "data": [ { "attributes": { "assetLastBackupStatuses": [], "assetSubscriptions": [], "assetType": "Virtual Machine", "description": "Owner - name, Project: IDM", "discoveryHosts": [ { "hostName": "server01", "ipAddress": "x.x.x.x", "uuid": "someuid" } ], "displayName": "server01.domain.com", "extendedAttributes": { "annotation": "Owner - Name, Project: IDM", "cluster": "Cluster01", "connectionState": "connected", "datacenter": "DC01", "datastore": "DS01", "displayName": "server01.domain.com", "dnsName": "server01.domain.com", "guestId": "windows8Server64Guest", "host": "host01.domain.com", "hostName": "x.x.x.x", "hostPath": "Engineering Resource", "instanceUuid": "someuuid", "ipAddress": x.x.x.x", "mor": "vm-921", "network": "dvPortGroup_vLAN##", "nicIpaddresses": "(x.x.x.x)", "path": "Engineering Resource", "powerState": "poweredOn", "snapshotDir": "DS01", "template": "false", "uuid": "someuuid", "vCenter": "vcenter.domain.com", "vCenterVersion": "5.5.0", "version": "vmx-08", "vmAbsolutePath": "/vcenter01.domain.com/Engineering/Engineering Resource/host.domain.com", "vmxDir": "DS01" }, "firstDiscoveredTime": "2018-09-26T14:14:30.775Z", "lastDiscoveredTime": "2019-05-09T19:26:52.950Z", "masters": [ { "hostName": "nbumaster01", "ipAddress": "x.x.x.x", "uuid": "someuid" } ], "protectionMethods": [], "providerGeneratedId": "VMware_5001b01e-651c-f63c-3b24-e279fb1b8fd4", "version": "5.5.0", "workloadType": "VMware" }, "id": "d329683a-1af7-4a42-b2e5-afd34f9d693a", "links": { "self": { "href": "/assets/d329683a-1af7-4a42-b2e5-afd34f9d693a" } }, "relationships": { "assetGroups": { "data": [], "links": { "self": { "href": "/assets/d329683a-1af7-4a42-b2e5-afd34f9d693a/asset-groups" } } } }, "type": "asset" }, { Here is the code i am working with so far: I have tried using multiple variants, but i have not had any luck. - name : debug var assets debug: msg: "{{assets.json}}" - name : debug json value debug: msg: "{{assets.json.data[0].attributes.assetType}}" - name : debug json value debug: msg: "{{assets.json.data[0].attributes.displayName}}" - name: display all displaynames debug: var: item loop: "{{assets.json | json_query('attributes.displayName')}}" -- 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/559cf2fb-d32c-44ae-b244-93928742f626%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] vars_prompt within a role
Is that pause option available within a role? Do you have some examples of that you would be willing to share? On Thursday, May 9, 2019 at 2:42:15 PM UTC-5, Brian Coca wrote: > > vars_prompt is only available at play, you can however use `pause` and > register user input. > > > -- > -- > Brian Coca > -- 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/384c438c-a29d-40e3-be4a-2ef47c66e553%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] vars_prompt within a role
I am working on a project that will be mostly api based running locally and attaching to different environments via the api (uri module) My plan was to create a role for each type of call that will be made, that way playbooks can be created to use any series of roles. The problem i am running into is that i need to have the user provide data. For the few that will be ran non-interactivly i see the -e option overrides the same var that is prompted for, so that works when we need to run a playbook in that context. >From what i can tell it may not be possible to put vars_prompt into the role and have that work.Has anyone found a way to get this to work. The biggest part of it is prompting for the servername that is part of the uri url. I would like to not include this on every playbook , but as part of the login role that is always going to run. That role is also asking for a user login and password.That way we can keep application auditing intact , rather than using a service account. -- 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/6cdc7e8f-7ecd-4e5b-a94d-90a755b48c79%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Complex api json calls
So if the multivalue is driven from user input or an input file and will vary in what regions are to be used, how can that be dynamic? On Wed, May 8, 2019, 4:55 PM Matt Martz wrote: > The `body` is typically easiest represented as a YAML representation of > the JSON data format. So in your case, this should be what you need: > > - uri: > url: > https://fsunix005.pne.ven.veritas.com/netbackup/config/snapshotproviders/configuredplugins/aws/instances > method: POST > body_format: json > body: > data: > attributes: > configurationAttributes: > - name: accesskey > singlevalue: key1 > - name: secretkey > singlevalue: skey2 > - multivalue: > - us-east-1 > - us-east-2 > - us-west-1 > - us-west-2 > name: regions > id: someid > type: plugininstance > > On Wed, May 8, 2019 at 4:50 PM Nicholas Britton < > britton.nicho...@gmail.com> wrote: > >> I am looking to use the uri module and have been sucessfull with simpler >> calls, but i am unsure how to get something like the following to work >> correctly.I have been provided what the json should look like but i am >> unsure how to build that out via the uri module in the body syntax. >> >> I have also struggled to find how ansible handles nested levels in the >> body. from examples it looks like its just the indents. But i am not >> sure, if someone can help shed some light for me it would be much >> appreciated. >> >> Here is what the json should look like when sent as the payload: >> >> POST https: >> //fsunix005.pne.ven.veritas.com/netbackup/config/snapshotproviders/configuredplugins/aws/instances >> >> >> >> { >> >> "data": { >> >> "id": "someid", >> >> "type": "plugininstance", >> >> "attributes": { >> >> "configurationAttributes": [ >> >> { >> >> "name": "accesskey", >> >> "singlevalue": "key1" >> >> }, >> >> { >> >> "name": "secretkey", >> >> "singlevalue": "skey2" >> >> }, >> >> { >> >> "name": "regions", >> >> "multivalue": [ >> >> "us-east-1", >> >> "us-east-2", >> >> "us-west-1", >> >> "us-west-2" >> >> ] >> >> } >> >> ] >> >> } >> >> } >> >> } >> >> >> -- >> 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/dcea4d04-b6c7-4db9-98e7-b5d13c30b908%40googlegroups.com >> <https://groups.google.com/d/msgid/ansible-project/dcea4d04-b6c7-4db9-98e7-b5d13c30b908%40googlegroups.com?utm_medium=email_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > Matt Martz > @sivel > sivel.net > > -- > 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/CAD8N0v-fPFcd-OpYNjWdQAn%3Dju23nXrAwO-3hWbLyJhSPv29eQ%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CAD8N0v-fPFcd-OpYNjWdQAn%3Dju23nXrAwO-3hWbLyJhSPv29eQ%40mail.gmail.com?utm_medium=email_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAN946jSvSo6FN%2BDBrh561ZGMEA8pdfBEaHRSCT1eaXtvSOMv2A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Complex api json calls
I am looking to use the uri module and have been sucessfull with simpler calls, but i am unsure how to get something like the following to work correctly.I have been provided what the json should look like but i am unsure how to build that out via the uri module in the body syntax. I have also struggled to find how ansible handles nested levels in the body. from examples it looks like its just the indents. But i am not sure, if someone can help shed some light for me it would be much appreciated. Here is what the json should look like when sent as the payload: POST https: //fsunix005.pne.ven.veritas.com/netbackup/config/snapshotproviders/configuredplugins/aws/instances { "data": { "id": "someid", "type": "plugininstance", "attributes": { "configurationAttributes": [ { "name": "accesskey", "singlevalue": "key1" }, { "name": "secretkey", "singlevalue": "skey2" }, { "name": "regions", "multivalue": [ "us-east-1", "us-east-2", "us-west-1", "us-west-2" ] } ] } } } -- 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/dcea4d04-b6c7-4db9-98e7-b5d13c30b908%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] print free space for mount
I am trying to print the free space for a mount that an application needs to have x free on. Once i can do that i would look at adding actions based on that, but i would also like to the user running the play to know if there is an issue or not. Here is what i have so far, and i cant see to get what i would expect, any thoughts: code: --- - hosts: all tasks: - debug: msg: "Mount Point {{item.mount}} free space {{item.size_available/1073741824}} " loop: "{{ansible_mounts}}" when: item.mount == '/home' output: PLAY [all] ** TASK [Gathering Facts] ** ok: [server] TASK [debug] skipping: [server] => (item={u'block_used': 3056865, u'uuid': u'bf9d7ab9-4be3-419d-8aed-f3b952b75957', u'size_total': 84408975360, u'block_total': 20607660, u'mount': u'/', u'block_available': 17550795, u'size_available': 71888056320, u'fstype': u'ext4', u'inode_total': 5242880, u'inode_available': 5165347, u'device': u'/dev/mapper/VolGroup-lv_root', u'inode_used': 77533, u'block_size': 4096, u'options': u'rw'}) skipping: [server] => (item={u'block_used': 109536, u'uuid': u'11dcc8c1-6895-4cc5-b6f3-6d83767021ac', u'size_total': 499355648, u'block_total': 487652, u'mount': u'/boot', u'block_available': 378116, u'size_available': 387190784, u'fstype': u'ext4', u'inode_total': 128016, u'inode_available': 127971, u'device': u'/dev/sda1', u'inode_used': 45, u'block_size': 1024, u'options': u'rw'}) ok: [server] => (item={u'block_used': 3071894, u'uuid': u'c6c79efc-1ada-4714-9d32-80a6cd896605', u'size_total': 105558474752, u'block_total': 25771112, u'mount': u'/home', u'block_available': 22699218, u'size_available': 92975996928, u'fstype': u'ext4', u'inode_total': 6540800, u'inode_available': 6382890, u'device': u'/dev/mapper/VolGroup-lv_home', u'inode_used': 157910, u'block_size': 4096, u'options': u'rw'}) => { "msg": "Mount Point /home free space 86.5906448364 " } What i really want to display and only display is : "Mount Point /home free space 86.5906448364 " -- 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/218947b2-b36c-4ba6-bff8-6e2d5230eae0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.