Initial commit
All checks were successful
/ ansible-docsmith (push) Successful in 41s

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2026-03-23 10:48:41 +01:00 committed by Julien Riou
commit f418990e84
Signed by: jriou
GPG key ID: 9A099EDA51316854
85 changed files with 3520 additions and 2 deletions

50
roles/golang/README.md Normal file
View 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
```

View file

@ -0,0 +1,8 @@
---
# Version to install.
#
# - Type: str
# - Required: No
# - Default: 1.25.4
golang_version: 1.25.4

View 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

View file

@ -0,0 +1,7 @@
---
- name: Converge
hosts: molecule
roles:
- golang
vars:
golang_version: 1.25.4

View 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'] }}"

View 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

View 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

View 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

View file

@ -0,0 +1,3 @@
---
collections:
- name: containers.podman

View 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') != ""

View 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