Skip to content

Commit

Permalink
Merge pull request #20 from Oefenweb/consistency-changes
Browse files Browse the repository at this point in the history
Consistency changes
  • Loading branch information
tersmitten committed Oct 1, 2023
2 parents bbe0378 + 6720eab commit 0426c41
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 105 deletions.
4 changes: 1 addition & 3 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
warn_list:
- role-name
- name[play]
- name[casing]
- '204'
- '303'
- '306'
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
python-version: '3.x'

- name: Install test dependencies
run: pip install ansible-lint[community,yamllint]
run: |
pip install ansible-lint
ansible-galaxy install -r requirements.yml
- name: Lint code
run: |
Expand All @@ -43,11 +45,8 @@ jobs:
matrix:
include:
- distro: debian8
ansible-version: '<2.10'
- distro: debian9
- distro: debian10
- distro: ubuntu1604
ansible-version: '>=2.9, <2.10'
- distro: ubuntu1604
ansible-version: '>=2.10, <2.11'
- distro: ubuntu1604
Expand Down
3 changes: 2 additions & 1 deletion requirements.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# requirements file
---
collections: []
collections:
- name: community.mysql
22 changes: 14 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: get mysql version
shell: >
- name: get mysql version # noqa risky-shell-pipe

Check warning on line 3 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.shell: >
mysqld --version | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p'
register: _mysql_version
changed_when: false
Expand All @@ -11,7 +11,8 @@
- percona-server-tools
- percona-server-tools-get-mysql-version

- include: reset-root-password-lt-57.yml
- name: reset root password < 5.7

Check warning on line 14 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 14 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 14 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 14 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 14 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 14 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.import_tasks: reset-root-password-lt-57.yml
when:
- percona_server_tools_reset_root_password.run | default(false)
- _mysql_version.stdout is version('5.7', '<')
Expand All @@ -22,7 +23,8 @@
- percona-server-tools-reset-root-password
- percona-server-tools-reset-root-password-lt-57

- include: reset-root-password-ge-57.yml
- name: reset root password >= 5.7

Check warning on line 26 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 26 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 26 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 26 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 26 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 26 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.import_tasks: reset-root-password-ge-57.yml
when:
- percona_server_tools_reset_root_password.run | default(false)
- _mysql_version.stdout is version('5.7', '>=')
Expand All @@ -33,31 +35,35 @@
- percona-server-tools-reset-root-password
- percona-server-tools-reset-root-password-ge-57

- include: reset-ib-logfile.yml
- name: reset ib_logfile

Check warning on line 38 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 38 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 38 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 38 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 38 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 38 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.import_tasks: reset-ib-logfile.yml
when: percona_server_tools_reset_ib_logfile.run | default(false)
tags:
- configuration
- tools
- percona-server-tools
- percona-server-tools-reset-ib-logfile

- include: setup-slave-replication.yml
- name: setup slave replication

Check warning on line 47 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 47 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 47 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 47 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 47 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 47 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.import_tasks: setup-slave-replication.yml
when: percona_server_tools_setup_slave_replication.run | default(false)
tags:
- configuration
- tools
- percona-server-tools
- percona-server-tools-setup-slave-replication

- include: setup-slave-replication-gtid.yml
- name: setup slave replication gtid

Check warning on line 56 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 56 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 56 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 56 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 56 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 56 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.import_tasks: setup-slave-replication-gtid.yml
when: percona_server_tools_setup_slave_replication_gtid.run | default(false)
tags:
- configuration
- tools
- percona-server-tools
- percona-server-tools-setup-slave-replication-gtid

- include: setup-master-replication.yml
- name: setup master replication

Check warning on line 65 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 65 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 65 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 65 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 65 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 65 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.import_tasks: setup-master-replication.yml
when: percona_server_tools_setup_master_replication.run | default(false)
tags:
- configuration
Expand Down
14 changes: 7 additions & 7 deletions tasks/reset-ib-logfile.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
# tasks file
---
- name: reset ib logfile | get InnoDB shutdown mode

Check warning on line 3 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 3 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
mysql_variables:
community.mysql.mysql_variables:
variable: innodb_fast_shutdown
register: _innodb_fast_shutdown_value
when: percona_server_tools_reset_ib_logfile.check_innodb_shutdown_mode | default(true)
tags:
- percona-server-tools-reset-ib-logfile-check-innodb-shutdown-mode

- name: reset ib logfile | store InnoDB shutdown mode (as fact)

Check warning on line 11 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 11 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 11 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 11 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 11 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.

Check warning on line 11 in tasks/reset-ib-logfile.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
set_fact:
ansible.builtin.set_fact:
percona_server_tools_innodb_fast_shutdown: "{{ _innodb_fast_shutdown_value.msg }}"
tags:
- percona-server-tools-reset-ib-logfile-check-innodb-shutdown-mode

