Skip to content

Commit a44e415

Browse files
mpsOxygenRavzan Valceanu
andauthored
Fix a couple of ansible-lint errors (#126)
* capitalize task names to pass ansible-lint Signed-off-by: Ravzan Valceanu <[email protected]> * Truthy value should be one of \[false, true]ansible-lint Signed-off-by: Ravzan Valceanu <[email protected]> * All tasks should be named.ansible-lint Signed-off-by: Ravzan Valceanu <[email protected]> * Use FQCN for builtin module actions - ansible-lint Use FQCN for module actions, such `ansible.posix.sysctl`. - ansible-lint Use FQCN for module actions, such `ansible.posix.selinux`. - ansible-lint Deprecated module. include - ansible-lint You can improve the task key order to: name, when, block - ansible-lint Signed-off-by: Ravzan Valceanu <[email protected]> * resolve conflict with main use wait_for module instead of pause Signed-off-by: Ravzan Valceanu <[email protected]> * add "" to variables in task Wait for opensearch to startup Signed-off-by: Ravzan Valceanu <[email protected]> * fix ansible lint inline vs yaml Signed-off-by: Ravzan Valceanu <[email protected]> --------- Signed-off-by: Ravzan Valceanu <[email protected]> Co-authored-by: Ravzan Valceanu <[email protected]>
1 parent d986a76 commit a44e415

File tree

12 files changed

+116
-103
lines changed

12 files changed

+116
-103
lines changed

opensearch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22

3-
- name: opensearch installation & configuration
3+
- name: Opensearch installation & configuration
44
hosts: os-cluster
55
gather_facts: true
66
roles:
77
- { role: linux/opensearch }
88

9-
- name: opensearch dashboards installation & configuration
9+
- name: Opensearch dashboards installation & configuration
1010
hosts: dashboards
1111
gather_facts: true
1212
roles:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
---
22
- name: restart dashboards
3-
systemd: name=dashboards state=restarted enabled=yes
3+
ansible.builtin.systemd: name=dashboards state=restarted enabled=true
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22

33
- name: Dashboards Install | Download opensearch dashbaord {{ os_dashboards_version }}
4-
get_url:
4+
ansible.builtin.get_url:
55
url: "{{ os_download_url }}-dashboards/{{ os_dashboards_version }}/opensearch-dashboards-{{ os_dashboards_version }}-linux-x64.tar.gz"
66
dest: "/tmp/opensearch-dashboards.tar.gz"
77
register: download
88

99
- name: Dashboards Install | Create opensearch dashboard user
10-
user:
10+
ansible.builtin.user:
1111
name: "{{ os_dashboards_user }}"
1212
state: present
1313
shell: /bin/false
@@ -16,41 +16,41 @@
1616
when: download.changed or iac_enable
1717

1818
- name: Dashboards Install | Create home directory
19-
file:
19+
ansible.builtin.file:
2020
path: "{{ os_dashboards_home }}"
2121
state: directory
2222
owner: "{{ os_dashboards_user }}"
2323
group: "{{ os_dashboards_user }}"
2424
when: download.changed or iac_enable
2525

2626
- name: Dashboards Install | Extract the tar file
27-
command: chdir=/tmp/ tar -xvzf opensearch-dashboards.tar.gz -C "{{ os_dashboards_home }}" --strip-components=1
27+
ansible.builtin.command: chdir=/tmp/ tar -xvzf opensearch-dashboards.tar.gz -C "{{ os_dashboards_home }}" --strip-components=1
2828
when: download.changed or iac_enable
2929

3030
- name: Dashboards Install | Copy Configuration File
31-
template:
31+
ansible.builtin.template:
3232
src: opensearch_dashboards.yml
33-
dest: "{{os_conf_dir}}/opensearch_dashboards.yml"
33+
dest: "{{ os_conf_dir }}/opensearch_dashboards.yml"
3434
owner: "{{ os_dashboards_user }}"
3535
group: "{{ os_dashboards_user }}"
3636
mode: 0644
37-
backup: yes
37+
backup: true
3838

3939
- name: Dashboards Install | Set the file ownerships
40-
file:
40+
ansible.builtin.file:
4141
dest: "{{ os_dashboards_home }}"
4242
owner: "{{ os_dashboards_user }}"
4343
group: "{{ os_dashboards_user }}"
44-
recurse: yes
44+
recurse: true
4545

4646
- name: Dashboards Install | Set the folder permission
47-
file:
47+
ansible.builtin.file:
4848
dest: "{{ os_conf_dir }}"
4949
owner: "{{ os_dashboards_user }}"
5050
group: "{{ os_dashboards_user }}"
5151
mode: 0700
5252

5353
- name: Dashboards Install | create systemd service
54-
template:
54+
ansible.builtin.template:
5555
src: dashboards.service
5656
dest: "{{ systemctl_path }}/dashboards.service"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
- name: Hosts | populate inventory into hosts file
3-
blockinfile:
3+
ansible.builtin.blockinfile:
44
dest: /etc/hosts
55
block: |-
66
{% for item in groups['dashboards'] %}
77
{{ hostvars[item]['ip'] }} {{ item }}.{{ domain_name }} {{ item }}
88
{% endfor %}
99
state: present
10-
create: yes
11-
backup: yes
10+
create: true
11+
backup: true
1212
marker: "# Ansible inventory hosts {mark}"
1313
when: populate_inventory_to_hosts_file

roles/linux/dashboards/tasks/main.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
---
22

3-
- hostname:
3+
- name: Set hostname
4+
ansible.builtin.hostname:
45
name: "{{ inventory_hostname }}"
56

67
# Disabling for Amazon Linux 2 as selinux is disabled by default.
78
- name: Disable the selinux
8-
selinux:
9+
ansible.posix.selinux:
910
state: disabled
1011
when: (ansible_distribution != "Ubuntu") and (ansible_distribution != "Amazon")
1112

1213
- name: Populate the nodes to /etc/hosts
13-
import_tasks: etchosts.yml
14+
ansible.builtin.import_tasks: etchosts.yml
1415

1516
- name: Tune the system settings
16-
import_tasks: tune.yml
17+
ansible.builtin.import_tasks: tune.yml
1718

18-
- name: include dashboards installation
19-
include: dashboards.yml
19+
- name: Include dashboards installation
20+
ansible.builtin.import_tasks: dashboards.yml
2021

2122
- name: Make sure opensearch dashboards is started
22-
service:
23+
ansible.builtin.service:
2324
name: dashboards
2425
state: started
25-
enabled: yes
26+
enabled: true
2627

2728
- name: Get all the installed dashboards plugins
28-
command: "sudo -u {{ os_dashboards_user }} {{ os_plugin_bin_path }} list"
29+
ansible.builtin.command: "sudo -u {{ os_dashboards_user }} {{ os_plugin_bin_path }} list"
2930
register: list_plugins
3031

3132
- name: Show all the installed dashboards plugins
32-
debug:
33+
ansible.builtin.debug:
3334
msg: "{{ list_plugins.stdout }}"

roles/linux/dashboards/tasks/tune.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Set open files limit in sysctl.conf
3-
sysctl:
3+
ansible.posix.sysctl:
44
name: fs.file-max
55
value: 65536
66
state: present
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
# handlers file for opensearch
33
- name: reload systemd configuration
4-
become: yes
5-
command: systemctl daemon-reload
4+
become: true
5+
ansible.builtin.command: systemctl daemon-reload
66

77
# Restart service and ensure it is enabled
88

99
- name: restart opensearch
10-
systemd: name=opensearch state=restarted enabled=yes
10+
ansible.builtin.systemd: name=opensearch state=restarted enabled=yes
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
- name: Hosts | populate inventory into hosts file
3-
blockinfile:
3+
ansible.builtin.blockinfile:
44
dest: /etc/hosts
55
block: |-
66
{% for item in groups['os-cluster'] %}
77
{{ hostvars[item]['ip'] }} {{ item }}.{{ domain_name }} {{ item }}
88
{% endfor %}
99
state: present
10-
create: yes
11-
backup: yes
10+
create: true
11+
backup: true
1212
marker: "# Ansible inventory hosts {mark}"
1313
when: populate_inventory_to_hosts_file

roles/linux/opensearch/tasks/main.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,53 @@
11
---
22

3-
- hostname:
3+
- name: Set hostname
4+
ansible.builtin.hostname:
45
name: "{{ inventory_hostname }}"
56

67
# Disabling for Amazon Linux 2 as selinux is disabled by default.
78
- name: Disable the selinux
8-
selinux:
9+
ansible.posix.selinux:
910
state: disabled
1011
when: (ansible_distribution != "Ubuntu") and (ansible_distribution != "Amazon")
1112

1213
- name: Populate the nodes to /etc/hosts
13-
import_tasks: etchosts.yml
14+
ansible.builtin.import_tasks: etchosts.yml
1415

1516
- name: Tune the system settings
16-
import_tasks: tune.yml
17+
ansible.builtin.import_tasks: tune.yml
1718

18-
- name: include opensearch installation
19-
include: opensearch.yml
19+
- name: Include opensearch installation
20+
ansible.builtin.import_tasks: opensearch.yml
2021

21-
- name: include security plugin for opensearch
22-
include: security.yml
22+
- name: Include security plugin for opensearch
23+
ansible.builtin.import_tasks: security.yml
2324

2425
# After the cluster forms successfully for the first time,
2526
# remove the cluster.initial_master_nodes setting from each nodes' configuration.
2627
- name: Remove `cluster.initial_master_nodes` setting from configuration
27-
command: sed -i '/cluster.initial_master_nodes/d' "{{os_conf_dir}}/opensearch.yml"
28+
ansible.builtin.command: sed -i '/cluster.initial_master_nodes/d' "{{ os_conf_dir }}/opensearch.yml"
2829

2930
- name: Make sure opensearch is started
30-
service:
31+
ansible.builtin.service:
3132
name: opensearch
3233
state: started
33-
enabled: yes
34+
enabled: true
3435

3536
- name: Get all the installed ES plugins
36-
command: "{{ os_plugin_bin_path }} list"
37+
ansible.builtin.command: "{{ os_plugin_bin_path }} list"
3738
register: list_plugins
3839

3940
- name: Show all the installed ES plugins
40-
debug:
41+
ansible.builtin.debug:
4142
msg: "{{ list_plugins.stdout }}"
4243

4344
- name: Wait for opensearch to startup
44-
wait_for: host={{ hostvars[inventory_hostname]['ip'] }} port={{os_api_port}} delay=5 connect_timeout=1
45+
ansible.builtin.wait_for:
46+
host: "{{ hostvars[inventory_hostname]['ip'] }}"
47+
port: "{{ os_api_port }}"
48+
delay: 5
49+
connect_timeout: 1
50+
timeout: 120
4551

4652
- name: Check the opensearch status
4753
ansible.builtin.uri:
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22

33
- name: OpenSearch Install | Download opensearch {{ os_version }}
4-
get_url:
4+
ansible.builtin.get_url:
55
url: "{{ os_download_url }}/{{ os_version }}/opensearch-{{ os_version }}-linux-x64.tar.gz"
66
dest: "/tmp/opensearch.tar.gz"
77
register: download
88

99
- name: OpenSearch Install | Create opensearch user
10-
user:
10+
ansible.builtin.user:
1111
name: "{{ os_user }}"
1212
state: present
1313
shell: /bin/false
@@ -16,39 +16,39 @@
1616
when: download.changed or iac_enable
1717

1818
- name: OpenSearch Install | Create home directory
19-
file:
19+
ansible.builtin.file:
2020
path: "{{ os_home }}"
2121
state: directory
2222
owner: "{{ os_user }}"
2323
group: "{{ os_user }}"
2424
when: download.changed or iac_enable
2525

2626
- name: OpenSearch Install | Extract the tar file
27-
command: chdir=/tmp/ tar -xvzf opensearch.tar.gz -C "{{ os_home }}" --strip-components=1
27+
ansible.builtin.command: chdir=/tmp/ tar -xvzf opensearch.tar.gz -C "{{ os_home }}" --strip-components=1
2828
when: download.changed or iac_enable
2929

3030
- name: OpenSearch Install | Copy Configuration File
31-
blockinfile:
31+
ansible.builtin.blockinfile:
3232
block: "{{ lookup('template', 'templates/opensearch-{{ cluster_type }}.yml') }}"
3333
dest: "{{ os_conf_dir }}/opensearch.yml"
34-
backup: yes
34+
backup: true
3535
state: present
36-
create: yes
36+
create: true
3737
marker: "## {mark} opensearch main configuration ##"
3838
owner: "{{ os_user }}"
3939
group: "{{ os_user }}"
4040
mode: 0600
4141

4242
- name: OpenSearch Install | Copy jvm.options File for Instance
43-
template:
43+
ansible.builtin.template:
4444
src: jvm.options
45-
dest: "{{os_conf_dir}}/jvm.options"
45+
dest: "{{ os_conf_dir }}/jvm.options"
4646
owner: "{{ os_user }}"
4747
group: "{{ os_user }}"
4848
mode: 0600
49-
force: yes
49+
force: true
5050

5151
- name: OpenSearch Install | create systemd service
52-
template:
52+
ansible.builtin.template:
5353
src: opensearch.service
5454
dest: "{{ systemctl_path }}/opensearch.service"

0 commit comments

Comments
 (0)