Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
ad30a8307f
commit
f418990e84
85 changed files with 3520 additions and 2 deletions
50
roles/golang/README.md
Normal file
50
roles/golang/README.md
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# Ansible Role Go
|
||||
|
||||
Install [Go](https://go.dev/).
|
||||
|
||||
## Table of content
|
||||
|
||||
<!-- ANSIBLE DOCSMITH TOC START -->
|
||||
* [Role variables](#variables)
|
||||
* [`golang_version`](#variable-golang_version)
|
||||
<!-- ANSIBLE DOCSMITH TOC END -->
|
||||
<!-- ANSIBLE DOCSMITH MAIN START -->
|
||||
|
||||
## Role variables<a id="variables"></a>
|
||||
|
||||
The following variables can be configured for this role:
|
||||
|
||||
| Variable | Type | Required | Default | Description (abstract) |
|
||||
|----------|------|----------|---------|------------------------|
|
||||
| `golang_version` | `str` | No | `"1.25.4"` | Version to install. |
|
||||
|
||||
### `golang_version`<a id="variable-golang_version"></a>
|
||||
|
||||
[*⇑ Back to ToC ⇑*](#toc)
|
||||
|
||||
Version to install.
|
||||
|
||||
- **Type**: `str`
|
||||
- **Required**: No
|
||||
- **Default**: `"1.25.4"`
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ANSIBLE DOCSMITH MAIN END -->
|
||||
|
||||
## Usage
|
||||
|
||||
Playbook example:
|
||||
|
||||
```yaml
|
||||
- hosts: all
|
||||
roles:
|
||||
- jriou.general.golang
|
||||
```
|
||||
|
||||
Then run the playbook:
|
||||
|
||||
```
|
||||
ansible-playbook play.yml
|
||||
```
|
||||
8
roles/golang/defaults/main.yml
Normal file
8
roles/golang/defaults/main.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
|
||||
# Version to install.
|
||||
#
|
||||
# - Type: str
|
||||
# - Required: No
|
||||
# - Default: 1.25.4
|
||||
golang_version: 1.25.4
|
||||
13
roles/golang/meta/argument_specs.yml
Normal file
13
roles/golang/meta/argument_specs.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
argument_specs:
|
||||
main:
|
||||
short_description: Install Go
|
||||
description:
|
||||
- Install [Go](https://go.dev/).
|
||||
author:
|
||||
- jriou
|
||||
options:
|
||||
golang_version:
|
||||
description:
|
||||
- Version to install.
|
||||
default: 1.25.4
|
||||
7
roles/golang/molecule/default/converge.yml
Normal file
7
roles/golang/molecule/default/converge.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: molecule
|
||||
roles:
|
||||
- golang
|
||||
vars:
|
||||
golang_version: 1.25.4
|
||||
18
roles/golang/molecule/default/create.yml
Normal file
18
roles/golang/molecule/default/create.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- name: Create containers
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Create containers
|
||||
containers.podman.podman_container:
|
||||
hostname: "{{ item }}"
|
||||
name: "{{ item }}"
|
||||
image: "{{ hostvars[item]['container_image'] }}"
|
||||
state: started
|
||||
loop: "{{ groups['molecule'] }}"
|
||||
|
||||
- name: Wait for containers to be ready
|
||||
ansible.builtin.wait_for_connection:
|
||||
timeout: 300
|
||||
delegate_to: "{{ item }}"
|
||||
loop: "{{ groups['molecule'] }}"
|
||||
11
roles/golang/molecule/default/destroy.yml
Normal file
11
roles/golang/molecule/default/destroy.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
- name: Destroy container instances
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Remove containers
|
||||
containers.podman.podman_container:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
loop: "{{ groups['molecule'] }}"
|
||||
failed_when: false
|
||||
12
roles/golang/molecule/default/inventory/hosts.yml
Normal file
12
roles/golang/molecule/default/inventory/hosts.yml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
molecule:
|
||||
hosts:
|
||||
debian11:
|
||||
ansible_connection: containers.podman.podman
|
||||
container_image: docker.io/geerlingguy/docker-debian11-ansible:latest
|
||||
debian12:
|
||||
ansible_connection: containers.podman.podman
|
||||
container_image: docker.io/geerlingguy/docker-debian12-ansible:latest
|
||||
debian13:
|
||||
ansible_connection: containers.podman.podman
|
||||
container_image: docker.io/geerlingguy/docker-debian13-ansible:latest
|
||||
26
roles/golang/molecule/default/molecule.yml
Normal file
26
roles/golang/molecule/default/molecule.yml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
ansible:
|
||||
executor:
|
||||
args:
|
||||
ansible_playbook:
|
||||
- --inventory=inventory/
|
||||
env:
|
||||
ANSIBLE_ROLES_PATH: ../../../../roles
|
||||
playbooks:
|
||||
create: create.yml
|
||||
converge: converge.yml
|
||||
verify: verify.yml
|
||||
destroy: destroy.yml
|
||||
|
||||
dependency:
|
||||
name: galaxy
|
||||
options:
|
||||
requirements-file: ${MOLECULE_SCENARIO_DIRECTORY}/requirements.yml
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
- create
|
||||
- converge
|
||||
- idempotence
|
||||
- verify
|
||||
- destroy
|
||||
3
roles/golang/molecule/default/requirements.yml
Normal file
3
roles/golang/molecule/default/requirements.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
collections:
|
||||
- name: containers.podman
|
||||
15
roles/golang/molecule/default/verify.yml
Normal file
15
roles/golang/molecule/default/verify.yml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- name: Verify
|
||||
hosts: molecule
|
||||
vars:
|
||||
golang_version: 1.25.4
|
||||
tasks:
|
||||
- name: Get version
|
||||
ansible.builtin.command:
|
||||
cmd: /usr/local/go/bin/go version
|
||||
register: golang_version_cmd
|
||||
|
||||
- name: Compare versions
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- golang_version_cmd.stdout | regex_search('^go version go' + golang_version + ' linux/amd64') != ""
|
||||
7
roles/golang/tasks/main.yml
Normal file
7
roles/golang/tasks/main.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- name: Install
|
||||
ansible.builtin.unarchive:
|
||||
src: "https://go.dev/dl/go{{ golang_version }}.linux-amd64.tar.gz"
|
||||
dest: /usr/local
|
||||
remote_src: true
|
||||
creates: /usr/local/go
|
||||
Loading…
Add table
Add a link
Reference in a new issue