Ansible delegate and run_once

后端 未结 1 470
孤街浪徒
孤街浪徒 2021-01-16 08:40

i write one specific roles for local and dev environment that will drop and recreate the database from first server in dbserver group which mostly used as the master databas

1条回答
  •  北荒
    北荒 (楼主)
    2021-01-16 09:33

    If you need to delegate your task to the first server only and run it once no matter how many servers in the current play, use:

    - name: drop database
      mysql_db: name={{ targetdbname }} state=absent
      when: targetdeploydb == "new"
      delegate_to: "{{ groups['dbserver'] | first }}"
      run_once: true
    

    0 讨论(0)
提交回复
热议问题