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