Re: [ansible-project] ansible shell variable
Thank you very much for the help On Monday, 25 May 2020 01:16:43 UTC-4, Vladimir Botka wrote: > > On Sun, 24 May 2020 20:31:12 -0700 (PDT) > Andrew Morgan > wrote: > > > > > 1) get the mac address > > > > 2) get the subnet > > > > > > > > --- > > > > - hosts: dev > > > > become: true > > > > #connection: local > > > > gather_facts: true > > > > Run the command below a see what "facts" are available when > "gather_facts: > > > true" is enabled. > > > shell> ansible dev -m setup > > > This is the output: > > > > fatal: [deVPN]: FAILED! => changed=true > > cmd: |- > > ansible dev -m setup > > delta: '0:00:00.033604' > > end: '2020-05-24 23:29:51.883830' > > msg: non-zero return code > > rc: 127 > > start: '2020-05-24 23:29:51.850226' > > stderr: '/bin/bash: ansible: command not found' > > stderr_lines: > > stdout: '' > > stdout_lines: > > This is a misunderstanding. Do not run the command with ansible-playbook > as > "shell" task on the remote host! > > The "command" shall be run from the command-line on controller. The output > will show all facts collected by the module "setup" on the remote host. > The > same facts will be collected automatically by a playbook when not disabled > by > "gather_facts: false". See > https://docs.ansible.com/ansible/latest/modules/setup_module.html#examples > > shell> ansible dev -m setup > > Find the variables that fit your purpose. For example > > shell> cat playbook.yml > - hosts: dev > tasks: > - debug: > var: ansible_default_ipv4 > - debug: > msg: "MAC: {{ ansible_default_ipv4.macaddress }}" > - debug: > msg: "Network: {{ ansible_default_ipv4.network }}" > > shell> ansible-playbook playbook.yml > > HTH, > > -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/916793b6-2896-4f7c-8ff5-1eda44a6235d%40googlegroups.com.
Re: [ansible-project] ansible shell variable
Thank you , this actually worked, but the issue is that it presents another MAC address from the one in AWS, so I am still getting an error detailed below: 22:00:0b:0b:97:4e is the MAC address from debug, and 22:00:0b:0b:97:4e is the MAC from aws metadata. changed: [deVPN] TASK [debug] *** ok: [deVPN] => msg: 'instance id is i-0b9de9bd38cc1ce8f ' TASK [debug] *** ok: [deVPN] => msg: 'curl --silent http://169.254.169.254/latest/meta-data/network/interfaces/macs/22:00:0b:0b:97:4e/subnet-id ' TASK [Get Subnet-ID] *** [WARNING]: Consider using the get_url or uri module rather than running 'curl'. If you need to use command because get_url or uri is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False' in ansible.cfg to get rid of this message. changed: [deVPN] TASK [debug] *** ok: [deVPN] => msg: |- instance id is http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;> http://www.w3.org/1999/xhtml; xml:lang="en" lang="en"> 404 - Not Found 404 - Not Found PLAY RECAP * deVPN So is there no way to accomplish the following? It seems to be the only way I can get the right MAC id INTERFACE=$(curl --silent http://169.254.169.254/latest/meta-data/network/interfaces/macs/) SUBNET_ID=$(curl --silent http://169.254.169.254/latest/meta-data/network/interfaces/macs/${INTERFACE}/subnet-id) On Monday, 25 May 2020 01:16:43 UTC-4, Vladimir Botka wrote: > > On Sun, 24 May 2020 20:31:12 -0700 (PDT) > Andrew Morgan > wrote: > > > > > 1) get the mac address > > > > 2) get the subnet > > > > > > > > --- > > > > - hosts: dev > > > > become: true > > > > #connection: local > > > > gather_facts: true > > > > Run the command below a see what "facts" are available when > "gather_facts: > > > true" is enabled. > > > shell> ansible dev -m setup > > > This is the output: > > > > fatal: [deVPN]: FAILED! => changed=true > > cmd: |- > > ansible dev -m setup > > delta: '0:00:00.033604' > > end: '2020-05-24 23:29:51.883830' > > msg: non-zero return code > > rc: 127 > > start: '2020-05-24 23:29:51.850226' > > stderr: '/bin/bash: ansible: command not found' > > stderr_lines: > > stdout: '' > > stdout_lines: > > This is a misunderstanding. Do not run the command with ansible-playbook > as > "shell" task on the remote host! > > The "command" shall be run from the command-line on controller. The output > will show all facts collected by the module "setup" on the remote host. > The > same facts will be collected automatically by a playbook when not disabled > by > "gather_facts: false". See > https://docs.ansible.com/ansible/latest/modules/setup_module.html#examples > > shell> ansible dev -m setup > > Find the variables that fit your purpose. For example > > shell> cat playbook.yml > - hosts: dev > tasks: > - debug: > var: ansible_default_ipv4 > - debug: > msg: "MAC: {{ ansible_default_ipv4.macaddress }}" > - debug: > msg: "Network: {{ ansible_default_ipv4.network }}" > > shell> ansible-playbook playbook.yml > > HTH, > > -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/69b98451-862f-4d57-918c-86ab92b70870%40googlegroups.com.
Re: [ansible-project] ansible shell variable
On Sun, 24 May 2020 20:31:12 -0700 (PDT) Andrew Morgan wrote: > > > 1) get the mac address > > > 2) get the subnet > > > > > > --- > > > - hosts: dev > > > become: true > > > #connection: local > > > gather_facts: true > > Run the command below a see what "facts" are available when "gather_facts: > > true" is enabled. > > shell> ansible dev -m setup > This is the output: > > fatal: [deVPN]: FAILED! => changed=true > cmd: |- > ansible dev -m setup > delta: '0:00:00.033604' > end: '2020-05-24 23:29:51.883830' > msg: non-zero return code > rc: 127 > start: '2020-05-24 23:29:51.850226' > stderr: '/bin/bash: ansible: command not found' > stderr_lines: > stdout: '' > stdout_lines: This is a misunderstanding. Do not run the command with ansible-playbook as "shell" task on the remote host! The "command" shall be run from the command-line on controller. The output will show all facts collected by the module "setup" on the remote host. The same facts will be collected automatically by a playbook when not disabled by "gather_facts: false". See https://docs.ansible.com/ansible/latest/modules/setup_module.html#examples shell> ansible dev -m setup Find the variables that fit your purpose. For example shell> cat playbook.yml - hosts: dev tasks: - debug: var: ansible_default_ipv4 - debug: msg: "MAC: {{ ansible_default_ipv4.macaddress }}" - debug: msg: "Network: {{ ansible_default_ipv4.network }}" shell> ansible-playbook playbook.yml HTH, -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/20200525071628.70797a56%40gmail.com. pgpCf1g1hqA7W.pgp Description: OpenPGP digital signature
Re: [ansible-project] ansible shell variable
This is the output: fatal: [deVPN]: FAILED! => changed=true cmd: |- ansible dev -m setup delta: '0:00:00.033604' end: '2020-05-24 23:29:51.883830' msg: non-zero return code rc: 127 start: '2020-05-24 23:29:51.850226' stderr: '/bin/bash: ansible: command not found' stderr_lines: stdout: '' stdout_lines: On Sunday, 24 May 2020 20:40:33 UTC-4, Vladimir Botka wrote: > > On Sun, 24 May 2020 16:55:52 -0700 (PDT) > Andrew Morgan > wrote: > > > 1) get the mac address > > 2) get the subnet > > > > --- > > - hosts: dev > > become: true > > #connection: local > > gather_facts: true > > Run the command below a see what "facts" are available when "gather_facts: > true" is enabled. > > shell> ansible dev -m setup > -- 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/b6f2d06e-86a9-4a68-990b-d21291c82f46%40googlegroups.com.
Re: [ansible-project] ansible shell variable
On Sun, 24 May 2020 16:55:52 -0700 (PDT) Andrew Morgan wrote: > 1) get the mac address > 2) get the subnet > > --- > - hosts: dev > become: true > #connection: local > gather_facts: true Run the command below a see what "facts" are available when "gather_facts: true" is enabled. shell> ansible dev -m setup -- 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/20200525024017.2373008b%40gmail.com. pgpEdMfo2k1NA.pgp Description: OpenPGP digital signature