Skip to content

Commit 2a4f6e8

Browse files
committed
add rex feature
1 parent 3558a56 commit 2a4f6e8

7 files changed

Lines changed: 120 additions & 5 deletions

File tree

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ jobs:
117117
- name: Add optional feature - foreman-proxy
118118
run: |
119119
./foremanctl deploy --add-feature foreman-proxy
120-
- name: Add optional features - azure-rm, google
120+
- name: Add optional features - azure-rm, google and remote-execution
121121
run: |
122-
./foremanctl deploy --add-feature azure-rm --add-feature google
122+
./foremanctl deploy --add-feature azure-rm --add-feature google --add-feature remote-execution
123123
- name: Run tests
124124
run: |
125125
./forge test --pytest-args="--certificate-source=${{ matrix.certificate_source }} --database-mode=${{ matrix.database }}"
@@ -226,9 +226,9 @@ jobs:
226226
- name: Add optional feature - foreman-proxy
227227
run: |
228228
./foremanctl deploy --add-feature foreman-proxy
229-
- name: Add optional features - azure-rm, google
229+
- name: Add optional features - azure-rm, google and remote-execution
230230
run: |
231-
./foremanctl deploy --add-feature azure-rm --add-feature google
231+
./foremanctl deploy --add-feature azure-rm --add-feature google --add-feature remote-execution
232232
- name: Stop services
233233
run:
234234
vagrant ssh quadlet -- sudo systemctl stop foreman.target

src/features.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ azure-rm:
1111
description: Azure Resource Manager plugin for Foreman
1212
foreman:
1313
plugin_name: foreman_azure_rm
14+
remote-execution:
15+
description: Remote Execution plugin for Foreman
16+
foreman:
17+
plugin_name: foreman_remote_execution
18+
foreman_proxy:
19+
plugin_name: remote_execution_ssh
20+
dependencies:
21+
- dynflow
22+
dynflow:
23+
internal: true
24+
foreman_proxy:
25+
plugin_name: dynflow
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
- name: Create SSH Key
3+
community.crypto.openssh_keypair:
4+
path: "/root/foreman-proxy-ssh"
5+
6+
- name: Create SSH Key podman secret
7+
containers.podman.podman_secret:
8+
state: present
9+
name: foreman-proxy-remote_execution_ssh-ssh-key
10+
path: "/root/foreman-proxy-ssh"
11+
notify:
12+
- Restart Foreman Proxy
13+
- Refresh Foreman Proxy
14+
15+
- name: Create SSH Pub podman secret
16+
containers.podman.podman_secret:
17+
state: present
18+
name: foreman-proxy-remote_execution_ssh-ssh-pub
19+
path: "/root/foreman-proxy-ssh.pub"
20+
notify:
21+
- Restart Foreman Proxy
22+
- Refresh Foreman Proxy
23+
24+
- name: Mount SSH secrets
25+
ansible.builtin.copy:
26+
dest: /etc/containers/systemd/foreman-proxy.container.d/remote_execution_ssh-keys.conf
27+
content: |
28+
[Container]
29+
Secret=foreman-proxy-remote_execution_ssh-ssh-key,type=mount,target=/usr/share/foreman-proxy/.ssh/id_rsa_foreman_proxy
30+
Secret=foreman-proxy-remote_execution_ssh-ssh-pub,type=mount,target=/usr/share/foreman-proxy/.ssh/id_rsa_foreman_proxy.pub
31+
mode: '0644'
32+
owner: root
33+
group: root
34+
notify:
35+
- Restart Foreman Proxy
36+
- Refresh Foreman Proxy
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
:enabled: {{ feature_enabled }}
3+
:database:
4+
5+
# Require a valid cert to access Dynflow console
6+
# :console_auth: true
7+
8+
# Maximum age of execution plans to keep before having them cleaned
9+
# by the execution plan cleaner (in seconds), defaults to 30 minutes
10+
# :execution_plan_cleaner_age: 1800
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
:enabled: {{ feature_enabled }}
3+
:ssh_identity_key_file: '~/.ssh/id_rsa_foreman_proxy'
4+
:local_working_dir: '/var/tmp'
5+
:remote_working_dir: '/var/tmp'
6+
:socket_working_dir: '/var/tmp'
7+
# :kerberos_auth: false
8+
9+
# :cockpit_integration: true
10+
11+
# Mode of operation, one of ssh, pull, pull-mqtt
12+
:mode: ssh
13+
14+
# Enables the use of SSH certificate for smart proxy authentication
15+
# The file should contain an SSH CA public key that the SSH public key of smart proxy is signed by
16+
# :ssh_user_ca_public_key_file:
17+
18+
# Enables the use of SSH host certificates for host authentication
19+
# The file should contain a list of trusted SSH CA authorities that the host certs can be signed by
20+
# Example file content: @cert-authority * <SSH CA public key>
21+
# :ssh_ca_known_hosts_file:
22+
23+
# Defines how often (in seconds) should the runner check
24+
# for new data leave empty to use the runner's default
25+
# :runner_refresh_interval: 1
26+
27+
# Defines the verbosity of logging coming from ssh command
28+
# one of :debug, :info, :error, :fatal
29+
# must be lower than general log level
30+
# :ssh_log_level: error
31+
32+
# Remove working directories on job completion
33+
# :cleanup_working_dirs: true
34+
35+
# MQTT configuration, need to be set if mode is set to pull-mqtt
36+
# :mqtt_broker: localhost
37+
# :mqtt_port: 1883
38+
39+
# Use of SSL can be forced either way by explicitly setting mqtt_tls setting. If
40+
# unset, SSL gets used if smart-proxy's foreman_ssl_cert, foreman_ssl_key and
41+
# foreman_ssl_ca settings are set available.
42+
# :mqtt_tls:
43+
44+
# The notification is sent over mqtt every $mqtt_resend_interval seconds, until
45+
# the job is picked up by the host or cancelled
46+
# :mqtt_resend_interval: 900

