Skip to content

Commit

Permalink
Add ansible parameter to uninstall
Browse files Browse the repository at this point in the history
The new v3.0.4 tag was added, but it was edited after.
This raises an error during an update of existing git folder.
The solution is to add an option to delete existing checkout code.
With this we can deploy with `--tags pakiti -e pakiti_uninstall=true`
and it will delete and checkout again a fresh pakiti.
Resolves #5
  • Loading branch information
igobranco committed Nov 2, 2023
1 parent f8edb9c commit ece70e4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pakiti_install: true
# if role will execute the pakiti software that sends information to the server
pakiti_push: false

# flags to indicate to uninstall
pakiti_uninstall: false

# when we want to have a way to only push, we can skip the cronjob creation on
# the installation process
pakiti_install_cron: true
Expand Down
4 changes: 3 additions & 1 deletion tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
mode: u=rwX,g=rX,o=rX
recurse: true
changed_when: false
when: pakiti_install
tags: pakiti

- name: Checkout the pakiti-client repository
Expand All @@ -32,7 +33,7 @@
force: true
accept_hostkey: true
changed_when: false
when: not ansible_check_mode
when: pakiti_install and not ansible_check_mode
become: true
become_user: "{{ pakiti_user }}"
tags: pakiti
Expand All @@ -45,6 +46,7 @@
group: "{{ pakiti_user }}"
mode: u=rwX,g=rX,o=rX
recurse: true
when: pakiti_install
changed_when: false
tags: pakiti

Expand Down
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
- include_tasks: check-params.yml
tags: pakiti

- include_tasks: uninstall.yml
when: pakiti_uninstall
tags: pakiti

- include_tasks: install.yml
when: pakiti_install
tags: pakiti
Expand Down
7 changes: 7 additions & 0 deletions tasks/uninstall.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Delete previous pakiti folder
file:
path: "{{ pakiti_client_path }}"
state: absent
when: pakiti_uninstall
tags: pakiti

0 comments on commit ece70e4

Please sign in to comment.