Merge branch 'master' of adellam/ansible-roles into master

This commit is contained in:
Andrea Dell'Amico 2020-03-03 18:42:13 +01:00 committed by Gitea
commit 39a086a894
5 changed files with 19 additions and 14 deletions

View File

@ -2,7 +2,7 @@
mysql_enabled: True mysql_enabled: True
mysql_pkg_state: present mysql_pkg_state: present
mysql_conf_dir: /etc/mysql/conf.d mysql_conf_dir: /etc/mysql/conf.d
mysql_socket: /var/run/mysqld/mysqld.sock mysql_socket: /run/mysqld/mysqld.sock
mysql_data_dir: /var/lib/mysql mysql_data_dir: /var/lib/mysql
mysql_log_dir: /var/log/mysql mysql_log_dir: /var/log/mysql
@ -12,11 +12,14 @@ mysql_packages_list:
- mysql-client - mysql-client
- mytop - mytop
- python-mysqldb - python-mysqldb
- python-pymysql
mysql_db_name: db_name mysql_db_name: db_name
mysql_db_user: db_user mysql_db_user: db_user
mysql_db_pwd: "We cannot save the password into the repository. Use another variable and change pgpass.j2 accordingly. Encrypt the file that contains the variable with ansible-vault" mysql_db_pwd: "We cannot save the password into the repository. Use another variable and change pgpass.j2 accordingly. Encrypt the file that contains the variable with ansible-vault"
mysql_binary_logging: True
mysql_server_id: 1
# Alternatives: utf8 # Alternatives: utf8
mysql_default_encoding: utf8mb4 mysql_default_encoding: utf8mb4
# Alternatives: utf8_unicode_ci utf8_bin # Alternatives: utf8_unicode_ci utf8_bin

View File

@ -1,7 +1,7 @@
--- ---
# 'localhost' needs to be the last item for idempotency, the mysql_user docs # 'localhost' needs to be the last item for idempotency, the mysql_user docs
- name: Secure the mysql root user with a password - name: Secure the mysql root user with a password
mysql_user: name=root host={{ item }} password={{ mysql_root_password }} mysql_user: name=root host={{ item }} password={{ mysql_root_password }} login_unix_socket={{ mysql_socket }}
when: mysql_root_password is defined when: mysql_root_password is defined
with_items: with_items:
- '{{ ansible_hostname }}' - '{{ ansible_hostname }}'
@ -12,7 +12,7 @@
tags: [ 'mysql', 'mysql_root' ] tags: [ 'mysql', 'mysql_root' ]
- name: Secure the mysql root user when no password has been defined - name: Secure the mysql root user when no password has been defined
mysql_user: name=root host={{ item }} password="" mysql_user: name=root host={{ item }} password="" login_unix_socket={{ mysql_socket }}
when: mysql_root_password is not defined when: mysql_root_password is not defined
with_items: with_items:
- '{{ ansible_hostname }}' - '{{ ansible_hostname }}'
@ -28,13 +28,13 @@
tags: [ 'mysql', 'mysql_root' ] tags: [ 'mysql', 'mysql_root' ]
- name: delete anonymous MySQL server user for the server hostname - name: delete anonymous MySQL server user for the server hostname
mysql_user: user="" host="{{ ansible_hostname }}" state="absent" mysql_user: user="" host="{{ ansible_hostname }}" state="absent" login_unix_socket={{ mysql_socket }}
tags: [ 'mysql', 'mysql_root' ] tags: [ 'mysql', 'mysql_root' ]
- name: delete anonymous MySQL server user for localhost - name: delete anonymous MySQL server user for localhost
mysql_user: user="" state="absent" mysql_user: user="" state="absent" login_unix_socket={{ mysql_socket }}
tags: mysql tags: mysql
- name: remove the MySQL test database - name: remove the MySQL test database
mysql_db: db=test state=absent mysql_db: db=test state=absent login_unix_socket={{ mysql_socket }}
tags: mysql tags: mysql

View File

