â ã¯ããã«
Ansible ã«ã¯ callback plugin ã¨ããä»çµã¿ããããçµæåºåã®å½¢å¼ã夿´ããããããã¨ãã§ãã¾ãã yaml ã«å¤æ´ããã¨ãæ¹è¡ã³ã¼ããã¨ã«æ¹è¡ãããå½¢ã§æ¨æºåºåããã¾ãã
æ¬è¨äºã§ããcallback plugin ã yaml
ã«å¤æ´ããæ¹æ³ã©ãåºåä¾ããç´¹ä»ãã¾ãã
ãªããæ¬ä»¶ã¯å æ¥ã¡ã³ã¿ã¼ã¨ãã¦åå ããã¦ããã ãããAnsibleããããä¼ ï¼ãµã¼ãç·¨ & NWç·¨ï¼2019.07 ã§ã®è³ªçå¿çã§ã®ããã¨ãã®ä¸ã§ãåå è ããããã ããã³ã¡ã³ãã§æ°ä»ããå¾ã¾ããã ï¼ãã¾ã¾ã§ç¹ã« yaml ã«å¤æ´ããç¨éãæãæµ®ãã³ã¾ããã§ãã»ã»ï¼
- åä½ç¢ºèªç°å¢: Ansible 2.8.0
- å¯¾è±¡å¨æ©: Cisco DevNet Sandox ä¸ã® IOS-XE ï¼ã¨ã¦ã便å©ã§ãï¼
â callback plugin ã yaml ã«å¤æ´ãã
ansible.cfg
ãç°å¢å¤æ°ãªã©ã§å¤æ´ã§ãã¾ãï¼åè: DEFAULT_STDOUT_CALLBACKï¼ãä»åã¯ãansible.cfg
ã§å¤æ´ãã¾ãã
[defaults] stdout_callback = yaml
ãªããansible-playbook
ã³ãã³ãã§ã¯ãªããansible
ã³ãã³ãã§ãã®è¨å®å¤æ´ãæå¹ã«ããããã«ã¯ãããã« bin_ansible_callbacks = True
ãå¿
è¦ã§ãã
â åºåä¾
Playbook
ä»åã¯ã ios_command
ã¢ã¸ã¥ã¼ã«ãå©ç¨ãã¦ãshow version
ã³ãã³ããå®è¡ããåºåçµæã® stdout
ãåºåããã¾ãã
- hosts: ios gather_facts: no tasks: - name: test ios_command: commands: - show version register: result - name: debug debug: var: result.stdout
å®è¡
$ ansible-playbook -i inventory ios_test.yml PLAY [ios] ************************************************************************************************************ TASK [test] *********************************************************************************************************** ok: [iosal1] TASK [debug] ********************************************************************************************************** ok: [iosal1] => result.stdout: - |- Cisco IOS XE Software, Version 16.08.01 Cisco IOS Software [Fuji], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.8.1, RELEASE SOFTWARE (fc3) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Tue 27-Mar-18 13:32 by mcpre (...ç¥...) 3 Gigabit Ethernet interfaces 32768K bytes of non-volatile configuration memory. 16370384K bytes of physical memory. 7774207K bytes of virtual hard disk at bootflash:. 0K bytes of WebUI ODM Files at webui:. Configuration register is 0x2102 PLAY RECAP ************************************************************************************************************ iosal1 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ãã®ããã«ãæ¹è¡ã³ã¼ããè§£éãããå½¢ã§è¡¨ç¤ºããã¾ãã
ãªãã
result.stdout: - |-
ã® |
㯠YAML ã§è¤æ°è¡ã®å¤ã示ã Syntax ã§ãã
åèï¼ããã©ã«ãã®å ´åï¼
åèã¾ã§ã«ãããã©ã«ãã®å ´åã®åºåçµæãæç²ãã¦æ²è¼ãã¾ãã
ok: [iosal1] => { "result.stdout": [ "Cisco IOS XE Software, Version 16.08.01\nCisco IOS Software [Fuji], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.8.1, RELEASE SOFTWARE (fc3)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2018 by Cisco Systems, Inc.\nCompiled Tue 27-Mar-18 13:32 by mcpre\(...ç¥...)3 Gigabit Ethernet interfaces\n32768K bytes of non-volatile configuration memory.\n16370384K bytes of physical memory.\n7774207K bytes of virtual hard disk at bootflash:.\n0K bytes of WebUI ODM Files at webui:.\n\nConfiguration register is 0x2102" ] }
ãã®ããã«ãæ¹è¡ã³ã¼ã \n
ã¯ãã®ã¾ã¾è¡¨ç¤ºããã¾ãã
ããã©ã«ãã®å ´åã§ããstdout
ã§ã¯ãªããstdout_lines
ã表示ããããã«ããã¨ã1è¡1ãªã¹ãã¢ã¤ãã ã¨ãã¦è¡¨ç¤ºãããã®ã§è¦ãããã§ãããã ãã¯ã©ã¼ãã¼ã·ã§ã³ãå
¥ãã¾ãã
ok: [iosal1] => { "result.stdout_lines": [ [ "Cisco IOS XE Software, Version 16.08.01", "Cisco IOS Software [Fuji], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.8.1, RELEASE SOFTWARE (fc3)", "Technical Support: http://www.cisco.com/techsupport", "Copyright (c) 1986-2018 by Cisco Systems, Inc.", "Compiled Tue 27-Mar-18 13:32 by mcpre", (...ç¥...) "3 Gigabit Ethernet interfaces", "32768K bytes of non-volatile configuration memory.", "16370384K bytes of physical memory.", "7774207K bytes of virtual hard disk at bootflash:.", "0K bytes of WebUI ODM Files at webui:.", "", "Configuration register is 0x2102" ] ] }
â ã¾ã¨ã
callback plugin ã yaml ã«å¤æ´ãã¦ãæ¹è¡ã³ã¼ããã¨ã«æ¹è¡ãããå½¢ã§æ¨æºåºåããããã¨ããç´¹ä»ãã¾ããã
[2023/04/20]
ãã®è¨äºã®4å¹´å¾ã«ãä¼¼ããããªè¨äºãã¾ãæ¸ãã¦ãã¾ã£ãã®ã§ãªã³ã¯ãæ²è¼ãã¾ãã以ä¸ã®è¨äºã§ã¯ãã³ã¬ã¯ã·ã§ã³ã«ç§»è¡å¾ãªã®ã§ community.general.yaml
ã¨ãã表è¨ã«ãªã£ã¦ãã¾ãã