[ansible-project] Issue with unmount of volume
Hi, I have my facts as like below to unmount a file system in my EC2 via ansible. the ansible playbook executes fine without any issues but still file system doesnt get unmounted (eventhough not in use or no errors). The actual commands to manually unmount a volume works fine though. Any pointers would be of great help. - set_fact: device: /dev/xvdb when: nvmedev.stat.exists == False - name: Unmount device mount: name: "{{ item }}" src: none fstype: none state: unmounted with_items: - /dev/xvdb1 - name: Unmount mount: path: /dev/nvme1n1 state: absent RegardsKarthick -- 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/1077839576.767724.1552371526090%40mail.yahoo.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Re: getting a variable indirectly
On 12.03.2019 02:54, fusillator wrote: #not yet working in ansible release 2.3.2 # when: lookup('vars', item|basename, default=false) #workaround see role variable confobjs in the playbook launcher when: confobjs[item|basename] is defined register: template_result I'm not sure I understand what you are trying to achieve, but I think you are looking for this hostvars[inventory_hostname][item|basename] is defined It's not recommended to use vars, but this also works vars[inventory_hostname][item|basename] is defined If you want to combine variable with a string the syntax is hostvars[inventory_hostname][myvar ~ 'my_string'] is defined -- 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 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/6ff789851b9ea95695772502f3ea2527%40olstad.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Re: getting a variable indirectly
sorry for the mess, but the previous replies was wrong.. it's important to keep no space between different lines: - hosts: servers #gather_facts: false roles: - role: myrole1 vars: confobjs: "{% set objs = {} %}\ {% if confobj1 is defined %}\ {% set objs1 = objs|combine({'confobj1': confobj1}) %}\ {% set objs = objs1 %}\ {% endif %}\ {% if confobjn is defined %}\ {% set objs1 = objs|combine({'confobjn': confobjn}) %}\ {% set objs = objs1 %}\ {% endif %}\ {{ objs }}" in the task: #not yet working in ansible release 2.3.2 # when: lookup('vars', item|basename, default=false) #workaround see role variable confobjs in the playbook launcher when: confobjs[item|basename] is defined register: template_result it seems to work ugly well Il giorno lunedì 11 marzo 2019 21:05:11 UTC+1, fusillator ha scritto: > > Hi all, I need to get the value of a variable whose name is saved in > another one, in other words I need the lookup plugin vars > Unfortunately I can't upgrade ansible to a release upper to 2.4, so I have > to reinvent the wheel.. unpleasant feeling. > Is there a way to implement it in another way? > > I tried like so > > # when: lookup('vars', item|basename, default=false) > when: confobj > vars: > confobj: "{% set output = globals()[item|basename] if > globals()[item|basename] is defined else false %}\ > {{ output }}" > > But the variable is not defined in the global namespace.. > Actually the problem is a little more simple.. the variable could be set > in {host,group}_vars or in roles/*/{default,vars} > For the former case I could get it thanks the available var plugin with > host_vars[inventory_hostname][item|basename] > but how to retrieve those variables set by roles stuff? > > regards > > Luca > > > > > > > > -- 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/85af3448-9fef-4e20-9b41-7c70921955e6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Re: Can ios_config handle responding to two prompts in a row?
Great, thanks for that. On Monday, March 11, 2019 at 5:48:13 PM UTC+13, Ganesh Nalawade wrote: > > > You can use cli_command module available in Ansible 2.7 version onwards > > https://docs.ansible.com/ansible/latest/modules/cli_command_module.html > > The task can be modified as below to support multiple prompts. > > - name: Respond to double-password prompt > cli_command: > commands: > - command: crypto pki server my-ca start > > check_all: True > prompt: > > - "password" > > - "enter password" > > answer: > > - "mypassword\r" > > - "mypassword\r" > > > > > On Monday, 11 March 2019 10:13:06 UTC+5:30, ibdg wrote: >> >> Just noticed, my title here is wrong, it should be 'ios_command' not >> 'ios_config' >> > -- 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/1d7f23f0-2a95-414b-bbe6-c4af52b7679c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Re: with_items question
Thank you for all the help, this is the output of the first task with -v when I try item.name TASK [oraswgi-install : Copy installer files] * task path: /root/MY_RAC/roles/oraswgi-install/tasks/main.yml:25 Read vars_file 'infra-vars.yml' Read vars_file 'db-vars.yml' Read vars_file 'secrets.yml' fatal: [oradb1]: FAILED! => { "msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'name'\n\nThe error appears to have been in '/root/MY_RAC/roles/oraswgi-install/tasks/main.yml': line 25, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# ==> Copy installer files\n- name: Copy installer files\n ^ here\n" } skipping: [oradb2] => (item=V978971-01.zip) => { "changed": false, "item": "V978971-01.zip", "skip_reason": "Conditional result was False" } Read vars_file 'infra-vars.yml' Read vars_file 'db-vars.yml' Read vars_file 'secrets.yml' The modified task is: # ==> Copy installer files - name: Copy installer files copy: src: '{{ item.name }}' dest: '{{ oracle_stage }}/' owner: '{{ grid_install_user }}' mode: 0644 group: '{{ oracle_group }}' with_items: '{{ installer_archives }}' when: ansible_hostname==groups[group_names | first] | first -- 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/9bcbc166-a594-43d2-99db-746b7140d97b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Re: getting a variable indirectly
solved in a ugly way.. #not yet working in ansible release 2.3.x # when: lookup('vars', item|basename, default=false) when: confobjs[item|basename]|default(false) vars: confobjs: "{% set objs = {} %}\ {% set objs1 = objs|combine({'firstconfobj': firstconfobj}) if firstconfobj is defined %}\ {% set objs = obj1 %}\ {% set objs1 = objs|combine({'secondconfobj': secondconfobj}) if secondconfobj is defined %}\ {% set objs = obj1 %}\ #and so on {{ objs }}" Il giorno lunedì 11 marzo 2019 21:05:11 UTC+1, fusillator ha scritto: > > Hi all, I need to get the value of a variable whose name is saved in > another one, in other words I need the lookup plugin vars > Unfortunately I can't upgrade ansible to a release upper to 2.4, so I have > to reinvent the wheel.. unpleasant feeling. > Is there a way to implement it in another way? > > I tried like so > > # when: lookup('vars', item|basename, default=false) > when: confobj > vars: > confobj: "{% set output = globals()[item|basename] if > globals()[item|basename] is defined else false %}\ > {{ output }}" > > But the variable is not defined in the global namespace.. > Actually the problem is a little more simple.. the variable could be set > in {host,group}_vars or in roles/*/{default,vars} > For the former case I could get it thanks the available var plugin with > host_vars[inventory_hostname][item|basename] > but how to retrieve those variables set by roles stuff? > > regards > > Luca > > > > > > > > -- 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/dd1c3ff8-0c20-4a09-97aa-6a4c05b1bef4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Re: getting a variable indirectly
solved in a ugly way.. #not yet working in ansible release 2.3.x # when: lookup('vars', item|basename, default=false) when: confobjs[item|basename]|default(false) vars: confobjs: "{% set objs = {} %}\ {% set objs1 = objs|combine({'firstconfobj': firstconfobj}) if monitrc is defined %}\ {% set objs = obj1 %}\ {% set objs1 = objs|combine({'secondconfobj': secondconfobj}) if allow_monitrc is defined %}\ {% set objs = obj1 %}\ #and so on {{ objs }}" Il giorno lunedì 11 marzo 2019 21:05:11 UTC+1, fusillator ha scritto: > > Hi all, I need to get the value of a variable whose name is saved in > another one, in other words I need the lookup plugin vars > Unfortunately I can't upgrade ansible to a release upper to 2.4, so I have > to reinvent the wheel.. unpleasant feeling. > Is there a way to implement it in another way? > > I tried like so > > # when: lookup('vars', item|basename, default=false) > when: confobj > vars: > confobj: "{% set output = globals()[item|basename] if > globals()[item|basename] is defined else false %}\ > {{ output }}" > > But the variable is not defined in the global namespace.. > Actually the problem is a little more simple.. the variable could be set > in {host,group}_vars or in roles/*/{default,vars} > For the former case I could get it thanks the available var plugin with > host_vars[inventory_hostname][item|basename] > but how to retrieve those variables set by roles stuff? > > regards > > Luca > > > > > > > > -- 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/dbda9fc2-2f5d-475a-850e-39cb5459e172%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] conditionals
Hi Jeffrey, On 11.03.19 20:50, Jeffrey Agnitsch wrote: > - name: vmotion {{ inventory_hostname }} You'll also need "" here. - name: "vmotion {{ inventory_hostname }}" And this will give you only the first hostname as name for the task. This works for me: Playbook (without the linebreak in the when: line): --- - hosts: all tasks: - name: "foobar {{ inventory_hostname }}" debug: delegate_to: localhost when: inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') | int > 1 Inventory: host1 host2 Output: $ ansible-playbook -i /tmp/hosts /tmp/test.yml PLAY [all] *** TASK [Gathering Facts] *** ok: [host2] ok: [host1] TASK [foobar host1] *** skipping: [host1] ok: [host2 -> localhost] => { "msg": "Hello world!" } PLAY RECAP *** host1 : ok=1changed=0unreachable=0failed=0 host2 : ok=1changed=0unreachable=0failed=0 Hope that helps, Sebastian -- Sebastian Meyer Linux Consultant & Trainer Mail: me...@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 -- 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/2db654d8-0af7-97b0-6351-27f58c487b54%40b1-systems.de. For more options, visit https://groups.google.com/d/optout.
[ansible-project] getting a variable indirectly
Hi all, I need to get the value of a variable whose name is saved in another one, in other words I need the lookup plugin vars Unfortunately I can't upgrade ansible to a release upper to 2.4, so I have to reinvent the wheel.. unpleasant feeling. Is there a way to implement it in another way? I tried like so # when: lookup('vars', item|basename, default=false) when: confobj vars: confobj: "{% set output = globals()[item|basename] if globals()[item|basename] is defined else false %}\ {{ output }}" But the variable is not defined in the global namespace.. Actually the problem is a little more simple.. the variable could be set in {host,group}_vars or in roles/*/{default,vars} For the former case I could get it thanks the available var plugin with host_vars[inventory_hostname][item|basename] but how to retrieve those variables set by roles stuff? regards Luca -- 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/a1140fcb-80e0-4f66-b227-4232b40f1ecd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] conditionals
Trying to do a conditional that when my inventory host name once converted to a string is greater than a number Inventory file server1 server2 server3 - .. .. .. .. .. server205 this is the important parts of the role - name: vmotion {{ inventory_hostname }} vmware_vmotion: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }} password: "{{ vcenter_password }}" vm_name: "{{ inventory_hostname }}" destination_datastore: "TP1" when: "`(inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') | int) > 150`" delegate_to: localhost - name: vmotion {{ inventory_hostname }} vmware_vmotion: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}@scriptpro.com" password: "{{ vcenter_password }}" vm_name: "{{ inventory_hostname }}" destination_datastore: "TP2" when: "`(inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') | int) 180`" delegate_to: localhost it fails with ": "The conditional check '`(inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') | int) is even`' failed. The error was: template error while templating string: unexpected char u'`' at 6. String: {% if `(inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') | int) is even` %} True {% else %} False {% endif %}\n\nThe error appears to have been in '/etc/ansible/roles/vmotion_app/tasks/main.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: vmotion {{ inventory_hostname }}\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"} any thoughts are appreciated -- 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/8f11d72d-4078-437b-94b3-907e24e8ff29%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Apt Update exclude Packages (Blacklist)
On 11.03.2019 13:57, Face Gaming wrote: > I would like to know, if its possible to exclude packages from an apt > update or a blacklist for packages, which shouldn't be updated. There is no module for it, but you can run "apt-mark hold" with the command or shell module. -- 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 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/c6c166bb-f737-edcc-c01b-831c75faa3f3%40olstad.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Apt Update exclude Packages (Blacklist)
Hi, for yum there's the parameter exclude, for apt see a pinning howto for example https://wiki.debian.org/AptPreferences, so you can use lineinfile module to set the pinning priority of the package On Mon, 11 Mar 2019 at 13:57, Face Gaming wrote: > > Hey Guys > > I would like to know, if its possible to exclude packages from an apt update > or a blacklist for packages, which shouldn't be updated. > > Thanks for your help! > > Greetings > > -- > 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/c3f4b12c-46fd-4a0b-b657-07757a413e85%40googlegroups.com. > 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/CAPz4CsxTnE4ZBbAP5RCxEC11y5ou2EQzLuOBE%2BkQb8BmqX0C%2BA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] How can i run a block of playbook instructions only if they pass the specified condition?
Thanks Kai. I had all the tasks running with own retries but i was hoping to have retries condition for multiple tasks or a bunch of tasks having single condition and retries. It is strange that there is no way to get that done. On Mon, Mar 11, 2019, 7:35 PM Kai Stian Olstad < ansible-project+l...@olstad.com> wrote: > On 06.03.2019 08:59, Ankit wrote: > > Ok, i tried this but *block* doesn't accept, *retries. > > If you have looked at the documentation I linked to you would see that > retries is not allowed for a block, only task. > So you need to move your retries to the individual tasks. > > > > *I have the > > following playbook currently. Here, until works but i am not able to > figure > > out a way to limit the max number of iterations: > > > > - hosts: all > > > >name: runLinuxSystemUpdate > > > >gather_facts: false > > > >tasks: > > > > - name: Set Facts if not present in Host. > > > >include: checkLinuxSystemUpdateStatusTask.yml > > > >when: ansible_facts['Missing_Hotfix_Patches'] is not defined or > > ansible_facts['Missing_Hotfix_Patches'] == "" > > > > - name: Iteration Block > > > >block: > > > > - name: Install Patches Block > > > >block: > > > > - name: Run InstallLinuxPatchesTask.yml Task File > > > >include: InstallLinuxPatchesTask.yml > > > >when: ansible_facts['Missing_Hotfix_Patches'] != '0' or > > ansible_facts['Missing_Security_Patches'] != '0' > > When you not using rescue and/or always in block just having one task in a > block has no meaning. > > > > > - name: Reboot Machines Block > > > >block: > > > > - name: Run RebootLinuxMachinesTask.yml Task File > > > >include: RebootLinuxMachinesTask.yml > > > >when: ansible_facts['Pending_Reboot'] == true > > Same here, this block has no meaning since it only on one task. > > > > - name: Run checkLinuxSystemUpdateStatusTask task file to > re-validate > > Update and Reboot Status > > > >include: checkLinuxSystemUpdateStatusTask.yml > > > >#when: update_result.stdout.find("The deployment of patches > and > > packages was successfully") == -1 > > > >until: ansible_facts['Missing_Hotfix_Patches'] != '0' and > > ansible_facts['Missing_Security_Patches'] != '0' > >*retries: 3* > > The retries you need to move to each task. > > -- > 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 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/130851ca-df0c-2656-e74e-849c2f6be5dd%40olstad.com > . > 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/CACecUhs30AQTGJw2UiPviOYhObT78fk_t9AYoxfGdD68KCaiFw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Strange error: Do you have azure>=2.0.0 installed? Try `pip install ansible[azure]`- No module named containerservice
Have you tried to follow official ansible for azure installation guide? AFAIR it is: pip install ansible[azure] On MacOSX I noticed that ansible is very dependent on the right version of Azure libraries. Wawrzek On Mon, 11 Mar 2019 at 06:10, wrote: > > Hello, > I am puzzled from the under subject error message. > I have a very simple playbook that creates an Azure Resource Group. However, > when I execute it it generates this error message. > Of course, I have the latest packages installed: > > rpm -qa | grep -i ansible > ansible-2.7.8-1.fc28.noarch > > rpm -qa | grep -i azure > python2-azure-sdk-2.0.0-2.fc28.noarch > python2-azure-storage-0.36.0-2.fc28.noarch > python2-msrestazure-0.4.21-2.fc28.noarch > azure-cli-2.0.60-1.el7.x86_64 > > Also, the containerservice is in place: > > sudo find / | grep "azure" | grep -i containerservice > /usr/lib/python2.7/site-packages/azure/mgmt/compute/containerservice > /usr/lib/python2.7/site-packages/azure/mgmt/compute/containerservice/models.pyc > > In the github similar errors resulted to an issue with packages versions and > issues with AWX/Tower, but I don't run it in AWX. > > Any ideas? > > -- > 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/9b064172-9fa3-4159-b617-33d7f17cf477%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Dr Wawrzyniec Niewodniczańskior Wawrzek for short PhD in Quantum Chemistry & MSc in Molecular Engineering WWW: http://wawrzek.name E-MAIL: j...@wawrzek.name Linux User #177124 -- 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/CAC7-vpCrh5aA2cz4uPt2odJYAC3H47zSznSD5KG9x4WAZ6vW7g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] retrieving facter_ec2_metadata from hostvars - can't get element in macs
On 09.03.2019 02:47, Chris Jefferies wrote: > That's too bad because I don't have the mac address before I need to read > its attributes. How might a person get a list of the mac addresses > associated with the interfaces? You could try using python method to get the keys .macs.keys() this will return the list of all keys in macs. So the fist one would be .macs.keys()[0] -- 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 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/8a50d335-b31e-30ce-8fb2-b61c624426a5%40olstad.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] retrieving facter_ec2_metadata from hostvars - can't get element in macs
That's too bad because I don't have the mac address before I need to read its attributes. How might a person get a list of the mac addresses associated with the interfaces? Thanks for the info. Chris. On Thursday, March 7, 2019 at 9:19:11 AM UTC-8, Kai Stian Olstad wrote: > > On 05.03.2019 21:38, Chris Jefferies wrote: > > I can drill down into hostvars like this: > > > > - debug: > > msg: "looking at interface macs: {{ > > hostvars[inventory_hostname].facter_ec2_metadata.network.interfaces.macs > }}" > > > > > > And I get something like this: > > > > > > ok: [db01.deva.ecm] => { > > "msg": "looking at interface macs: {u'xx:xx:xx:xx:xx:xx': > > {u'local-hostname': u'ip-10-1-1-9.us-west-1.compute.internal', > > u'security-groups': u'sg_me', u'vpc-ipv4-cidr-blocks': u'10.1.0.0/16', > > u'subnet-id': u'subnet-009ae259d26e44f23', u'vpc-ipv4-cidr-block': > > u'10.1.0.0/16', u'interface-id': u'eni-0f706387a1423f329', u'mac': > > u'xx:xx:xx:xx:xx:xx, u'security-group-ids': u'sg-034d209d935486e41', > > u'local-ipv4s': u'10.1.1.10', u'owner-id': u'784710449476', > > u'subnet-ipv4-cidr-block': u'10.1.1.0/24', u'device-number': u'0', > > u'vpc-id': u'vpc-1710943aba582459a'}}" > > } > > > > > > > > > > I get an error if I try to find the first/only mac address with the [0] > > approach like this: > > > > {{ > hostvars[inventory_hostname].facter_ec2_metadata.network.interfaces.macs[ > > 0] }} > > > > > > or > > > > {{ > hostvars[inventory_hostname].facter_ec2_metadata.network.interfaces.macs. > > 0 }} > > > > > > What's the trick to get to the values within the mac address? > > > > Any tips would be appreciated, thanks, > > macs is a dict and not a list. Therefor using 0 to get the fist list > element wont work. > > To get information out of a dict you need to use the key which is the mac > address in you case. > > > -- > 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 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/610e4394-8e6b-4f12-acb2-5b60e51646b7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] How can i run a block of playbook instructions only if they pass the specified condition?
On 06.03.2019 08:59, Ankit wrote: > Ok, i tried this but *block* doesn't accept, *retries. If you have looked at the documentation I linked to you would see that retries is not allowed for a block, only task. So you need to move your retries to the individual tasks. > *I have the > following playbook currently. Here, until works but i am not able to figure > out a way to limit the max number of iterations: > > - hosts: all > >name: runLinuxSystemUpdate > >gather_facts: false > >tasks: > > - name: Set Facts if not present in Host. > >include: checkLinuxSystemUpdateStatusTask.yml > >when: ansible_facts['Missing_Hotfix_Patches'] is not defined or > ansible_facts['Missing_Hotfix_Patches'] == "" > > - name: Iteration Block > >block: > > - name: Install Patches Block > >block: > > - name: Run InstallLinuxPatchesTask.yml Task File > >include: InstallLinuxPatchesTask.yml > >when: ansible_facts['Missing_Hotfix_Patches'] != '0' or > ansible_facts['Missing_Security_Patches'] != '0' When you not using rescue and/or always in block just having one task in a block has no meaning. > > - name: Reboot Machines Block > >block: > > - name: Run RebootLinuxMachinesTask.yml Task File > >include: RebootLinuxMachinesTask.yml > >when: ansible_facts['Pending_Reboot'] == true Same here, this block has no meaning since it only on one task. > - name: Run checkLinuxSystemUpdateStatusTask task file to re-validate > Update and Reboot Status > >include: checkLinuxSystemUpdateStatusTask.yml > >#when: update_result.stdout.find("The deployment of patches and > packages was successfully") == -1 > >until: ansible_facts['Missing_Hotfix_Patches'] != '0' and > ansible_facts['Missing_Security_Patches'] != '0' >*retries: 3* The retries you need to move to each task. -- 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 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/130851ca-df0c-2656-e74e-849c2f6be5dd%40olstad.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Apt Update exclude Packages (Blacklist)
Hey Guys I would like to know, if its possible to exclude packages from an apt update or a blacklist for packages, which shouldn't be updated. Thanks for your help! Greetings -- 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/c3f4b12c-46fd-4a0b-b657-07757a413e85%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Access to variables defined in roles from python script
I've read it, as well as other documents w.r.t. development of user modules. However, it does not answer my original question, nor does it supply a pointer to an answer. In the mean time an related question has come up. On remote machines one can save some 'facts' in /etc/ansible/facts.d/*fact. Is a similar functionality also available on the ansible controller? -- 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/8a34ec64-1b8b-4cfb-b882-60e110682555%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.