From 3226a76d940fef4092adcc053720c5488aee0994 Mon Sep 17 00:00:00 2001 From: Trysdyn Black Date: Sat, 27 Apr 2019 17:00:35 -0700 Subject: [PATCH] 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. --- README.md | 5 +++-- defaults/main.yml | 1 + tasks/main.yml | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 99d6cf4..5423385 100644 --- a/README.md +++ b/README.md @@ -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. -``` \ No newline at end of file +``` diff --git a/defaults/main.yml b/defaults/main.yml index 432715d..4a1f8c3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,6 @@ --- gitea_version: "1.7.5" +gitea_version_check: false gitea_app_name: "Gitea" gitea_user: "gitea" diff --git a/tasks/main.yml b/tasks/main.yml index c3ab493..b2a5d23 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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