tests/client_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
def test_foreman_content_view(client_environment, activation_key, organization, foremanapi, client):
22
client.run('dnf install -y subscription-manager')
3-
rcmd = foremanapi.create('registration_commands', {'organization_id': organization['id'], 'insecure': True, 'activation_keys': [activation_key['name']]})
3+
rcmd = foremanapi.create('registration_commands', {'organization_id': organization['id'], 'insecure': True, 'activation_keys': [activation_key['name']], 'force': True})
44
client.run_test(rcmd['registration_command'])
55
client.run('subscription-manager repos --enable=*')
66
client.run_test('dnf install -y bear')
77
assert client.package('bear').is_installed
88
client.run('dnf remove -y bear')
99
client.run('subscription-manager unregister')
1010
client.run('subscription-manager clean')
11+
12+
def test_foreman_rex(client_environment, activation_key, organization, foremanapi, client, client_fqdn):
13+
client.run('dnf install -y subscription-manager')
14+
rcmd = foremanapi.create('registration_commands', {'organization_id': organization['id'], 'insecure': True, 'activation_keys': [activation_key['name']], 'force': True})
15+
client.run_test(rcmd['registration_command'])
16+
job = foremanapi.create('job_invocations', {'feature': 'run_script', 'inputs': {'command': 'uptime'}, 'search_query': f'name = {client_fqdn}', 'targeting_type': 'static_query'})
17+
task = foremanapi.wait_for_task(job['task'])
18+
assert task['result'] == 'success'
19+
foremanapi.delete('hosts', {'id': client_fqdn})

tests/foreman_proxy_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ def test_foreman_proxy_features(server, certificates, server_fqdn):
77
assert cmd.succeeded
88
features = json.loads(cmd.stdout)
99
assert "logs" in features
10+
assert "script" in features
11+
assert "dynflow" in features
1012

1113
def test_foreman_proxy_service(server):
1214
foreman_proxy = server.service("foreman-proxy")

0 commit comments

Comments
 (0)