Add toggle to do a version check before download

Old behavior is to download the binary of `gitea_version` every run,
then checksum it against the currently installed version to see if it needs
to be copied over.

New behavior is to attempt to extract the current running version of gitea
and only initiate the old behavior if the running version != `gitea_version`.

Default is old behavior due to the major logic change involved.
This commit is contained in:
Trysdyn Black 2019-04-27 17:00:35 -07:00 committed by Thomas Maurice
parent 609a47de72
commit 3226a76d94
3 changed files with 12 additions and 2 deletions

View file

@ -8,7 +8,7 @@ Gitea is a Golang Git repository webapp, having the same look and feel as GitHub
It is still under developpement, see "Disclaimer" if you can't make it work.
## Sample exemple of use in a playbook
## Sample example of use in a playbook
The following have been tested with Debian 8, it should work on Ubuntu as well.
@ -55,6 +55,7 @@ The following have been tested with Debian 8, it should work on Ubuntu as well.
## More detailed options
### General
* `gitea_version_check`: Check if installed version != `gitea_version` before initiating binary download
* `gitea_user`: UNIX user used by Gitea
* `gitea_home`: Base directory to work
@ -173,4 +174,4 @@ Redistribution and use in source and binary forms, with or without modification,
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```
```

View file

@ -1,5 +1,6 @@
---
gitea_version: "1.7.5"
gitea_version_check: false
gitea_app_name: "Gitea"
gitea_user: "gitea"

View file

@ -1,4 +1,11 @@
---
- name: "Check gitea version"
shell: "/usr/local/bin/gitea -v | cut -d' ' -f 3"
register: gitea_active_version
changed_when: false
failed_when: false
when: gitea_version_check
- name: "Download the binary"
get_url:
url: "{{ gitea_dl_url }}/v{{ gitea_version }}/gitea-{{ gitea_version }}-linux-{{ gitea_arch }}"
@ -8,6 +15,7 @@
mode: 0755
force: true
notify: "Restart gitea"
when: (gitea_version_check == false) or (gitea_active_version.stdout != gitea_version)
- include: create_user.yml