Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AnsibleNight_2021-02-10

hito58
February 14, 2021

 AnsibleNight_2021-02-10

Ansible Night Online 2021.02.10

hito58

February 14, 2021
Tweet

Other Decks in Technology

Transcript

  1. ①インベントリの共通化 --- - name: 状態確認 hosts: all tasks: - shell:

    view stats --cluster {{ cl_no }} register: result_status ・・・ # inventory worker1 cl_no=1 ansible_host=192.168.0.1 worker2 cl_no=2 ansible_host=192.168.0.1 全部同じアドレス(controllerのアドレス)
  2. ①インベントリの共通化 --- - name: 状態確認 hosts: all tasks: - shell:

    {{ command }} register: result_status ・・・ # inventory controller ansible_host=192.168.0.1 worker10 ansible_host=192.168.0.2 worker11 ansible_host=192.168.0.3 worker20 ansible_host=192.168.0.4 worker21 ansible_host=192.168.0.5
  3. ①インベントリの共通化 書き換え例: MW提供のコマンド利用するばあい --- - name: 状態確認 hosts: *0 tasks:

    - delegate_to: controller shell: {{ command }} register: result_status ・・・ ) # inventory controller ansible_host=192.168.0.1 worker10 ansible_host=192.168.0.2 worker11 ansible_host=192.168.0.3 worker20 ansible_host=192.168.0.4 worker21 ansible_host=192.168.0.5 [worker1] worker10 Worker11 [worker2] worker20 worker21
  4. ②Playbookを1つのリポジトリで管理する リポジトリ内構成例: output_perser@xxxx/ run_mw_command@xxxx/ library/ ../output_perser/library/output_perser.py ../run_mw_command/library/run_mw_command.py pb_config_update/ main.yml pb_get_log/

    main.yml roles/ vnfm@xxxx/ worker@xxxx/ ansible.cfg hosts.yml inventoryファイルも同一リポジトリ内 インベントリソースとしてTowerに登録 Jobテンプレートで使うPlaybookたち カスタムモジュールたち(Submodule) Roleたち(Submodule)