Skip to content

Commit

Permalink
Merge pull request #84 from N07070/82-better-errors-on-check-mode
Browse files Browse the repository at this point in the history
Add check to run task in check mod & a error message.
  • Loading branch information
DO1JLR authored Jun 21, 2022
2 parents 586d277 + 7603c93 commit 3625ace
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tasks/set_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,24 @@
url: https://api.github.com/repos/go-gitea/gitea/releases/latest
return_content: true
register: gitea_remote_metadata
when: not ansible_check_mode

- name: "Fail if running in check mode without versions set."
ansible.builtin.fail:
msg: |
"You are running this playbook in check mode:
Please set the Gitea version with the variable 'gitea_version', because the URI module cannot detect the latest version in this mode."
when: ansible_check_mode and ( gitea_version == 'latest' or gitea_version == 'present' )

- name: "Set fact latest gitea release"
ansible.builtin.set_fact:
gitea_remote_version: "{{ gitea_remote_metadata.json.tag_name[1:] }}"
when: not ansible_check_mode

- name: "Set gitea version target (latest)"
ansible.builtin.set_fact:
gitea_version_target: "{{ gitea_remote_version }}"
when: not ansible_check_mode
when: gitea_version == "latest"

- name: "Set gitea version target ({{ gitea_version }})"
Expand Down
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ transfer_custom_footer:
- 'files/gitea_footer/extra_links_footer.tmpl'
- 'files/extra_links_footer.tmpl'

playbook_version_number: 37 # should be int
playbook_version_number: 38 # should be int
playbook_version_path: 'do1jlr.gitea.version'

0 comments on commit 3625ace

Please sign in to comment.