Skip to content

Commit

Permalink
Use version file to make clatd install idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOrangeOne committed Sep 5, 2024
1 parent 45d3e3e commit a544b9d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions roles/clatd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,36 @@
dest: "{{ install_dir }}"
force: true
version: 3ea303b5210bf701df30323933c86f9ffe4d3dd4
notify: Restart clatd
register: clatd_repo
notify: Restart clatd

- name: Get installed version (if installed)
slurp:
src: "{{ installed_version_file }}"
ignore_errors: true # Ignore if the file is missing, since it's about to be created
register: installed_version_slurp

- name: Resolve installed version
set_fact:
installed_version: "{{ installed_version_slurp.content | b64decode }}"
when: not installed_version_slurp.failed

- name: Install
community.general.make:
chdir: "{{ install_dir }}"
targets:
- installdeps # Install system dependencies
- install # Install clatd
when: clatd_repo.changed # noqa: no-handler - Use a handler to ensure execution order
when: installed_version is not defined or clatd_repo.after not in installed_version # noqa: no-handler - Use a handler to ensure execution order
notify: Restart clatd
register: install_clatd

- name: Update installed version
copy:
content: "{{ clatd_repo.after }}"
dest: "{{ installed_version_file }}"
mode: "0644"
when: install_clatd.changed # noqa: no-handler - Use a handler to ensure execution order

- name: Install configuration
copy:
Expand Down
1 change: 1 addition & 0 deletions roles/clatd/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
install_dir: /opt/clatd
installed_version_file: /opt/clatd.version

0 comments on commit a544b9d

Please sign in to comment.