Skip to content

Commit 7af6d04

Browse files
tgadievarno49
authored andcommitted
Epmldi 1429 (#2)
* Initial commit * edit molecule settings * edit molecule settings * edit gitlab-ci * changed travis link * test travis ci * readme * edit molecule settings for aws and epc * fixed "too many spaces.." and "too many blank lines" * fixed "too many spaces.." and "too many blank lines" * Update Readme to change ci status tag * fixed "too many spaces.." and "too many blank lines" * fixed "too many spaces.." and "too many blank lines" * add loop control * fixed wrong indentation * fixed wrong indentation * fix lint * fixed lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix playbook * Fix trailing-spaces * Add debugs * fix playbook * change gpgkey for mysql * add update_cache * add update_cache * change packages * change packages * add key * fix syntax problem * fix syntax problem * delete systemd * fix: 'mysql_replication_master' is undefined * fix lint * comment no_log for debug * fix lint * fix lint * debug mysql hosts * add host_all in mysql_user * delete debug * fix: update mysql root * add "find temporary password" * add debug file /var/log/mysqld.log * add debug file /var/log/mysqld.log * define mysql_log in default * fix logs file * fix logs * add handler * fix lint * fix lint * add slurp * add regex * fix lint * set default password for mysql root * change place for create main log file * fix password * fix password * fix lint * debug mysql root password * Test colors * debug password * fix password * fix password * test gitlab overrides * fix password * fix password * Test travis coloring * Test global env var * Test unbuffer * Fix lint * Change webhook * Remove env vars * Remove unbuffered * Test ansible-lint in molecule * Test ansible-lint arguments * Test full debug * Test additional options * Run ansible-lint * Change ansible-lint arguments * fix password * fix password * fix some errors * fix Python libraries * fix password * fix lint * fix few errors * fix additional parameters * fix lint * fix lint * fix lint * fix lint * fix lint * edit default variables * fix last time * add skip lint for task change password * fix lint * fix lint * fix default password root * add general log * Change root password reset handling * Fix pytest version * Add AWS tests * Add EPC tests * Add centos6 tests * Change molecule.yml * Turn on log * Change docker image for centos6 * Change groups name * Fix prepare playbook * Tests without root * Return become:True * Change shape * Remove create datadir step to meet idempotence * Remove create datadir * Add webhooks * add additional parameters in template * edit secure settings * fix spelling mistake * fix additional_parameters * fix "Remove file reset.sql" * test additional_parameters * edit "Copy my.cnf global MySQL configuration." * fix my.cnf template * Add molecule scenarios for different mysql versions * Change scenarios to avoid duplicates * Lint fix: new line character at the end of file * fix for mysql 5.6 * fix readme * fix mariadb * Fix for 5.5 and 5.6 * change readme * Test mariadb * Fix molecule config * Test docker config * Fix molecule.cfg * Fix lint * Try ansible colors * Fix yaml * test ANSIBLE_FORCE_COLOR * Test tput * Try force-color * Test ANSIBLE_FORCE_COLOR * Adjust gitlab-ci * Change molecule * Add env parameter to molecule * Enable cloud tests * Test version 5.5 * Fix new line character at the end of file * Tests mysql 5.6 docker * change default settings * change readme * change readme * Enable cloud tests * Test AWS USEAST * Test AWS-USEAST-2 * Revert changes * Enable all cloud tests * Test on AWS * Full test with selinux * Update Readme [skip ci] * Update Readme * edit default parametrs * add quotes on task's name * add author in meta [skip ci] * edit meta [skip ci] * edit meta [skip ci] * change defaults * add quotes in handlers * Update Readme, meta and molecule playbooks * edit variables [skip ci] * edit template [skip ci] * add when for mysql_python_packages * fix error with line * fix msg: The PyMySQL or MySQL-python module is required." * add quotes * fix variables * add become * edit readme * add quotes * add "" * Test template * Test template * Test template * Test block become * Adjust become * Test import_tasks * Add blocks become * Fix handler become * Fix compare to empty string * Test lint rules * Test lint version * Test pip2 * Test install from repo * Test ansible-lint default rules * Add config ansible-lint * Test docker * Test full path lint * Test ansible-lint path * Test lint for configure * Test lint path * Add ls debug * ls debug * Test lint errors * Change ansible-lint call * Add ansible-lint config * Fix lint errors and enable docker test * Enable cloud tests * Update gitlab-ci to call ansibe-lint correctly * Final fixes: syntax and lint * MariaDB test * Added badges to Readme, fixed quotes
1 parent a7671a9 commit 7af6d04

File tree

8 files changed

+58
-53
lines changed

8 files changed

+58
-53
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ stages:
77
before_script:
88
- ansible --version
99
- molecule --version
10+
- ansible-lint --version
1011

1112
variables:
1213
GET_SOURCES_ATTEMPTS: "5"
@@ -16,7 +17,8 @@ Ansible lint:
1617
before_script:
1718
- git clone https://github.com/lean-delivery/ansible-lint-rules.git ~/ansible-lint-rules
1819
script:
19-
- ansible-lint -c .ansible-lint `find . -regex ".*\.\(yml\)"`
20+
- ansible-lint . $(find . -name \*.yml) -c .ansible-lint
21+
2022
after_script:
2123
- rm -rf ~/ansible-lint-rules
2224
tags:

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ before_install:
1414
- git clone -b ${lint_version} https://github.com/lean-delivery/ansible-lint-rules.git ~/ansible-lint-rules
1515

1616
install:
17-
- pip install --upgrade ansible==2.5.* ansible-lint docker-py molecule==2.17 pyOpenSSL PyYAML pytest==3.7.4
17+
- pip install --upgrade ansible==2.5.* docker-py molecule==2.17 pyOpenSSL PyYAML pytest==3.7.4
18+
- pip install git+https://github.com/ansible/ansible-lint.git
1819
- ansible --version
20+
- ansible-lint --version
1921

2022
script:
21-
- ansible-lint -c .ansible-lint `find . -regex ".*\.\(yml\)"`
23+
- ansible-lint . $(find . -name \*.yml) -c .ansible-lint
2224
- molecule test -s default
2325

2426
notifications:

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Ansible Role: MySQL
22
[![License](https://img.shields.io/badge/license-Apache-green.svg?style=flat)](https://raw.githubusercontent.com/lean-delivery/ansible-role-mysql/master/LICENSE)
3-
[![Build Status](https://travis-ci.org/lean-delivery/ansible-role-mysql.svg?branch=master)](https://travis-ci.org/lean-delivery/ansible-role-mysql)
3+
[![Build Status](https://travis-ci.org/lean-delivery/ansible-role-mysql.svg)](https://travis-ci.org/lean-delivery/ansible-role-mysql)
4+
[![Galaxy](https://img.shields.io/badge/galaxy-lean_delivery.mysql-blue.svg)](https://galaxy.ansible.com/lean_delivery/mysql)
5+
![Ansible](https://img.shields.io/ansible/role/d/35413.svg)
6+
![Ansible](https://img.shields.io/badge/dynamic/json.svg?label=min_ansible_version&url=https%3A%2F%2Fgalaxy.ansible.com%2Fapi%2Fv1%2Froles%2F35413%2F&query=$.min_ansible_version)
47

58
## Summary
69

handlers/mysql_restart.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
block:
44
- name: "Stop MySQL"
55
service:
6-
name: '{{ mysql_service_name }}'
6+
name: "{{ mysql_service_name }}"
77
state: stopped
88

99
- name: "Wait until the lock file is removed"
@@ -13,14 +13,14 @@
1313

1414
- name: "Start mysql"
1515
service:
16-
name: '{{ mysql_service_name }}'
16+
name: "{{ mysql_service_name }}"
1717
state: started
1818
become: True
1919

2020
- name: "Wait for service to be ready"
2121
wait_for:
22-
port: '{{ mysql_port }}'
23-
host: '{{ mysql_bind_address }}'
22+
port: "{{ mysql_port }}"
23+
host: "{{ mysql_bind_address }}"
2424
connect_timeout: 3
2525
delay: 3
2626
timeout: 30

tasks/configure.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
template:
66
src: my.cnf.j2
77
dest: "{{ mysql_config_file }}"
8-
owner: "root"
9-
group: "root"
10-
mode: "0644"
8+
owner: root
9+
group: root
10+
mode: 0644
1111
force: "{{ overwrite_global_mycnf }}"
1212
register: mysql_config
1313
notify: restart mysql
@@ -16,9 +16,9 @@
1616
file:
1717
path: "{{ mysql_pid_file | dirname }}"
1818
state: directory
19-
owner: "mysql"
20-
group: "mysql"
21-
mode: "0755"
19+
owner: mysql
20+
group: mysql
21+
mode: 0755
2222

2323
- name: "Clear InnoDB logs"
2424
include_tasks: clear_innodb_logs.yml
@@ -28,18 +28,18 @@
2828
file:
2929
path: "{{ mysql_config_include_dir }}"
3030
state: directory
31-
owner: "root"
32-
group: "root"
33-
mode: "0755"
31+
owner: root
32+
group: root
33+
mode: 0755
3434
when: mysql_config_include_files | length
3535

3636
- name: "Create slow query log file (if configured)."
3737
file:
3838
path: "{{ mysql_slow_query_log_file }}"
3939
state: touch
40-
owner: "mysql"
40+
owner: mysql
4141
group: "{{ mysql_log_file_group }}"
42-
mode: "0640"
42+
mode: 0640
4343
register: touch_slowlog
4444
changed_when: touch_slowlog.diff.before.state != "file"
4545
when: mysql_slow_query_log_enabled
@@ -48,16 +48,15 @@
4848
file:
4949
path: "{{ mysql_log_error }}"
5050
state: touch
51-
owner: "mysql"
51+
owner: mysql
5252
group: "{{ mysql_log_file_group }}"
53-
mode: "0640"
54-
seuser: "system_u"
55-
serole: "object_r"
56-
setype: "mysqld_log_t"
57-
selevel: "s0"
53+
mode: 0640
54+
seuser: system_u
55+
serole: object_r
56+
setype: mysqld_log_t
57+
selevel: s0
5858
register: touch_log
5959
changed_when: touch_log.diff.before.state != "file"
60-
when: mysql_log_error != ""
6160

6261
- name: "Start MySQL service"
6362
service:

tasks/databases_and_users.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: "Ensure MySQL databases are present."
2+
- name: 'Ensure MySQL databases are present.'
33
mysql_db:
44
name: "{{ item.name }}"
55
collation: "{{ item.collation | default('utf8_general_ci') }}"
@@ -10,7 +10,7 @@
1010
login_password: "{{ mysql_root_password }}"
1111
with_items: "{{ mysql_databases }}"
1212

13-
- name: "Ensure MySQL users are present."
13+
- name: 'Ensure MySQL users are present.'
1414
mysql_user:
1515
name: "{{ item.name }}"
1616
host: "{{ item.host | default('localhost') }}"

tasks/secure-installation.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
# Reset default passwort for root didn't work with module mysql_user,
2+
# Reset default passwort for root didn"t work with module mysql_user,
33
# that why we use this block
44
- name: "Make new mysql admin user"
55
block:
66
- name: "Check mysql version"
77
mysql_variables:
8-
variable: "version"
8+
variable: version
99
login_user: "{{ mysql_root_username }}"
1010
login_password: "{{ mysql_root_password }}"
1111
register: mysql_version_out
@@ -16,7 +16,7 @@
1616

1717
- name: "Out mysql_version"
1818
debug:
19-
var: "mysql_version"
19+
var: mysql_version
2020
rescue:
2121
- name: "Clear InnoDB logs and restart MySQL in skip-grant-tables mode"
2222
block:
@@ -25,11 +25,11 @@
2525

2626
- name: "Copy init.cnf for skip-grant-tables mode"
2727
template:
28-
src: "init.cnf.j2"
28+
src: init.cnf.j2
2929
dest: "{{ mysql_config_file }}"
30-
owner: "root"
31-
group: "root"
32-
mode: "0644"
30+
owner: root
31+
group: root
32+
mode: 0644
3333
force: True
3434

3535
- name: "Start mysql with skip-grant-tables"
@@ -48,7 +48,7 @@
4848

4949
- name: "Check mysql version"
5050
mysql_variables:
51-
variable: "version"
51+
variable: version
5252
register: mysql_version_out
5353

5454
- name: "Set mysql version"
@@ -57,19 +57,19 @@
5757

5858
- name: "Out mysql_cli_version"
5959
debug:
60-
var: "mysql_version"
60+
var: mysql_version
6161

6262
- name: "Copy reset.sql for root reset"
6363
template:
64-
src: "reset.sql.j2"
65-
dest: "/tmp/reset.sql"
64+
src: reset.sql.j2
65+
dest: /tmp/reset.sql
6666
force: True
6767

6868
- name: "Reset root credentials"
6969
mysql_db:
70-
name: "mysql"
70+
name: mysql
7171
state: import
72-
target: "/tmp/reset.sql"
72+
target: /tmp/reset.sql
7373

7474
- name: "Clear InnoDB logs and restart MySQL in normal mode"
7575
block:
@@ -78,11 +78,11 @@
7878

7979
- name: "Copy my.cnf global MySQL configuration."
8080
template:
81-
src: "my.cnf.j2"
81+
src: my.cnf.j2
8282
dest: "{{ mysql_config_file }}"
83-
mode: "0644"
84-
owner: "root"
85-
group: "root"
83+
mode: 0644
84+
owner: root
85+
group: root
8686

8787
- name: "Start mysql"
8888
service:
@@ -92,7 +92,7 @@
9292

9393
- name: "Remove file reset.sql"
9494
file:
95-
path: "/tmp/reset.sql"
95+
path: /tmp/reset.sql
9696
state: absent
9797

9898
- name: "Wait for service to be ready"
@@ -106,7 +106,7 @@
106106
- name: "Ensure default user is present."
107107
mysql_user:
108108
name: "{{ mysql_user_name }}"
109-
host: "localhost"
109+
host: localhost
110110
password: "{{ mysql_user_password }}"
111111
priv: "*.*:ALL,GRANT"
112112
state: present
@@ -117,15 +117,15 @@
117117
- name: "Copy .my.cnf file with password credentials."
118118
become: True
119119
template:
120-
src: "user-my.cnf.j2"
120+
src: user-my.cnf.j2
121121
dest: "{{ mysql_user_home }}/.my.cnf"
122122
owner: "{{ mysql_user_name }}"
123-
mode: "0600"
123+
mode: 0600
124124
when: mysql_user_name != mysql_root_username
125125

126126
- name: "Update mysql root password for all root accounts"
127127
mysql_user:
128-
name: "root"
128+
name: root
129129
host_all: True
130130
password: "{{ mysql_root_password }}"
131131
check_implicit_admin: True
@@ -144,7 +144,7 @@
144144

145145
- name: "Remove MySQL test database."
146146
mysql_db:
147-
name: "test"
147+
name: test
148148
state: absent
149149
login_user: "{{ mysql_root_username }}"
150150
login_password: "{{ mysql_root_password }}"

vars/RedHat-7-mariadb.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ mysql_version: "latest"
44
mysql_repo: "http://yum.mariadb.org/10.1/centos7-amd64"
55
mysql_gpgkey: "https://yum.mariadb.org/RPM-GPG-KEY-MariaDB"
66
mysql_packages:
7-
- "mariadb"
87
- "MariaDB-client"
98
- "MariaDB-server"
10-
- "mariadb-libs"
9+
1110
mysql_python_packages:
1211
- "MySQL-python"
1312
- "perl-DBD-MySQL"

0 commit comments

Comments
 (0)