summaryrefslogtreecommitdiffstats
path: root/roles/ansible/README.md
blob: 1234be8655319e2c102c3c921a87e8f9f8961d53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Ansible Role

This role manages multiple versions of ansible-core and molecule using pipx,
allowing you to install different versions side-by-side and switch between them easily.

## Variables

### Required Variables

**Ansible-core:**

- `ansible_core_versions`: List of ansible-core versions to install
- `ansible_core_default_version`: The version to use as default (must be in the versions list)

**Molecule:**

- `molecule_versions`: List of molecule versions to install
- `molecule_default_version`: The version to use as default (must be in the versions list)

### Example Configuration

```yaml
ansible_core_versions:
  - "2.18.7"
ansible_core_default_version: "2.18.7"

molecule_versions:
  - "25.7.0"
molecule_default_version: "25.7.0"
```

## Usage

### Installed Commands

After running this role, you'll have:

**Ansible version-specific commands:**

- `ansible2.18.7`, `ansible-playbook2.18.7`, `ansible-galaxy2.18.7`, etc.

**Molecule version-specific commands:**

- `molecule25.7.0` (includes docker and podman drivers via molecule-plugins)

**Default commands (symlinked to default version):**

- `ansible` → `ansible2.18.7`
- `ansible-playbook` → `ansible-playbook2.18.7`
- `ansible-galaxy` → `ansible-galaxy2.18.7`
- `molecule` → `molecule25.7.0`
- And all other ansible commands

### Switching Default Version

To switch the default version:

1. Update `ansible_core_default_version` and/or `molecule_default_version` in your variables
2. Re-run the playbook

The symlinks will be updated to point to the new default versions.

## Requirements

- `uv`
- `python`

These are installed via `python` role

## Example Playbook

```yaml
- hosts: all
  roles:
    - role: ansible
      vars:
        ansible_core_versions:
          - "2.18.7"
          - "2.19.1"
        ansible_core_default_version: "2.19.1"
```