Skip to content

Commit 5a7414b

Browse files
authored
Merge pull request #2 from ferricoxide/AddLinFuncs
Add funcitonality for Linux Configuration-Targets
2 parents cb91b99 + a993e12 commit 5a7414b

21 files changed

Lines changed: 390 additions & 107 deletions

File tree

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.0.1
2+
current_version = 0.1.0
33
commit = True
44
message = Bumps version to {new_version}
55
tag = False

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,19 @@ concurrency:
99
jobs:
1010
test:
1111
uses: plus3it/actions-workflows/.github/workflows/test.yml@ddd67e99878a285f728de398c1116151c2d7791a
12+
13+
linux:
14+
uses: plus3it/actions-workflows/.github/workflows/test-salt-linux.yml@ddd67e99878a285f728de398c1116151c2d7791a
15+
strategy:
16+
matrix:
17+
os_version:
18+
- 8
19+
- 9
20+
salt_state:
21+
- flux-cli
22+
salt_pillar_root:
23+
- ./tests/pillar/test-linux-main
24+
with:
25+
salt-os-version: ${{ matrix.os_version }}
26+
salt-state: ${{ matrix.salt_state }}
27+
salt-pillar-root: ${{ matrix.salt_pillar_root }}

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
### 0.1.0
8+
9+
**Released**: 2026.05.12
10+
11+
**Summary**:
12+
13+
* Adds setup-capability for RHEL-type Linux configuration-targets (tested with Alma Linux 9.7)
14+
* Adds Linux-related CI features to project
15+
* Add conditional integration-steps for Podman and Docker (and tested with the [kind](https://kind.sigs.k8s.io/)
16+
717
### 0.0.1
818

919
**Released**: 2026.05.11

README.md

Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,47 @@
1-
# repo-template
2-
Generic repo template for Plus3IT repositories
3-
4-
To use this template:
5-
6-
1. Select the green "Use this template" button, or [click here](https://github.com/plus3it/repo-template/generate).
7-
2. Select the repo Owner, give the repo a name, enter a description, select Public or Private, and click "Create repository from template".
8-
3. Clone the repository and create a new branch.
9-
4. Configure the following settings on your new repo.
10-
* `GENERAL`
11-
* `Features`
12-
* Turn off Wikis, Sponsorships, Discussions, and Projects
13-
* `Pull Requests`
14-
* Turn off Squash Merging
15-
* Turn off Rebase Merging
16-
* Turn on Allow Auto-Merge
17-
* Turn on Automatically delete head branches
18-
* `Pushes`
19-
* Limit how many branches can be updated in a single push: 2
20-
* `COLLABORATORS and TEAMS`
21-
* `Manage Access`
22-
* Add relevant team roles, for example
23-
* `tardigrade-admins` (Admin)
24-
* `terraform` (Write)
25-
* `releasebot` (Write)
26-
* `Branches`
27-
* `Create Branch Protection rule` for `main`
28-
* Turn on Require pull request before merging
29-
* Turn on Require approvals
30-
* Turn on Dismiss stale pull requests...
31-
* `Required Status Checks`
32-
* As relevant to projects, for example
33-
* WIP
34-
* lint/actionlint
35-
* lint/tardigradelint
36-
* test / mockstacktest
37-
* Turn on Do not allow bypassing the above settings
38-
5. Edit the following files to customize them for the new repository:
39-
* `LICENSE`
40-
* Near the end of the file, edit the date and change the repository name
41-
* `CHANGELOG.template.md`
42-
* Rename to `CHANGELOG.md`, replacing the repo-template changelog
43-
* Edit templated items for the new repo
44-
* `.bumpversion.cfg`
45-
* Edit the version number for the new repo, ask team if not sure what to
46-
start with
47-
* `README.md`
48-
* Replace contents for the new repo
49-
* `.github/`
50-
* Inspect dependabot and workflow files in case changes are needed for
51-
the new repo
52-
6. Commit the changes and open a pull request
1+
flux-cli-formula
2+
==================
3+
4+
A SaltStack formula designed to install and configure the [Flux](https://fluxcd.io/flux/cmd/) CLI utility on installation-targets.
5+
6+
It is primarily expected that this formula will be run via [P3](https://www.plus3it.com/)'s "[watchmaker](https://watchmaker.readthedocs.io/en/stable/)" framework.
7+
8+
This formula is able to install the Flux CLI on both Linux[^1] and Windows Server[^2] operating environments. Intallation for internet-connected systems will come from the Flux CLI project's ["releases" page](https://github.com/fluxcd/flux2/releases).
9+
10+
11+
## Available states
12+
13+
- [flux-cli](#flux-cli)
14+
- [flux-cli.clean](#flux-cli.clean)
15+
- [flux-cli.package](#flux-cli.package)
16+
- [flux-cli.package.clean](#flux-cli.package.clean)
17+
- [flux-cli.config](#flux-cli.config)
18+
- [flux-cli.config.clean](#flux-cli.config.clean)
19+
20+
### flux-cli
21+
22+
Executes the `package` and `config` states to install and configure the Flux CLI
23+
24+
### flux-cli.clean
25+
26+
Executes the `package` and `config` states' `clean` actions to fully uninstall the Flux CLI and remove previously-installed browser policy-configs (and, on Windows, associated registry entries)
27+
28+
### flux-cli.package
29+
30+
Executes _just_ the `package` state to install the Flux CLI package.
31+
32+
### flux-cli.package.clean
33+
34+
Executes _just_ the `package.clean` state to uninstall the Flux CLI package.
35+
36+
### flux-cli.config
37+
38+
Executes _just_ the `config` state to install/configure the Flux CLI client-configuration (etc.) files
39+
40+
### flux-cli.config.clean
41+
42+
Executes _just_ the `config` state to uninstall the Flux CLI client-configuration (etc.) files and, on Windows, remove any registry-keys set by prior install-runs of the formula.
43+
44+
45+
46+
[^1]: As of this README's writing, only Enterprise Linux and related distros (Red Hat and Oracle Enterprise, CentOS Stream, Rocky and Alma Linux). It has only been specifically tested with EL **_9_** variants.
47+
[^2]: As of this README's writing, this functionality has only been tested on Windows Server 2022

flux-cli/_mapdata/_mapdata.jinja

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
---
44
{#- use salt.slsutil.serialize to avoid encoding errors on some platforms #}
55
{{ salt["slsutil.serialize"](
6-
"yaml",
7-
map,
8-
default_flow_style=False,
9-
allow_unicode=True,
10-
)
11-
| regex_replace("^\s+'$", "'", multiline=True)
12-
| trim
6+
"yaml",
7+
map,
8+
default_flow_style=False,
9+
allow_unicode=True,
10+
)
11+
| regex_replace("^\s+'$", "'", multiline=True)
12+
| trim
1313
}}

flux-cli/clean.sls

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
# vim: ft=sls
33

44
include:
5-
- .subcomponent.clean
6-
- .service.clean
75
- .config.clean
86
- .package.clean

flux-cli/config/clean.sls

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
{%- from tplroot ~ "/map.jinja" import mapdata as flux_cli with context %}
88
99
include:
10-
- {{ sls_service_clean }}
10+
{%- if grains.kernel == "Linux" %}
11+
- flux-cli.config.lin_clean
12+
{%- elif grains.kernel == "Windows" %}
13+
- flux-cli.config.win_clean
14+
{%- endif %}
1115
12-
flux-cli-config-clean-file-absent:
13-
file.absent:
14-
- name: {{ flux_cli.config }}
15-
- require:
16-
- sls: {{ sls_service_clean }}

flux-cli/config/file.sls

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,10 @@
99
1010
include:
1111
- {{ sls_package_install }}
12+
{%- if grains.kernel == "Linux" %}
13+
- flux-cli.config.lin_file
14+
{%- elif grains.kernel == "Windows" %}
15+
- flux-cli.config.win_file
16+
{%- endif %}
17+
1218
13-
flux-cli-config-file-file-managed:
14-
file.managed:
15-
- name: {{ flux_cli.config }}
16-
- source: {{ files_switch(['example.tmpl'],
17-
lookup='flux-cli-config-file-file-managed'
18-
)
19-
}}
20-
- mode: 644
21-
- user: root
22-
- group: {{ flux_cli.rootgroup }}
23-
- makedirs: True
24-
- template: jinja
25-
- require:
26-
- sls: {{ sls_package_install }}
27-
- context:
28-
flux_cli: {{ flux_cli | json }}

flux-cli/config/lin_clean.sls

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
{%- set tplroot = tpldir.split('/')[0] %}
5+
{%- set sls_package_clean = tplroot ~ '.package.clean' %}
6+
{%- from tplroot ~ "/map.jinja" import mapdata as flux_cli with context %}
7+
8+
include:
9+
- {{ sls_package_clean }}
10+
11+
Remove bash-completion file for Flux:
12+
file.absent:
13+
- name: '/etc/bash_completion.d/flux'
14+
15+
Remove kubeconfig directory for all users:
16+
file.absent:
17+
- name: '/etc/skel/.kube'
18+
19+
Remove shell-ENVs for Flux:
20+
file.absent:
21+
- name: '/etc/profile.d/flux_env.sh'

flux-cli/config/lin_file.sls

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split('/')[0] %}
6+
{%- set sls_package_install = tplroot ~ '.package.install' %}
7+
{%- from tplroot ~ "/map.jinja" import mapdata as flux_cli with context %}
8+
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
9+
{%- set installed_pkgs = salt['pkg.list_pkgs']() %}
10+
11+
include:
12+
- {{ sls_package_install }}
13+
14+
Enable podman socket for all future users:
15+
file.managed:
16+
- contents: "enable podman.socket"
17+
- group: root
18+
- mode: '0644'
19+
- name: '/usr/lib/systemd/user-preset/80-podman.preset'
20+
- only_if:
21+
- '[[ rpm -q --quiet podman ]]'
22+
- user: root
23+
24+
{%- if 'docker-ce' in installed_pkgs or 'docker' in installed_pkgs %}
25+
Ensure Docker Service for Flux/Kind:
26+
service.running:
27+
- name: 'docker'
28+
- enable: True
29+
- require:
30+
- file: 'Enforce flux permissions and SELinux'
31+
- require_in:
32+
- file: 'Install user-env setup for Podman socket'
33+
{%- endif %}
34+
35+
{%- if 'podman' in installed_pkgs %}
36+
Ensure Podman Socket for Kind:
37+
service.running:
38+
- name: 'podman.socket'
39+
- enable: True
40+
- comment: "Podman detected; enabling socket for Flux/Kind compatibility."
41+
- require:
42+
- file: 'Enforce flux permissions and SELinux'
43+
- require_in:
44+
- file: 'Install user-env setup for Podman socket'
45+
{%- endif %}
46+
47+
Ensure bash-completion package is present:
48+
pkg.installed:
49+
- name: bash-completion
50+
- require:
51+
- file: 'Enforce flux permissions and SELinux'
52+
53+
Ensure kubeconfig directory for all users:
54+
file.directory:
55+
- name: '/etc/skel/.kube'
56+
- user: root
57+
- group: root
58+
- mode: '0755'
59+
60+
Ensure systemd user delegation for Kind:
61+
file.managed:
62+
- contents: |
63+
[Service]
64+
Delegate=yes
65+
- group: root
66+
- makedirs: True
67+
- mode: '0644'
68+
- name: '/etc/systemd/system/user@.service.d/delegate.conf'
69+
- only_if:
70+
- '[[ -f /usr/local/bin/kind || -f /usr/bin/kind ]]'
71+
- user: root
72+
73+
Ensure the directory exists for the global link:
74+
file.directory:
75+
- group: root
76+
- makedirs: True
77+
- mode: '0755'
78+
- name: '/usr/lib/systemd/user/sockets.target.wants'
79+
- user: root
80+
81+
Fix permissions on bash-completion for Flux:
82+
file.managed:
83+
- group: root
84+
- mode: '0644'
85+
- name: '/etc/bash_completion.d/flux'
86+
- replace: False
87+
- require:
88+
- cmd: 'Install bash-completion for Flux'
89+
- user: root
90+
91+
Force podman socket globally:
92+
file.symlink:
93+
- name: '/usr/lib/systemd/user/sockets.target.wants/podman.socket'
94+
- target: '/usr/lib/systemd/user/podman.socket'
95+
- force: True
96+
- only_if:
97+
- '[[ rpm -q --quiet podman ]]'
98+
- require:
99+
- file: 'Ensure the directory exists for the global link'
100+
101+
Install bash-completion for Flux:
102+
cmd.run:
103+
- name: '/usr/local/bin/flux completion bash > /etc/bash_completion.d/flux'
104+
- onchanges:
105+
- archive: 'Extract flux CLI Archive'
106+
- require:
107+
- pkg: 'Ensure bash-completion package is present'
108+
109+
Install user-env setup for Podman socket:
110+
file.managed:
111+
- contents: |
112+
# Use rootless socket if available
113+
if [[ -S "${XDG_RUNTIME_DIR}/podman/podman.sock" ]]
114+
then
115+
export DOCKER_HOST="unix://${XDG_RUNTIME_DIR}/podman/podman.sock"
116+
# Fall back to system socket if the user has permissions
117+
elif [[ -w "/run/podman/podman.sock" ]]; then
118+
export DOCKER_HOST="unix:///run/podman/podman.sock"
119+
fi
120+
- group: root
121+
- mode: '0644'
122+
- name: '/etc/profile.d/flux_env.sh'
123+
- only_if:
124+
- [[ -S /run/podman/podman.sock ]]
125+
- user: root
126+
127+
Reload systemd for delegation:
128+
module.run:
129+
- service.systemctl_reload: {}
130+
- onchanges:
131+
- file: Ensure systemd user delegation for Kind

0 commit comments

Comments
 (0)