Browse Source

automate generation of random root mysql password

requires gen_passwd module
letsencrypt-seafile
Lorenzo 8 years ago
parent
commit
8de232cb1d
3 changed files with 12 additions and 4 deletions
  1. +1
    -1
      roles/seafile.mysql/defaults/main.yml
  2. +10
    -2
      roles/seafile.mysql/tasks/main.yml
  3. +1
    -1
      roles/seafile.mysql/templates/.my.cnf.j2

+ 1
- 1
roles/seafile.mysql/defaults/main.yml View File

@ -2,7 +2,7 @@
mysql_port: 3306
mysql_bind_address: "0.0.0.0"
mysql_root_db_pass: foobar
#mysql_root_db_pass: foobar
mysql_db:
- name: foo


+ 10
- 2
roles/seafile.mysql/tasks/main.yml View File

@ -26,8 +26,16 @@
- name: Start the mysql services Redhat
service: name={{ mysql_service }} state=started enabled=yes
- name: generate a new random mysql root passwrod
gen_passwd: length=16
register: random_root_pass
when: mysql_root_db_pass is not defined
- debug:
var: random_root_pass.passwd
- name: update mysql root password for all root accounts
mysql_user: name=root host={{ item }} password={{ mysql_root_db_pass }}
mysql_user: name=root host={{ item }} password={{ mysql_root_db_pass | default(random_root_pass.passwd) }}
with_items:
- "{{ ansible_hostname }}"
- 127.0.0.1
@ -36,7 +44,7 @@
when: ansible_hostname != 'localhost'
- name: update mysql root password for all root accounts
mysql_user: name=root host={{ item }} password={{ mysql_root_db_pass }}
mysql_user: name=root host={{ item }} password={{ mysql_root_db_pass | default(random_root_pass.passwd) }}
with_items:
- 127.0.0.1
- ::1


+ 1
- 1
roles/seafile.mysql/templates/.my.cnf.j2 View File

@ -1,3 +1,3 @@
[client]
user=root
password={{ mysql_root_db_pass }}
password={{ mysql_root_db_pass | default(random_root_pass.passwd) }}

Loading…
Cancel
Save