-
Notifications
You must be signed in to change notification settings - Fork 22
/
sample-playbook.yml
executable file
·67 lines (58 loc) · 1.87 KB
/
sample-playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
# Sample Playbook to install MySQL & use "mysql_secure_installation" Ansible Module
- name: Install & Secure MySQL
hosts: localhost
user: vagrant
become: true
vars:
RedHat_Packages:
- gcc
- mysql-devel # Alternative (NOT Tested) -- yum install mariadb-devel
- mariadb-server
- mariadb
RedHat_8_Extra_Packages:
- python3-pip
- python3-devel
Ubuntu_Packages:
- mariadb-server
- python-dev
#- libmysqlclient-dev
- gcc
Ubuntu_20_Extra_Packages:
- python3-pip
- python3-dev
Mariadb_Service: "{{ 'mariadb' if ansible_os_family == 'RedHat' else 'mysql'}}"
tasks:
- name: Update apt packages
become: true
apt:
upgrade: no
update_cache: yes
cache_valid_time: 86400 #One day
when: ansible_os_family == 'Debian' #and ansible_distribution_major_version == '20'
- name: Install Mariadb and its Dependencies On Ubuntu or Centos
package:
name: "{{ RedHat_Packages if ansible_os_family == 'RedHat' else Ubuntu_Packages }}"
state: present
- name: Start Mysql Service
service:
name: "{{ Mariadb_Service }}"
state: started
enabled: true
- import_tasks: mysql-python_dependencies.yml
- name: use "mysql_secure_installation" for Fresh MySQL Installation
mysql_secure_installation:
login_password: ''
new_password: 'password22'
user: root
login_host: localhost
hosts: ['localhost', '127.0.0.1', '::1']
change_root_password: true
remove_anonymous_user: true
disallow_root_login_remotely: true
remove_test_db: true
register: secure
- debug:
var: secure
# Used for testing.
- local_action: copy content={{secure}} dest=output.txt