Repos with recipes to deploy some infrastructure services
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

90 lignes
3.8 KiB

  1. ---
  2. - name: Install the MySQL dependencies on RedHat
  3. package:
  4. name: "{{ item }}"
  5. state: present
  6. with_items:
  7. - mysql
  8. - MySQL-python
  9. when: ansible_facts.os_family == 'RedHat'
  10. - name: Install the MySQL dependencies on Debian
  11. package:
  12. name: "{{ item }}"
  13. state: present
  14. with_items:
  15. - mysql-client
  16. - python-mysqldb
  17. when: ansible_facts.os_family == 'Debian'
  18. - name: Create the PowerDNS Authoritative Server MySQL databases
  19. mysql_db:
  20. login_user: "{{ item['value']['priv_user'] }}"
  21. login_password: "{{ item['value']['priv_password'] }}"
  22. login_host: "{{ item['value']['host'] }}"
  23. login_port: "{{ item['value']['port'] | default('3306') }}"
  24. name: "{{ item['value']['dbname'] }}"
  25. state: present
  26. when: "item.key.split(':')[0] == 'gmysql'"
  27. with_dict: "{{ pdns_backends | combine(pdns_mysql_databases_credentials, recursive=True) }}"
  28. - name: Grant the PowerDNS Authoritative Server access to the MySQL databases
  29. mysql_user:
  30. login_user: "{{ item[0]['priv_user'] }}"
  31. login_password: "{{ item[0]['priv_password'] }}"
  32. login_host: "{{ item[0]['host'] }}"
  33. login_port: "{{ item[0]['port'] | default('3306') }}"
  34. name: "{{ item[0]['user'] }}"
  35. password: "{{ item[0]['password'] }}"
  36. host: "{{ item[1] }}"
  37. priv: "{{ item[0]['dbname'] }}.*:ALL"
  38. append_privs: yes
  39. state: present
  40. with_subelements:
  41. - "{{ pdns_backends | combine(pdns_mysql_databases_credentials, recursive=True) }}"
  42. - priv_host
  43. - skip_missing: yes
  44. - name: Check if the PowerDNS Authoritative Server MySQL databases are empty
  45. command: >
  46. mysql --user="{{ item['value']['user'] }}" --password="{{ item['value']['password'] }}"
  47. --host="{{ item['value']['host'] }}" --port "{{ item['value']['port'] | default('3306') }}" --batch --skip-column-names
  48. --execute="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '{{ item['value']['dbname'] }}'"
  49. when: item.key.split(':')[0] == 'gmysql'
  50. with_dict: "{{ pdns_backends }}"
  51. register: _pdns_check_mysql_db
  52. changed_when: False
  53. - name: Define the PowerDNS Authoritative Server database MySQL schema file path on RedHat < 7
  54. set_fact:
  55. _pdns_mysql_schema_file: "/usr/share/doc/pdns/schema.mysql.sql"
  56. when: ansible_facts.os_family == 'RedHat' and ansible_facts.distribution_major_version | int < 7
  57. - name: Define the PowerDNS Authoritative Server database MySQL schema file path on RedHat >= 7
  58. set_fact:
  59. _pdns_mysql_schema_file: "/usr/share/doc/pdns-backend-mysql-{{ _pdns_running_version | regex_replace('-rc[\\d]*$', '') }}/schema.mysql.sql"
  60. when: ansible_facts.os_family == 'RedHat' and ansible_facts.distribution_major_version | int >= 7
  61. - name: Define the PowerDNS Authoritative Server database MySQL schema file path on Debian
  62. set_fact:
  63. _pdns_mysql_schema_file: "/usr/share/dbconfig-common/data/pdns-backend-mysql/install/mysql"
  64. when: ansible_facts.os_family == 'Debian' and pdns_install_repo == ''
  65. - name: Define the PowerDNS Authoritative Server database MySQL schema file path on Debian
  66. set_fact:
  67. _pdns_mysql_schema_file: "/usr/share/doc/pdns-backend-mysql/schema.mysql.sql"
  68. when: ansible_facts.os_family == 'Debian' and pdns_install_repo != ''
  69. - name: Import the PowerDNS Authoritative Server MySQL schema
  70. mysql_db:
  71. login_user: "{{ item['item']['value']['user'] }}"
  72. login_password: "{{ item['item']['value']['password'] }}"
  73. login_host: "{{ item['item']['value']['host'] }}"
  74. login_port: "{{ item['item']['port'] | default('3306') }}"
  75. name: "{{ item.item['value']['dbname'] }}"
  76. state: import
  77. target: "{{ _pdns_mysql_schema_file }}"
  78. when: "item['item']['key'].split(':')[0] == 'gmysql' and item['stdout'] == '0'"
  79. with_items: "{{ _pdns_check_mysql_db['results'] }}"