- local_action: command "{{ item }}"
with_items:
- "inventoryctl.py group -U -n LNZ"
- "inventoryctl.py host -U -H {{ inventory_hostname }} -g LNZ"
when: (itsv_machine_serial.stdout is match "IBM,02781A6BX") or
(itsv_machine_serial.stdout is match "IBM,02781A6CX") or
(itsv_machine_serial.stdout is match "IBM,02781A6DX")
TASK [hostgroups : command] ***********************************************************************************************************************************************************************************
failed: [AMTEST1 -> localhost] (item=inventoryctl.py group -U -n LNZ) => {"changed": false, "cmd": "'inventoryctl.py group -U -n LNZ'", "item": "inventoryctl.py group -U -n LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
failed: [AMTEST1 -> localhost] (item=inventoryctl.py host -U -H AMTEST1 -g LNZ) => {"changed": false, "cmd": "'inventoryctl.py host -U -H AMTEST1 -g LNZ'", "item": "inventoryctl.py host -U -H AMTEST1 -g LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
- name: run test play
hosts: all
gather_facts: yes
roles:
- hostgroups
tasks:
- name: print out the hostname of target
command: hostname
- name: Print itsv_lparname
debug:
var: hostvars[inventory_hostname].inventory_lparname
- name: Print inventory_hostname
debug:
var: hostvars[inventory_hostname].inventory_hostname
# - name: Display all variables/facts known for a host
# debug:
#var: hostvars[inventory_hostname]
TASK [hostgroups : command] ***********************************************************************************************************************************************************************************
failed: [AMTEST1 -> localhost] (item=roles/hostgroups/files/inventoryctl.py group -U -n LNZ) => {"changed": false, "cmd": "'roles/hostgroups/files/inventoryctl.py group -U -n LNZ'", "item": "roles/hostgroups/files/inventoryctl.py group -U -n LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
failed: [AMTEST1 -> localhost] (item=roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ) => {"changed": false, "cmd": "'roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ'", "item": "roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
PLAY RECAP ****************************************************************************************************************************************************************************************************
AMTEST1 : ok=3 changed=2 unreachable=0 failed=1
root@lpgaixmgmtlx01:/etc/ansible/aix>file roles/hostgroups/files/inventoryctl.py
roles/hostgroups/files/inventoryctl.py: Python script, ASCII text executable
--
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+unsubscribe@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/aa1c1828-881f-49a3-bab4-6b3add73bb11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TASK [hostgroups : command] ***********************************************************************************************************************************************************************************
failed: [AMTEST1 -> localhost] (item=inventoryctl.py group -U -n LNZ) => {"changed": false, "cmd": "'inventoryctl.py group -U -n LNZ'", "item": "inventoryctl.py group -U -n LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
failed: [AMTEST1 -> localhost] (item=inventoryctl.py host -U -H AMTEST1 -g LNZ) => {"changed": false, "cmd": "'inventoryctl.py host -U -H AMTEST1 -g LNZ'", "item": "inventoryctl.py host -U -H AMTEST1 -g LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
PLAY RECAP ****************************************************************************************************************************************************************************************************
AMTEST1 : ok=2 changed=2 unreachable=0 failed=1
root@lpgaixmgmtlx01:/etc/ansible/aix>which inventoryctl.py
/usr/bin/inventoryctl.py
[AMTEST1 -> localhost])To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/aa1c1828-881f-49a3-bab4-6b3add73bb11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@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/c198d040-ee84-478f-b8f8-453f8050c08b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c198d040-ee84-478f-b8f8-453f8050c08b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@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/4ac914f0-da18-4635-ae0e-ff74a4e9461c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
---
# tasks file for hostgroups
- shell: /usr/bin/uname -L | cut -d ' ' -f2
register: itsv_lparname
- command: /usr/sbin/lsattr -El sys0 -a systemid -F value
register: itsv_machine_serial
- command: pwd
- local_action: command "{{ item }}"
with_items:
- "pwd"
- "inventoryctl.py group -U -n LNZ"
- "inventoryctl.py host -U -H {{ inventory_hostname }} -g LNZ"
when: (itsv_machine_serial.stdout is match "IBM,02781A6BX") or
(itsv_machine_serial.stdout is match "IBM,02781A6CX") or
(itsv_machine_serial.stdout is match "IBM,02781A6DX")
root@lpgaixmgmtlx01:/etc/ansible/aix>ansible-playbook -i AMTEST1, testplay.yml
PLAY [run test play] ******************************************************************************************************************************************************************************************
TASK [hostgroups : shell] *************************************************************************************************************************************************************************************
changed: [AMTEST1]
TASK [hostgroups : command] ***********************************************************************************************************************************************************************************
changed: [AMTEST1]
TASK [hostgroups : command] ***********************************************************************************************************************************************************************************
changed: [AMTEST1]
TASK [hostgroups : command] ***********************************************************************************************************************************************************************************
changed: [AMTEST1 -> localhost] => (item=pwd)
failed: [AMTEST1 -> localhost] (item=inventoryctl.py group -U -n LNZ) => {"changed": false, "cmd": "'inventoryctl.py group -U -n LNZ'", "item": "inventoryctl.py group -U -n LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
failed: [AMTEST1 -> localhost] (item=inventoryctl.py host -U -H AMTEST1 -g LNZ) => {"changed": false, "cmd": "'inventoryctl.py host -U -H AMTEST1 -g LNZ'", "item": "inventoryctl.py host -U -H AMTEST1 -g LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
PLAY RECAP ****************************************************************************************************************************************************************************************************
AMTEST1 : ok=3 changed=3 unreachable=0 failed=1
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4ac914f0-da18-4635-ae0e-ff74a4e9461c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@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/dc1a8a4a-1c6d-400f-9531-4626782c7a32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
- local_action: command "{{ item }}"
with_items:
- "pwd"
- "{{ role_path }}/files/inventoryctl.py group -U -n LNZ"
- "{{ role_path }}/files/inventoryctl.py host -U -H {{ inventory_hostname }} -g LNZ"
when: (itsv_machine_serial.stdout is match "IBM,02781A6BX") or
(itsv_machine_serial.stdout is match "IBM,02781A6CX") or
(itsv_machine_serial.stdout is match "IBM,02781A6DX")
TASK [hostgroups : command] ***********************************************************************************************************************************************************************************
changed: [AMTEST1 -> localhost] => (item=pwd)
failed: [AMTEST1 -> localhost] (item=/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py group -U -n LNZ) => {"changed": false, "cmd": "'/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py group -U -n LNZ'", "item": "/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py group -U -n LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
failed: [AMTEST1 -> localhost] (item=/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ) => {"changed": false, "cmd": "'/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ'", "item": "/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@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/3389c79e-de8b-4a47-adb3-5071dbbc7ee9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py group -U -n LNZ" without any fuss or specials.TASK [hostgroups : command] ***********************************************************************************************************************************************************************************
changed: [AMTEST1 -> localhost] => (item=pwd)
failed: [AMTEST1 -> localhost] (item=/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py group -U -n LNZ) => {"changed": true, "cmd": ["/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py", "group", "-U", "-n", "LNZ"], "delta": "0:00:00.109754", "end": "2018-08-06 16:36:54.041377", "item": "/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py group -U -n LNZ", "msg": "non-zero return code", "rc": 1, "start": "2018-08-06 16:36:53.931623", "stderr": "Traceback (most recent call last):\n File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 549, in <module>\n InventoryCtl()\n File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 31, in __init__\n self.read_settings()\n File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 42, in read_settings\n self.myconfig = dict(config.items('server'))\n File \"/usr/lib/python2.7/site-packages/backports/configparser/__init__.py\", line 869, in items\n raise NoSectionError(section)\nbackports.configparser.NoSectionError: No section: 'server'", "stderr_lines": ["Traceback (most recent call last):", " File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 549, in <module>", " InventoryCtl()", " File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 31, in __init__", " self.read_settings()", " File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 42, in read_settings", " self.myconfig = dict(config.items('server'))", " File \"/usr/lib/python2.7/site-packages/backports/configparser/__init__.py\", line 869, in items", " raise NoSectionError(section)", "backports.configparser.NoSectionError: No section: 'server'"], "stdout": "", "stdout_lines": []}
failed: [AMTEST1 -> localhost] (item=/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ) => {"changed": true, "cmd": ["/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py", "host", "-U", "-H", "AMTEST1", "-g", "LNZ"], "delta": "0:00:00.109299", "end": "2018-08-06 16:36:54.289337", "item": "/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ", "msg": "non-zero return code", "rc": 1, "start": "2018-08-06 16:36:54.180038", "stderr": "Traceback (most recent call last):\n File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 549, in <module>\n InventoryCtl()\n File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 31, in __init__\n self.read_settings()\n File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 42, in read_settings\n self.myconfig = dict(config.items('server'))\n File \"/usr/lib/python2.7/site-packages/backports/configparser/__init__.py\", line 869, in items\n raise NoSectionError(section)\nbackports.configparser.NoSectionError: No section: 'server'", "stderr_lines": ["Traceback (most recent call last):", " File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 549, in <module>", " InventoryCtl()", " File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 31, in __init__", " self.read_settings()", " File \"/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py\", line 42, in read_settings", " self.myconfig = dict(config.items('server'))", " File \"/usr/lib/python2.7/site-packages/backports/configparser/__init__.py\", line 869, in items", " raise NoSectionError(section)", "backports.configparser.NoSectionError: No section: 'server'"], "stdout": "", "stdout_lines": []}
--
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+unsubscribe@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/bc9eefe7-04c1-4b91-9842-c78b44517823%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bc9eefe7-04c1-4b91-9842-c78b44517823%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@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/a2c8144f-4bf0-41fa-984d-542bc8b7a8dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.