Skip to content

Commit eaad305

Browse files
committed
Split distribution dependent tasks
1 parent a0a4b4c commit eaad305

File tree

4 files changed

+49
-46
lines changed

4 files changed

+49
-46
lines changed

tasks/install.yml

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,15 @@
66
- "{{ ansible_os_family }}.yml"
77
- default.yml
88

9-
- name: 'Check epel repo'
10-
shell: yum repolist | grep -qi EPEL
11-
register: epel_repo_check
12-
check_mode: false
13-
when: ansible_pkg_mgr == "yum"
14-
15-
- name: 'Add epel repo'
16-
template:
17-
src: "epel.repo"
18-
dest: "/etc/yum.repos.d/epel.repo"
19-
owner: "root"
20-
group: "root"
21-
mode: "0644"
22-
when: ansible_pkg_mgr == "yum" and epel_repo_check is defined and epel_repo_check.rc != 0
23-
24-
- name: Add haproxy apt repo (jessie)
25-
apt_repository:
26-
repo: deb http://http.debian.net/debian {{ ansible_distribution_release }} main
27-
state: present
28-
update_cache: yes
29-
when: ansible_distribution_release == 'jessie'
30-
31-
- name: 'Add haproxy apt repo (Ubuntu)'
32-
apt_repository:
33-
repo: "ppa:vbernat/haproxy-1.5"
34-
state: present
35-
update_cache: yes
36-
when: ansible_distribution == "Ubuntu"
37-
38-
- name: Install HAProxy (yum)
39-
yum:
40-
name: "{{ haproxy_package_name }}"
41-
when: ansible_pkg_mgr == "yum"
42-
43-
- name: Install HAProxy (apt jessie)
44-
apt:
45-
name: "{{ haproxy_package_name }}"
46-
default_release: "{{ansible_distribution_release}}"
47-
when: ansible_distribution_release == 'jessie'
48-
49-
- name: Install HAProxy (Ubuntu)
50-
package:
51-
name: "{{ haproxy_package_name }}"
52-
when: ansible_distribution == 'Ubuntu'
9+
- name: Include distribution tasks
10+
include_tasks: "{{ item }}"
11+
with_first_found:
12+
- "install/{{ ansible_distribution }}.yml"
13+
- "install/{{ ansible_os_family }}.yml"
5314

5415
- name: Install supplementary packages
5516
package:
56-
name: "{{ item }}"
57-
with_items: "{{ haproxy_extra_packages }}"
17+
name: "{{ haproxy_extra_packages }}"
5818

5919
- name: 'Enable it'
6020
service:

tasks/install/CentOS.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: 'Check epel repo'
3+
shell: yum repolist | grep -qi EPEL
4+
register: epel_repo_check
5+
check_mode: false
6+
7+
- name: 'Add epel repo'
8+
template:
9+
src: "epel.repo"
10+
dest: "/etc/yum.repos.d/epel.repo"
11+
owner: "root"
12+
group: "root"
13+
mode: "0644"
14+
when: epel_repo_check is defined and epel_repo_check.rc != 0
15+
16+
- name: Install HAProxy (yum)
17+
yum:
18+
name: "{{ haproxy_package_name }}"

tasks/install/Debian.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- name: Add haproxy apt repo (jessie)
3+
apt_repository:
4+
repo: "deb http://http.debian.net/debian {{ ansible_distribution_release }} main"
5+
state: present
6+
update_cache: yes
7+
when: ansible_distribution_release == 'jessie'
8+
9+
- name: Install HAProxy (jessie)
10+
apt:
11+
name: "{{ haproxy_package_name }}"
12+
default_release: "{{ ansible_distribution_release }}"
13+
when: ansible_distribution_release == 'jessie'

tasks/install/Ubuntu.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: 'Add haproxy apt repo (Ubuntu)'
3+
apt_repository:
4+
repo: "ppa:vbernat/haproxy-1.5"
5+
state: present
6+
update_cache: yes
7+
when: ansible_distribution == "Ubuntu"
8+
9+
- name: Install HAProxy (Ubuntu)
10+
package:
11+
name: "{{ haproxy_package_name }}"
12+
when: ansible_distribution == 'Ubuntu'

0 commit comments

Comments
 (0)