Ansibleでcontrollerの設定を管理する2 / 4
Catalyst Center workflow
次はcisco.catalystcenterのtemplate_workflow_managerへ、事前に準備したtemplate_detailsを渡す構成である。credentialは暗号化した変数等から渡す。
- name: Manage Catalyst Center templates
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Apply the intended template workflow
cisco.catalystcenter.template_workflow_manager:
catalystcenter_host: "{{ cc_host }}"
catalystcenter_username: "{{ cc_user }}"
catalystcenter_password: "{{ cc_password }}"
catalystcenter_version: "{{ cc_version }}"
catalystcenter_verify: true
config_verify: true
state: merged
config: "{{ template_details }}"
no_log: true
template_detailsではconfiguration_templatesにproject/template名、language、device_types/software_typeとtemplate_contentを指定する。別のdeploy_templateへ対象deviceとtemplate_parametersを関連付ける入力例は次になる。
template_details:
- deploy_template:
project_name: LabBranch
template_name: LabHostname
force_push: false
template_parameters:
- {param_name: hostname, param_value: LAB-BR1}
device_details:
device_ips: [192.0.2.11]
この例は対応するproject/templateとhostname変数を作成・commit済みとして配備する。template sourceにJinja構文がある場合、Ansible側で先に評価する内容とcontrollerへ渡すtemplate textを区別する。Velocityの$hostname等は別のengineの構文である。