/
keepalived_install.yml
113 lines (103 loc) · 3.17 KB
/
keepalived_install.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
# Copyright 2015, Jean-Philippe Evrard <jean-philippe@evrard.me>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Add the keepalived through ppa
apt_key:
id: "{{ keepalived_ppa_keyid }}"
keyserver: "{{ keepalived_ppa_keyserver }}"
state: present
when:
- ansible_pkg_mgr == 'apt'
- keepalived_ubuntu_src == "ppa"
tags:
- keepalived-apt-keys
- name: Add Ubuntu Cloud Archive keyring
apt:
pkg: ubuntu-cloud-keyring
state: "{{ keepalived_package_state }}"
when:
- ansible_pkg_mgr == 'apt'
- keepalived_ubuntu_src == "uca"
tags:
- keepalived-apt-keys
- name: Add the keepalived apt repository
apt_repository:
repo: "{{ (keepalived_ubuntu_src == 'ppa') | ternary(keepalived_ppa_repo, keepalived_uca_repo) }}"
update_cache: True
state: present
when:
- ansible_pkg_mgr == 'apt'
- keepalived_ubuntu_src != "native"
tags:
- keepalived-repo
- name: Check if keepalived is already installed
package:
name: "{{ keepalived_package_name }}"
state: present
register: check_if_present
check_mode: yes
- name: Prevent keepalived from starting on install (upstart)
copy:
dest: "{{ prevent_start_file }}"
content: "{{ prevent_start_file_content }}"
when:
- ansible_os_family | lower == 'debian'
- check_if_present | changed
- ansible_service_mgr is defined
- ansible_service_mgr != 'systemd'
tags:
- keepalived-prevent-start
- name: Prevent keepalived from starting on install (systemd)
file:
state: link
src: "/dev/null"
dest: "{{ prevent_start_file }}"
when:
- ansible_os_family | lower == 'debian'
- check_if_present | changed
- ansible_service_mgr is defined
- ansible_service_mgr == 'systemd'
tags:
- keepalived-prevent-start
- name: install keepalived
package:
name: "{{ keepalived_package_name }}"
state: "{{ keepalived_package_state }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
tags:
- keepalived-apt-packages
- name: Ensure no new "samples" folder appeared
file:
path: /etc/keepalived/samples/
state: absent
when:
- ansible_os_family | lower == 'debian'
- name: Revert keepalived start prevention
file:
dest: "{{ prevent_start_file }}"
state: absent
when:
- ansible_os_family | lower == 'debian'
- check_if_present | changed
tags:
- keepalived-prevent-start
- name: "Systemd daemon_reload"
command: systemctl daemon-reload
changed_when: check_if_present | changed
when:
- ansible_service_mgr is defined
- ansible_service_mgr == 'systemd'
tags:
- skip_ansible_lint