Skip to content

Commit f512467

Browse files
lexfreiclaude
andcommitted
feat: Ansible collection for Cozystack installation
Ansible collection (cozystack.installer) that deploys Cozystack on generic Kubernetes clusters (k3s, kubeadm, RKE2). Two-stage installation: Helm chart deploys the operator, then a Platform Package CR is applied for the chosen variant. Includes per-distro node preparation examples: - examples/ubuntu/ (Ubuntu/Debian) — apt - examples/rhel/ (RHEL 8+/CentOS Stream 8+/Rocky/Alma) — dnf - examples/suse/ (openSUSE/SLE) — zypper Tested on Lima VMs: openSUSE Leap, Debian 12, Rocky Linux 9. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
0 parents  commit f512467

30 files changed

+1515
-0
lines changed

.ansible-lint

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
# Prevent ansible-lint from auto-installing requirements.yml
3+
# (git commit hash versions crash ansible-galaxy's LooseVersion parser).
4+
# CI installs dependencies in a separate step before running lint.
5+
offline: true
6+
7+
skip_list:
8+
# All collection variables use cozystack_ prefix (collection namespace),
9+
# not individual role prefixes.
10+
- var-naming[no-role-prefix]
11+
12+
# Roles inside the collection cannot be resolved by ansible-lint
13+
# during local development (known issue: ansible-lint#2487).
14+
mock_roles:
15+
- cozystack.installer.cozystack
16+
17+
# examples/*/site.yml imports external playbooks (k3s.orchestration.site)
18+
# that may not be installed during linting.
19+
exclude_paths:
20+
- examples/ubuntu/site.yml
21+
- examples/rhel/site.yml
22+
- examples/suse/site.yml

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @lexfrei
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Bug report
3+
about: Report an issue with the collection
4+
labels: bug
5+
---
6+
7+
## Environment
8+
9+
- Ansible version:
10+
- Collection version:
11+
- Kubernetes distribution (k3s/kubeadm/RKE2):
12+
- OS:
13+
14+
## Expected behavior
15+
16+
## Actual behavior
17+
18+
## Steps to reproduce
19+
20+
1.
21+
22+
## Relevant logs
23+
24+
```text
25+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Feature request
3+
about: Suggest an enhancement
4+
labels: enhancement
5+
---
6+
7+
## Use case
8+
9+
<!-- What problem does this solve? -->
10+
11+
## Proposed solution
12+
13+
## Alternatives considered

.github/pull_request_template.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Summary
2+
3+
<!-- Brief description of what this PR does and why -->
4+
5+
## Changes
6+
7+
-
8+
9+
## Test plan
10+
11+
- [ ] `ansible-lint` passes
12+
- [ ] `ansible-test sanity` passes
13+
- [ ] Tested on a live cluster (describe environment)
14+
- [ ] Idempotency verified (second run: changed=0)

.github/workflows/test.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
name: Test
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
23+
- name: Install dependencies
24+
run: pip install ansible-core ansible-lint
25+
26+
- name: Build and install collection
27+
run: |
28+
ansible-galaxy collection build
29+
ansible-galaxy collection install cozystack-installer-*.tar.gz --force
30+
31+
- name: Install collection dependencies
32+
run: ansible-galaxy collection install --requirements-file requirements.yml
33+
34+
- name: Run ansible-lint
35+
run: ansible-lint
36+
37+
- name: Syntax check Ubuntu example
38+
run: ansible-playbook examples/ubuntu/prepare-ubuntu.yml --syntax-check
39+
40+
- name: Syntax check SUSE example
41+
run: ansible-playbook examples/suse/prepare-suse.yml --syntax-check
42+
43+
- name: Syntax check RHEL example
44+
run: ansible-playbook examples/rhel/prepare-rhel.yml --syntax-check
45+
46+
sanity:
47+
name: Sanity
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
with:
53+
path: ansible_collections/cozystack/installer
54+
55+
- name: Set up Python
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: "3.12"
59+
60+
- name: Install ansible-core
61+
run: pip install ansible-core
62+
63+
- name: Run sanity tests
64+
working-directory: ansible_collections/cozystack/installer
65+
run: ansible-test sanity --color
66+
67+
e2e:
68+
name: E2E
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v4
73+
74+
- name: Set up Python
75+
uses: actions/setup-python@v5
76+
with:
77+
python-version: "3.12"
78+
79+
- name: Install Ansible
80+
run: pip install ansible-core
81+
82+
- name: Build and install collection
83+
run: |
84+
ansible-galaxy collection build
85+
ansible-galaxy collection install cozystack-installer-*.tar.gz --force
86+
87+
- name: Install collection dependencies
88+
run: ansible-galaxy collection install --requirements-file requirements.yml
89+
90+
- name: Run full pipeline
91+
run: >-
92+
sudo env "PATH=$PATH" "HOME=$HOME" ansible-playbook examples/ubuntu/site.yml
93+
--inventory tests/ci-inventory.yml
94+
95+
- name: Verify operator is running
96+
run: |
97+
sudo kubectl --kubeconfig /etc/rancher/k3s/k3s.yaml \
98+
wait deployment/cozystack-operator \
99+
--namespace cozy-system \
100+
--timeout=120s \
101+
--for=condition=Available
102+
103+
- name: Verify CRDs are established
104+
run: |
105+
sudo kubectl --kubeconfig /etc/rancher/k3s/k3s.yaml \
106+
wait crd/packages.cozystack.io \
107+
--for=condition=Established \
108+
--timeout=60s
109+
110+
- name: Verify Platform Package exists
111+
run: |
112+
sudo kubectl --kubeconfig /etc/rancher/k3s/k3s.yaml \
113+
get package cozystack.cozystack-platform \
114+
--namespace cozy-system
115+
116+
- name: Test idempotency (second run)
117+
run: >-
118+
sudo env "PATH=$PATH" "HOME=$HOME" ansible-playbook examples/ubuntu/site.yml
119+
--inventory tests/ci-inventory.yml

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.tar.gz
2+
.DS_Store
3+
*.retry
4+
.ansible/
5+
__pycache__/
6+
*.pyc
7+
FILES.json
8+
MANIFEST.json

CHANGELOG.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
============================
2+
cozystack.installer Release Notes
3+
============================
4+
5+
v1.0.0-rc.1
6+
============
7+
8+
First release as a standalone collection. Synced with Cozystack v1.0.0-rc.1.
9+
10+
Breaking changes from pre-release development:
11+
12+
- Switched from custom chart (``lexfrei/cozystack-installer``) to official
13+
Cozystack installer chart (``ghcr.io/cozystack/cozystack/cozy-installer``)
14+
- Two-stage install: Helm chart deploys operator, Platform Package CR
15+
is applied separately via ``kubectl apply``
16+
- Role ``prepare`` removed from collection — moved to per-distro examples
17+
(``examples/ubuntu/``, ``examples/rhel/``, ``examples/suse/``)
18+
- ``k3s.orchestration`` removed from dependencies — users compose their own pipeline
19+
- New variables: ``cozystack_operator_variant``, ``cozystack_platform_variant``,
20+
``cozystack_create_platform_package``, ``cozystack_pod_cidr``, etc.
21+
- ``cozystack_root_host`` is no longer required for chart install
22+
(used in Platform Package CR)

0 commit comments

Comments
 (0)