Skip to content

Commit f52d3d4

Browse files
committed
Split setup tasks into distro-specific files and update apt_cache for first run.
1 parent d098cd9 commit f52d3d4

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

tasks/main.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@
99
enablerepo={{ mysql_enablerepo }}
1010
when: mysql_enablerepo != ""
1111

12-
- name: Ensure MySQL packages are installed (RedHat).
13-
yum: >
14-
name={{ item }}
15-
state=installed
16-
enablerepo={{ mysql_enablerepo }}
17-
with_items: mysql_packages
12+
- include: setup-RedHat.yml
1813
when: ansible_os_family == 'RedHat'
1914

20-
- name: Ensure MySQL packages are installed (Debian).
21-
apt: >
22-
name={{ item }}
23-
state=installed
24-
with_items: mysql_packages
15+
- include: setup-Debian.yml
2516
when: ansible_os_family == 'Debian'
2617

2718
- name: Copy my.cnf global MySQL configuration.

tasks/setup-Debian.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- name: Check if MySQL is already installed.
3+
stat: path=/etc/init.d/mysql
4+
register: mysql_installed
5+
6+
- name: Update apt cache if MySQL is not yet installed.
7+
apt: update_cache=yes
8+
when: mysql_installed.stat.exists == false
9+
10+
- name: Ensure MySQL packages are installed.
11+
apt: >
12+
name={{ item }}
13+
state=installed
14+
with_items: mysql_packages

tasks/setup-RedHat.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Ensure MySQL packages are installed.
3+
yum: >
4+
name={{ item }}
5+
state=installed
6+
enablerepo={{ mysql_enablerepo }}
7+
with_items: mysql_packages

0 commit comments

Comments
 (0)