Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
ansible enhancements (#18)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio Nemirowski <[email protected]>
  • Loading branch information
sergio authored Mar 18, 2022
1 parent 6df9700 commit e89a6d4
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 65 deletions.
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

- name: Restart neofs-ir instance service
- name: Restart NeoFS IR service
ansible.builtin.systemd:
name: "neofs-ir{{ neofs_ir__instance }}.service"
state: 'restarted'
Expand Down
12 changes: 12 additions & 0 deletions tasks/binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: Download NeoFS IR binary
ansible.builtin.get_url:
url: "{{ neofs_ir__bin_url }}"
dest: "{{ neofs_ir__bin_path }}"
owner: 'root'
group: 'root'
mode: '0755'
when: not (neofs_ir__use_compose | bool)
notify:
- Restart NeoFS IR service
File renamed without changes.
1 change: 0 additions & 1 deletion tasks/healthcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@
until: _neofs_ir_check_result.rc == 0
retries: 10
delay: 30

73 changes: 14 additions & 59 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
---

# Prepare system
- ansible.builtin.include: 'prepare_user.yml'

- name: Ensure data directory exists
ansible.builtin.file:
state: directory
path: "{{ item }}"
owner: "{{ neofs_ir__user }}"
group: "{{ neofs_ir__group }}"
mode: '0750'
with_items:
- "{{ neofs_ir__data_dir }}"
- ansible.builtin.include_tasks: 'user.yml'

- name: Create configuration directory parent
ansible.builtin.file:
Expand All @@ -33,15 +22,7 @@
with_items:
- "{{ neofs_ir__conf_dir }}"

- name: Ensure there is node wallet
ansible.builtin.copy:
content: "{{ neofs_ir__wallet }}"
dest: "{{ neofs_ir__wallet_path }}"
owner: 'root'
group: "{{ neofs_ir__group }}"
mode: '0660'
notify:
- Restart neofs-ir instance service
- ansible.builtin.include_tasks: 'wallet.yml'

- name: Download locode database archive
ansible.builtin.unarchive:
Expand All @@ -52,42 +33,23 @@
group: "{{ neofs_ir__group }}"
mode: '0644'
notify:
- Restart neofs-ir instance service
- Restart NeoFS IR service

- name: Prepare NeoFS IR config for neofs-ir{{ neofs_ir__instance }}
- name: Copy NeoFS IR config
ansible.builtin.template:
src: 'config.yaml.j2'
dest: "{{ neofs_ir__conf_dir }}/config.yaml"
owner: 'root'
group: "{{ neofs_ir__group }}"
mode: '0640'
notify:
- Restart neofs-ir instance service
- Restart NeoFS IR service

- name: Download neofs-ir binary
ansible.builtin.get_url:
url: "{{ neofs_ir__bin_url }}"
dest: "{{ neofs_ir__bin_path }}"
owner: 'root'
group: 'root'
mode: '0755'
when: not (neofs_ir__use_compose | bool)
notify:
- Restart neofs-ir instance service

- include: download_cli.yml
- ansible.builtin.include_tasks: 'binary.yml'

- name: Get uid for neofs-ir user
ansible.builtin.getent:
database: passwd
key: "{{ neofs_ir__user }}"
- ansible.builtin.include_tasks: 'cli.yml'

- name: Get gid for neofs-ir user
ansible.builtin.getent:
database: group
key: "{{ neofs_ir__group }}"

- name: Prepare docker-compose for neofs-ir{{ neofs_ir__instance }}
- name: Copy compose file
ansible.builtin.template:
src: 'docker-compose.yml.j2'
dest: "{{ neofs_ir__conf_dir }}/docker-compose.yml"
Expand All @@ -96,35 +58,28 @@
mode: '0640'
when: neofs_ir__use_compose | bool
notify:
- Restart neofs-ir instance service
- Restart NeoFS IR service

- name: Copy regular systemd unit file
- name: Copy regular systemd unit
ansible.builtin.template:
src: "neofs-ir.service.bin.j2"
dest: "/etc/systemd/system/neofs-ir{{ neofs_ir__instance }}.service"
when: not (neofs_ir__use_compose | bool)
notify:
- Restart neofs-ir instance service
- Restart NeoFS IR service

- name: Copy Docker systemd unit file
- name: Copy dockerized systemd unit
ansible.builtin.template:
src: "neofs-ir.service.compose.j2"
dest: "/etc/systemd/system/neofs-ir{{ neofs_ir__instance }}.service"
when: neofs_ir__use_compose | bool
notify:
- Restart neofs-ir instance service

- name: Ensure NeoFS IR{{ neofs_ir__instance }} service runs
ansible.builtin.systemd:
name: "neofs-ir{{ neofs_ir__instance }}.service"
state: 'started'
enabled: yes
daemon_reload: yes
- Restart NeoFS IR service

- include: healthcheck.yml

- name: Force debops.ferm run
include_role:
ansible.builtin.include_role:
name: debops.debops.ferm
vars:
ferm__dependent_rules:
Expand Down
8 changes: 4 additions & 4 deletions tasks/prepare_user.yml → tasks/user.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---

- name: Ensure there is neofs-ir group
- name: Create NeoFS IR group
ansible.builtin.group:
name: "{{ neofs_ir__group }}"
system: yes
state: 'present'

- name: Ensure there is neofs-ir user
- name: Create NeoFS IR user
ansible.builtin.user:
name: "{{ neofs_ir__user }}"
group: "{{ neofs_ir__group }}"
Expand All @@ -17,12 +17,12 @@
skeleton: no
state: 'present'

- name: Get uid for neofs-ir user
- name: Get UID for NeoFS IR user
ansible.builtin.getent:
database: passwd
key: "{{ neofs_ir__user }}"

- name: Get gid for neofs-ir user
- name: Get GID for NeoFS IR user
ansible.builtin.getent:
database: group
key: "{{ neofs_ir__group }}"
11 changes: 11 additions & 0 deletions tasks/wallet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

- name: Copy wallet
ansible.builtin.copy:
content: "{{ neofs_ir__wallet }}"
dest: "{{ neofs_ir__wallet_path }}"
owner: 'root'
group: "{{ neofs_ir__group }}"
mode: '0660'
notify:
- Restart NeoFS IR service

0 comments on commit e89a6d4

Please sign in to comment.