From 6dabffe402d7b65cebaab821504c3f32bdb5acbe Mon Sep 17 00:00:00 2001 From: vass Date: Wed, 1 Apr 2020 19:48:17 +0200 Subject: [PATCH] Rename install-go to ensure-go for consistency The old role will be kept and include ensure-go for backwards-compatability. Change-Id: I4e6345563817057a6c47c124b9ec8b0c62b057d6 --- doc/source/go-roles.rst | 1 + playbooks/go/pre.yaml | 2 +- roles/ensure-go/README.rst | 17 +++++++++++++++++ .../defaults/main.yaml | 0 .../tasks/install-go.yaml | 0 roles/ensure-go/tasks/main.yaml | 14 ++++++++++++++ roles/{install-go => ensure-go}/vars/main.yaml | 0 roles/install-go/README.rst | 18 +----------------- roles/install-go/tasks/main.yaml | 17 +++-------------- 9 files changed, 37 insertions(+), 32 deletions(-) create mode 100644 roles/ensure-go/README.rst rename roles/{install-go => ensure-go}/defaults/main.yaml (100%) rename roles/{install-go => ensure-go}/tasks/install-go.yaml (100%) create mode 100644 roles/ensure-go/tasks/main.yaml rename roles/{install-go => ensure-go}/vars/main.yaml (100%) diff --git a/doc/source/go-roles.rst b/doc/source/go-roles.rst index 53ba1fdd3..33cda4036 100644 --- a/doc/source/go-roles.rst +++ b/doc/source/go-roles.rst @@ -1,6 +1,7 @@ Go Roles ======== +.. zuul:autorole:: ensure-go .. zuul:autorole:: ensure-golangci-lint .. zuul:autorole:: install-go .. zuul:autorole:: go diff --git a/playbooks/go/pre.yaml b/playbooks/go/pre.yaml index 9ab00c00b..6c49c6f98 100644 --- a/playbooks/go/pre.yaml +++ b/playbooks/go/pre.yaml @@ -1,3 +1,3 @@ - hosts: all roles: - - install-go + - ensure-go diff --git a/roles/ensure-go/README.rst b/roles/ensure-go/README.rst new file mode 100644 index 000000000..169d3a728 --- /dev/null +++ b/roles/ensure-go/README.rst @@ -0,0 +1,17 @@ +Install go + +**Role Variables** + +.. zuul:rolevar:: go_install_dir + :default: /usr/local/ + + Directory to install go in. + +.. zuul:rolevar:: go_version + :default: 1.13 + +.. zuul:rolevar:: go_os + :default: {{ ansible_system | lower }} + +.. zuul:rolevar:: go_arch + :default: amd64 / 386 diff --git a/roles/install-go/defaults/main.yaml b/roles/ensure-go/defaults/main.yaml similarity index 100% rename from roles/install-go/defaults/main.yaml rename to roles/ensure-go/defaults/main.yaml diff --git a/roles/install-go/tasks/install-go.yaml b/roles/ensure-go/tasks/install-go.yaml similarity index 100% rename from roles/install-go/tasks/install-go.yaml rename to roles/ensure-go/tasks/install-go.yaml diff --git a/roles/ensure-go/tasks/main.yaml b/roles/ensure-go/tasks/main.yaml new file mode 100644 index 000000000..e4936ec3d --- /dev/null +++ b/roles/ensure-go/tasks/main.yaml @@ -0,0 +1,14 @@ +- name: Check installed go version + command: go version + register: go_installed_version + environment: + PATH: "{{ ansible_env.PATH }}:{{ go_install_dir }}/go/bin" + ignore_errors: yes + +- name: Skip if correct version of go is installed + include_tasks: install-go.yaml + when: + - go_installed_version.rc != 0 or + go_version != (go_installed_version.stdout|regex_replace(go_version_pattern, '\\g')) or + go_os != (go_installed_version.stdout|regex_replace(go_version_pattern, '\\g')) or + go_arch != (go_installed_version.stdout|regex_replace(go_version_pattern, '\\g')) diff --git a/roles/install-go/vars/main.yaml b/roles/ensure-go/vars/main.yaml similarity index 100% rename from roles/install-go/vars/main.yaml rename to roles/ensure-go/vars/main.yaml diff --git a/roles/install-go/README.rst b/roles/install-go/README.rst index 169d3a728..1c7bded68 100644 --- a/roles/install-go/README.rst +++ b/roles/install-go/README.rst @@ -1,17 +1 @@ -Install go - -**Role Variables** - -.. zuul:rolevar:: go_install_dir - :default: /usr/local/ - - Directory to install go in. - -.. zuul:rolevar:: go_version - :default: 1.13 - -.. zuul:rolevar:: go_os - :default: {{ ansible_system | lower }} - -.. zuul:rolevar:: go_arch - :default: amd64 / 386 +.. warning:: Deprecated, use ensure-go instead. diff --git a/roles/install-go/tasks/main.yaml b/roles/install-go/tasks/main.yaml index e4936ec3d..0b9d53b96 100644 --- a/roles/install-go/tasks/main.yaml +++ b/roles/install-go/tasks/main.yaml @@ -1,14 +1,3 @@ -- name: Check installed go version - command: go version - register: go_installed_version - environment: - PATH: "{{ ansible_env.PATH }}:{{ go_install_dir }}/go/bin" - ignore_errors: yes - -- name: Skip if correct version of go is installed - include_tasks: install-go.yaml - when: - - go_installed_version.rc != 0 or - go_version != (go_installed_version.stdout|regex_replace(go_version_pattern, '\\g')) or - go_os != (go_installed_version.stdout|regex_replace(go_version_pattern, '\\g')) or - go_arch != (go_installed_version.stdout|regex_replace(go_version_pattern, '\\g')) +- name: Include ensure-go + include_role: + name: ensure-go