如果您需要將任務僅委派給第一臺服務器摧冀,并且無論當前清單中有多少臺服務器都運行一次task
- name: drop database
mysql_db: name={{ targetdbname }} state=absent
when: targetdeploydb == "new"
delegate_to: "{{ groups['dbserver'] | first }}"
run_once: true
如果您需要將任務僅委派給第一臺服務器摧冀,并且無論當前清單中有多少臺服務器都運行一次task
- name: drop database
mysql_db: name={{ targetdbname }} state=absent
when: targetdeploydb == "new"
delegate_to: "{{ groups['dbserver'] | first }}"
run_once: true