Ansible ã®ã©ããã¼ã¢ã¸ã¥ã¼ã«ã表示ããPlaybook ã¤ããã¾ããã pic.twitter.com/X0fnAzFXoI
— ããã¡(yokochi) @ Ansibleå®è·µã¬ã¤ã 第3ç (@akira6592) 2019å¹´12æ19æ¥
â ã¯ããã«
Ansible ã«ã¯ 3,000 ãè¶ ããã¢ã¸ã¥ã¼ã«ãæ¨æºã§å«ã¾ãã¦ãã¾ãã
ããã¾ã§å¢ããã¨ãä»æ¥ã¯ä½ã®ã¢ã¸ã¥ã¼ã«ã触ããããªï¼ä»æ¥ã®ã©ããã¼ã¢ã¸ã¥ã¼ã«ã¯ãªãã ããï¼ãã¨æ°ã«ãªãã¾ãããã
ãã®è¨äºã§ã¯ããããªã¨ãã«ã´ã£ããã§æ¥µãã¦å®ç¨ç㪠Playbook ããç´¹ä»ãã¾ãã
â» ãã ããçµæã«å¯¾ãã¦å½æ¹ã¯ä½ã責任ãè² ãã¾ãã
- åä½ç°å¢
- Ansible 2.9.1
â Playbook
ansible-doc
ã³ãã³ãã® -l
ã§ã¢ã¸ã¥ã¼ã«ã®ä¸è¦§ãã-j
ãªãã·ã§ã³ã§ JSON å½¢å¼ã§è¡¨ç¤ºããã¾ãï¼-j
ã¯Ansible 2.9 ããã®æ©è½ï¼ã
ãã®çµæãåãåã£ã¦ãfrom_json
ãã£ã«ã¿ã¼ã§ãAnsible ã®ãã£ã¯ã·ã§ããªã«ãã¼ã¹ãããã®çµæãdict2items
ãã£ã«ã¿ã¼ã§ãªã¹ãã«å¤æãã¾ãã
ãã®ãªã¹ãããwith_random_choice
ã«ããã¦ãã©ã³ãã ã«1ã¤ã®ã¢ã¸ã¥ã¼ã«ãé¸æãã¾ãã
- hosts: localhost gather_facts: no connection: local tasks: - name: get module list command: "ansible-doc -l -j" changed_when: no register: result - name: do uranai debug: msg: - "ä»æ¥ã®ã©ããã¼ã¢ã¸ã¥ã¼ã«ã¯ã»ã»ã»ã»" - "" - "" - " {{ item.key }} ã§ãï¼ï¼" - "" - "" - "æ¦è¦: {{ item.value }}" - "ä»ããã¢ã¯ã»ã¹ï¼ï¼ >> https://docs.ansible.com/ansible/latest/modules/{{ item.key }}_module.html" with_random_choice: "{{ result.stdout | from_json | dict2items }}" loop_control: label: "{{ item.key }}"
â å®è¡ä¾
å®è¡ä¾ã§ããã¤ã³ãã³ããªãã¡ã¤ã«ã¯ä¸è¦ã§ãã
$ ansible-playbook -i localhost, uranai.yml PLAY [localhost] **************************************************************************************************** TASK [get module list] ********************************************************************************************** ok: [localhost] TASK [do uranai] **************************************************************************************************** ok: [localhost] => (item=fortios_system_replacemsg_spam) => { "msg": [ "ä»æ¥ã®ã©ããã¼ã¢ã¸ã¥ã¼ã«ã¯ã»ã»ã»ã»", "", "", " fortios_system_replacemsg_spam ã§ãï¼ï¼", "", "", "æ¦è¦: Replacement messages in Fortinet's FortiOS and FortiGate", "ä»ããã¢ã¯ã»ã¹ï¼ï¼ >> https://docs.ansible.com/ansible/latest/modules/fortios_system_replacemsg_spam_module.html" ] } PLAY RECAP ********************************************************************************************************** localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ã¡ãªã¿ã«ä»æ¥ã®ç§ã®ã©ããã¼ã¢ã¸ã¥ã¼ã«ã¯ fortios_system_replacemsg_spam
ã§ããã
fortios_*
ã¢ã¸ã¥ã¼ã«ã¯ 400å以ä¸ãããã®ã§ãåºç¾é »åº¦ã¯é«ãã¨æãã¾ãã
ããä¸åããããã£ã¦ã¿ã¾ãããã
ok: [localhost] => (item=slxos_config) => { "msg": [ "ä»æ¥ã®ã©ããã¼ã¢ã¸ã¥ã¼ã«ã¯ã»ã»ã»ã»", "", "", " slxos_config ã§ãï¼ï¼", "", "", "æ¦è¦: Manage Extreme Networks SLX-OS configuration sections", "ä»ããã¢ã¯ã»ã¹ï¼ï¼ >> https://docs.ansible.com/ansible/latest/modules/slxos_config_module.html" ] }
slxos_config
ã¢ã¸ã¥ã¼ã«ã§ããããããã¯ã¼ã¯ã¢ã¸ã¥ã¼ã«ãç¶ãã¦ããªãã ãå¬ããã§ãã
ããèããããåãæ¥ã«å®è¡ãããåãçµæã«ãªãã¹ãã§ããããããã¦ããã¾ãããã»ã»ã
â ãããã«
表示ã®ä»æ¹ã¯ãã£ã¨ããããã«ã¹ã¿ãã¤ãºã§ãã¾ãããçµã¿åãã次第ã§ãã£ãããã¼ã«ã«éããã¨ãã§ãã¾ãããã²ãæ´»ç¨ãã ããã