2.3.4.2. フックの使用
フックは ホスト インベントリーファイルの OSEv3:vars セクションに定義されます。
各フックは Ansible タスクを定義する YAML ファイルをポイントする必要があります。このファイルは include として使用されます。つまり、このファイルは Playbook にすることはできず、タスクのセットである必要があります。 あいまいさを避けるためにフックファイルへの絶対パスを使用することがベストプラクティスとして推奨されます。
インベントリーファイルのフック定義の例
[OSEv3:vars]
openshift_master_upgrade_pre_hook=/usr/share/custom/pre_master.yml
openshift_master_upgrade_hook=/usr/share/custom/master.yml
openshift_master_upgrade_post_hook=/usr/share/custom/post_master.yml
openshift_node_upgrade_pre_hook=/usr/share/custom/pre_node.yml
openshift_node_upgrade_hook=/usr/share/custom/node.yml
openshift_node_upgrade_post_hook=/usr/share/custom/post_node.yml
pre_master.yml タスクの例
---
# Trivial example forcing an operator to ack the start of an upgrade
# file=/usr/share/custom/pre_master.yml
- name: note the start of a master upgrade
debug:
msg: "Master upgrade of {{ inventory_hostname }} is about to start"
- name: require an operator agree to start an upgrade
pause:
prompt: "Hit enter to start the master upgrade"