6
6
state=present
7
7
update_cache=yes
8
8
cache_valid_time={{apt_cache_valid_time}}
9
+ when : ansible_distribution == "Ubuntu"
9
10
10
11
- name : elastic-install | Install dependencies
11
- apt :
12
- pkg={{ item }}
13
- state=present
14
- with_items : elasticsearch_apt_dependencies
12
+ action : >
13
+ {{ ansible_pkg_mgr }}
14
+ name={{ item }}
15
+ state=present
16
+ with_items : " {{ elasticsearch_pkg_dependencies }}"
15
17
16
18
- name : elastic-install | Configuring elastic group
17
19
group :
45
47
46
48
- name : elastic-install | Download Elasticsearch deb
47
49
get_url :
48
- url={{ elasticsearch_download_url }}/elasticsearch-{{ elasticsearch_version }}.deb
49
- dest=/tmp/elasticsearch-{{ elasticsearch_version }}.deb
50
+ url={{ elasticsearch_ubuntu_download_url }}
51
+ dest=/tmp/
50
52
mode=0440
51
- when : not installed_version.stat.exists
53
+ register : downloaded_pkg
54
+ when : not installed_version.stat.exists and
55
+ ansible_distribution == "Ubuntu"
56
+
57
+ - name : elastic-install | Download Elasticsearch rpm
58
+ get_url :
59
+ url={{ elasticsearch_centos7_download_url }}
60
+ dest=/tmp/
61
+ mode=0440
62
+ register : downloaded_pkg
63
+ when : not installed_version.stat.exists and
64
+ ansible_distribution == "CentOS" and
65
+ ansible_distribution_major_version == "7"
52
66
53
- # shell: dpkg --remove elasticsearch
54
67
- name : elastic-install | Uninstalling previous version if applicable
55
- apt :
68
+ action : >
69
+ {{ ansible_pkg_mgr }}
56
70
name="elasticsearch"
57
71
state="absent"
58
72
when : not installed_version.stat.exists
63
77
state=absent
64
78
when : not installed_version.stat.exists
65
79
66
- - name : elastic-install | Install Elasticsearch deb
67
- shell : dpkg -i -E --force-confnew /tmp/elasticsearch-{{ elasticsearch_version }}.deb
68
- when : not installed_version.stat.exists
80
+ - name : elastic-install | Ubuntu | Install Elasticsearch deb
81
+ shell : dpkg -i -E --force-confnew {{ downloaded_pkg.dest }}
82
+ when : not installed_version.stat.exists and
83
+ ansible_distribution == "Ubuntu"
84
+ notify : Restart Elasticsearch
85
+
86
+ - name : elastic-install | CentOS-7 | Install Elasticsearch rpm
87
+ shell : rpm -i {{ downloaded_pkg.dest }}
88
+ when : not installed_version.stat.exists and
89
+ ansible_distribution == "CentOS" and
90
+ ansible_distribution_major_version == "7"
69
91
notify : Restart Elasticsearch
70
92
71
93
- name : elastic-install | Ensure elastic directories exists
83
105
- " {{ elasticsearch_work_dir }}"
84
106
- " {{ elasticsearch_conf_dir }}"
85
107
86
- - name : Configure limits max_open_files
108
+ - name : elastic-install | Configure limits max_open_files
87
109
lineinfile :
88
110
dest=/etc/security/limits.conf
89
111
regexp='^{{ elasticsearch_user }} - nofile {{ elasticsearch_max_open_files }}'
116
138
insertafter=EOF
117
139
line='session required pam_limits.so'
118
140
notify : Restart Elasticsearch
141
+ when : ansible_distribution == "Ubuntu"
119
142
120
143
- name : elastic-install | Configure common-session-noninteractive pam_limits.so
121
144
lineinfile :
124
147
insertafter=EOF
125
148
line='session required pam_limits.so'
126
149
notify : Restart Elasticsearch
150
+ when : ansible_distribution == "Ubuntu"
151
+
152
+ - name : elastic-install | Configure system-auth pam_limits.so
153
+ lineinfile :
154
+ dest=/etc/pam.d/system-auth
155
+ regexp='^session required pam_limits.so'
156
+ insertafter=EOF
157
+ line='session required pam_limits.so'
158
+ notify : Restart Elasticsearch
159
+ when : ansible_distribution == "CentOS" and
160
+ ansible_distribution_major_version == "7"
127
161
128
162
- name : elastic-install | Configure sudo pam_limits.so
129
163
lineinfile :
158
192
owner={{ elasticsearch_user }}
159
193
group={{ elasticsearch_group }}
160
194
mode=0644
161
- notify : Restart Elasticsearch
195
+ notify : Restart Elasticsearch
0 commit comments