- name: reset ib logfile | set InnoDB shutdown mode
mysql_variables:
community.mysql.mysql_variables:
variable: innodb_fast_shutdown
value: "1"
when: percona_server_tools_reset_ib_logfile.check_innodb_shutdown_mode | default(true)
tags:
- percona-server-tools-reset-ib-logfile-set-innodb-shutdown-mode

- name: reset ib logfile | stop service
service:
ansible.builtin.service:
name: mysql
state: stopped
tags:
- percona-server-tools-reset-ib-logfile-stop-service

- name: reset ib logfile | remove ib_logfile(s)
file:
ansible.builtin.file:
path: "{{ item }}"
state: absent
with_items: "{{ percona_server_tools_reset_ib_logfile.ib_logfiles | default(['/var/lib/mysql/ib_logfile0', '/var/lib/mysql/ib_logfile1']) }}"
tags:
- percona-server-tools-reset-ib-logfile-remove

- name: reset ib logfile | start service
service:
ansible.builtin.service:
name: mysql
state: started
tags:
- percona-server-tools-reset-ib-logfile-start-service

- name: reset ib logfile | restore InnoDB shutdown mode
mysql_variables:
community.mysql.mysql_variables:
variable: innodb_fast_shutdown
value: "{{ percona_server_tools_innodb_fast_shutdown }}"
when: percona_server_tools_reset_ib_logfile.check_innodb_shutdown_mode | default(true)
Expand Down
16 changes: 8 additions & 8 deletions tasks/reset-root-password-ge-57.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# tasks file
---
- name: reset root password | stop service
service:
ansible.builtin.service:
name: mysql
state: stopped
tags:
- percona-server-tools-reset-root-password-ge-57-stop-service

- name: reset root password | create init-file
copy:
ansible.builtin.copy:
dest: "{{ percona_server_tools_my_init_file }}"
content: |
UPDATE `mysql`.`user` SET `authentication_string` = PASSWORD('{{ percona_server_tools_reset_root_password.root_password }}'), plugin = 'mysql_native_password' WHERE `User` = 'root';
Expand All @@ -21,15 +21,15 @@
- percona-server-tools-reset-root-password-ge-57-init-file-create

- name: reset root password | copy my.cnf
command: >
ansible.builtin.command: >
cp -av {{ percona_server_tools_my_cnf_file }} {{ percona_server_tools_my_cnf_file_safe }}
register: _my_cnf_copy
changed_when: _my_cnf_copy.stdout_lines | length > 0
tags:
- percona-server-tools-reset-root-password-ge-57-my-cnf-copy

- name: reset root password | make my.cnf safe
lineinfile:
ansible.builtin.lineinfile:
path: "{{ percona_server_tools_my_cnf_file_safe }}"
state: absent
regexp: "{{ item }}"
Expand All @@ -38,7 +38,7 @@
- percona-server-tools-reset-root-password-ge-57-my-cnf-safe

- name: reset root password | start service without grants and networking
command: >
ansible.builtin.command: >
timeout --preserve-status {{ percona_server_tools_mysqld_start_timeout }}s mysqld
--defaults-file={{ percona_server_tools_my_cnf_file_safe }}
--init-file={{ percona_server_tools_my_init_file }}
Expand All @@ -53,7 +53,7 @@
- percona-server-tools-reset-root-password-ge-57-start-service

- name: reset root password | wait for service to finish
async_status:
ansible.builtin.async_status:
jid: "{{ _mysqld_sleeper.ansible_job_id }}"
register: _mysqld_sleeper_result
until: _mysqld_sleeper_result.finished
Expand All @@ -63,7 +63,7 @@
- percona-server-tools-reset-root-password-ge-57-end-service

- name: reset root password | cleanup tmp files
file:
ansible.builtin.file:
path: "{{ item }}"
state: absent
with_items:
Expand All @@ -73,7 +73,7 @@
- percona-server-tools-reset-root-password-ge-57-cleanup

- name: reset root password | start service
service:
ansible.builtin.service:
name: mysql
state: started
tags:
Expand Down
6 changes: 3 additions & 3 deletions tasks/reset-root-password-lt-57.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# tasks file
---
- name: reset root password | flush privileges
command: >
ansible.builtin.command: >
mysql --defaults-file=/etc/mysql/debian.cnf --database=mysql -e "FLUSH PRIVILEGES;"
changed_when: false
tags:
- percona-server-tools-reset-root-password-lt-57-flush-privileges

- name: reset root password | login as debian-sys-maint and reset root password
command: >
ansible.builtin.command: >
mysql
--defaults-file=/etc/mysql/debian.cnf
--database=mysql
Expand All @@ -20,7 +20,7 @@
- percona-server-tools-reset-root-password-lt-57-update-password

- name: reset root password | flush privileges
command: >
ansible.builtin.command: >
mysql --defaults-file=/etc/mysql/debian.cnf --database=mysql -e "FLUSH PRIVILEGES;"
changed_when: false
tags:
Expand Down
Loading

0 comments on commit 0426c41

Please sign in to comment.