@ -1,12 +1,12 @@
--- ---
- import_tasks: packages.yml - import_tasks: packages.yml
- import_tasks: mysql-conf.yml - import_tasks: mysql-conf.yml
when: mysql_enabled when: mysql_enabled | bool
- import_tasks: manage-mysql-service.yml - import_tasks: manage-mysql-service.yml
- import_tasks: configure_root_access.yml - import_tasks: configure_root_access.yml
when: mysql_enabled when: mysql_enabled | bool
- import_tasks: manage_my_db.yml - import_tasks: manage_my_db.yml
when: mysql_enabled when: mysql_enabled | bool
- import_tasks: mysql-backup.yml - import_tasks: mysql-backup.yml
when: mysql_enabled when: mysql_enabled | bool

View File

@ -1,12 +1,12 @@
--- ---
- name: Add databases to mysql, if any - name: Add databases to mysql, if any
mysql_db: name={{ item.name }} collation={{ item.collation }} encoding={{ item.encoding }} state=present mysql_db: name={{ item.name }} collation={{ item.collation }} encoding={{ item.encoding }} state=present login_unix_socket={{ mysql_socket }}
with_items: '{{ mysql_db_data | default([]) }}' with_items: '{{ mysql_db_data | default([]) }}'
when: item.name is defined when: item.name is defined
tags: [ 'mysql', 'mysql_db' ] tags: [ 'mysql', 'mysql_db' ]
- name: Add a user for the databases - name: Add a user for the databases
mysql_user: name={{ item.0.user }} password={{ item.0.pwd }} host={{ item.1 }} priv="{{ item.0.name }}.*:{{ item.0.user_grant }}" state=present mysql_user: name={{ item.0.user }} password={{ item.0.pwd }} host={{ item.1 }} priv="{{ item.0.name }}.*:{{ item.0.user_grant }}" state=present login_unix_socket={{ mysql_socket }}
with_subelements: with_subelements:
- '{{ mysql_db_data | default([]) }}' - '{{ mysql_db_data | default([]) }}'
- allowed_hosts - allowed_hosts
@ -14,7 +14,7 @@
tags: [ 'mysql', 'mysql_db', 'mysql_user' ] tags: [ 'mysql', 'mysql_db', 'mysql_user' ]
- name: Additional user privileges, if defined - name: Additional user privileges, if defined
mysql_user: name={{ item.0.user }} append_privs=yes priv="{{ item.0.name }}.*:{{ item.0.additional_privs }}" state=present mysql_user: name={{ item.0.user }} append_privs=yes priv="{{ item.0.name }}.*:{{ item.0.additional_privs }}" state=present login_unix_socket={{ mysql_socket }}
with_subelements: with_subelements:
- '{{ mysql_db_data | default([]) }}' - '{{ mysql_db_data | default([]) }}'
- allowed_hosts - allowed_hosts

View File

@ -42,6 +42,8 @@ bind-address = 0.0.0.0
bind-address = 127.0.0.1 bind-address = 127.0.0.1
{% endif %} {% endif %}
{% if mysql_binary_logging %}
server-id={{ mysql_server_id }}
# Enable binary logging. This is required for acting as a MASTER in a # Enable binary logging. This is required for acting as a MASTER in a
# replication configuration. You also need the binary log if you need # replication configuration. You also need the binary log if you need
# the ability to do point in time recovery from your latest backup. # the ability to do point in time recovery from your latest backup.
@ -49,6 +51,7 @@ log-bin=mysql-bin
# binary logging format - mixed recommended # binary logging format - mixed recommended
binlog_format=mixed binlog_format=mixed
{% endif %}
# Uncomment the following if you are using InnoDB tables # Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = {{ mysql_data_dir }} innodb_data_home_dir = {{ mysql_data_dir }}
@ -57,7 +60,6 @@ innodb_log_group_home_dir = {{ mysql_data_dir }}
# You can set .._buffer_pool_size up to 50 - 80 % # You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high # of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = {{ mysql_db_innodb_buffer_pool_size }} innodb_buffer_pool_size = {{ mysql_db_innodb_buffer_pool_size }}
innodb_additional_mem_pool_size = {{ mysql_db_innodb_additional_mem_pool_size }}
# Set .._log_file_size to 25 % of buffer pool size # Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = {{ mysql_db_innodb_log_file_size }} innodb_log_file_size = {{ mysql_db_innodb_log_file_size }}
innodb_log_buffer_size = {{ mysql_db_innodb_log_buffer_size }} innodb_log_buffer_size = {{ mysql_db_innodb_log_buffer_size }}