Skip to content

Commit

Permalink
add update
Browse files Browse the repository at this point in the history
  • Loading branch information
molecule committed May 9, 2024
1 parent f63fc13 commit f60a97f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 30 deletions.
12 changes: 12 additions & 0 deletions roles/setup/tasks/check_installed_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- name: Check if receptor is installed correctly
ansible.builtin.command: "receptor --version"
changed_when: false
register: receptor_version
ignore_errors: true

- name: Assert receptor installation
ansible.builtin.assert:
that:
- receptor_version.rc == 0
fail_msg: "Receptor not installed correctly. Please check the installation or reinstall it with local_receptor: true"
success_msg: "Receptor installed correctly"

Check failure on line 12 in roles/setup/tasks/check_installed_version.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[new-line-at-end-of-file]

No new line character at the end of file
47 changes: 20 additions & 27 deletions roles/setup/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Run preflight
ansible.builtin.include_tasks: preflight.yml
ansible.builtin.include_tasks: preflight.yml

Check failure on line 3 in roles/setup/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[trailing-spaces]

Trailing spaces

# Variable configuration.
- name: Include variables
Expand All @@ -15,7 +15,7 @@
ansible.builtin.set_fact:
additional_python_packages: "{{ additional_python_packages + ['receptorctl'] }}"
when:
- receptor_install_method in ['release', 'local']
- receptor_install_method in ['release', 'local'] or "'update' in receptor_install_method"
- "'receptorctl' not in additional_python_packages"

- name: Install python packages
Expand All @@ -24,38 +24,31 @@

- name: Receptor install local
ansible.builtin.include_tasks: setup-local.yml
when: receptor_install_method == 'local'
when: receptor_install_method in ['local', 'update-local']

- name: Receptor install release
ansible.builtin.include_tasks: setup-release.yml
when: receptor_install_method == 'release'
when: receptor_install_method == ['release', 'update-release']

- name: Check if receptor was installed correctly
ansible.builtin.command: "receptor --version"
changed_when: false
register: receptor_version
ignore_errors: true
- name: Receptor check installation
ansible.builtin.include_tasks: check_installed_version.yml

- name: Assert receptor installation
ansible.builtin.assert:
that:
- receptor_version.rc == 0
fail_msg: "Receptor not installed correctly. Please check the installation or reinstall it with local_receptor: true"
success_msg: "Receptor installed correctly"
- name: Configuration tasks during fisrt installation
when: not ('update' in receptor_install_method)
block:
- name: Configure receptor socket
ansible.builtin.include_tasks: configure.yml

- name: Configure receptor socket
ansible.builtin.include_tasks: configure.yml
- name: TLS files
ansible.builtin.include_tasks: tls.yml
when: receptor_tls

- name: TLS files
ansible.builtin.include_tasks: tls.yml
when: receptor_tls
- name: Work signing
ansible.builtin.include_tasks: worksign.yml
when: receptor_sign or receptor_verify

- name: Work signing
ansible.builtin.include_tasks: worksign.yml
when: receptor_sign or receptor_verify

- name: Generate receptor config
ansible.builtin.include_tasks: generate_config.yml
- name: Generate receptor config
ansible.builtin.include_tasks: generate_config.yml

- name: Setup systemd
ansible.builtin.include_tasks: setup-service.yml
Expand All @@ -64,7 +57,7 @@
- name: Start Receptor service
ansible.builtin.systemd:
name: "{{ receptor_service_name }}"
state: started
state: "{{ 'restarted' if 'update' in receptor_install_method else 'started' }}"

Check failure on line 60 in roles/setup/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[trailing-spaces]

Trailing spaces
daemon_reload: true
enabled: true
register: _started
6 changes: 5 additions & 1 deletion roles/setup/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
- name: Check local binary file is set
ansible.builtin.assert:
that: receptor_local_bin_file | length
when: receptor_install_method == 'local'
when: ['local', 'update-local']

Check failure on line 5 in roles/setup/tasks/preflight.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[colons]

Too many spaces after colon

- name: Receptor check installation
ansible.builtin.include_tasks: check_installed_version.yml
when: "'update' in receptor_install_method"
1 change: 1 addition & 0 deletions roles/setup/tasks/python_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- name: Install additional python packages
ansible.builtin.pip:
name: "{{ additional_python_packages | default([]) }}"
state: "{{ 'latest' if 'update' in receptor_install_method else 'present' }}"

Check failure on line 21 in roles/setup/tasks/python_packages.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[trailing-spaces]

Trailing spaces
executable: "{{ pip_executable }}"

- name: Symlink receptorctl to /usr/bin
Expand Down
2 changes: 1 addition & 1 deletion roles/setup/tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
- name: Install dependencies specific to the node type
ansible.builtin.apt:
name: "{{ additional_system_packages | default([]) }}"
state: present
state: "{{ 'latest' if 'update' in receptor_install_method else 'present' }}"
2 changes: 1 addition & 1 deletion roles/setup/tasks/setup-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Install receptor packages
ansible.builtin.dnf:
name: "{{ receptor_packages }}"
state: present
state: "{{ 'latest' if 'update' in receptor_install_method else 'present' }}"
when:
- receptor_install_method == 'package'
- receptor_packages
Expand Down

0 comments on commit f60a97f

Please sign in to comment.