Skip to content

Commit

Permalink
containers: add keycloak
Browse files Browse the repository at this point in the history
Adding new container for Keycloak.  Container defined in
separate docker-compose since it is unnecessary for general SSSD
testing.

Container build ansible role added and Makefile and scripts updated to
reflect the new keycloak container.

Signed-off-by: Scott Poore <[email protected]>
  • Loading branch information
spoore1 authored and pbrezina committed May 26, 2023
1 parent 1fa9aff commit 5aa154c
Show file tree
Hide file tree
Showing 29 changed files with 367 additions and 26 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ up-passkey:
&& docker-compose -f docker-compose.yml -f docker-compose.passkey.yml up \
--no-recreate --detach ${LIMIT}

up-keycloak:
docker-compose -f docker-compose.yml -f docker-compose.keycloak.yml up \
--no-recreate --detach ${LIMIT}

stop:
docker-compose stop

down:
docker-compose down
docker-compose -f docker-compose.yml \
-f docker-compose.keycloak.yml \
-f docker-compose.passkey.yml down

update:
docker-compose pull
Expand Down
31 changes: 31 additions & 0 deletions data/certs/master.keycloak.test.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-----BEGIN CERTIFICATE-----
MIIFTzCCAzegAwIBAgITPJ2nsJjf6JgZjc5YZi1LZL1I4DANBgkqhkiG9w0BAQsF
ADArMQ0wCwYDVQQKDAR0ZXN0MQ0wCwYDVQQLDARzc3NkMQswCQYDVQQDDAJjYTAe
Fw0yMzAzMzAyMDE3MjFaFw00MjEyMTUyMDE3MjFaMD0xDTALBgNVBAoMBHRlc3Qx
DTALBgNVBAsMBHNzc2QxHTAbBgNVBAMMFG1hc3Rlci5rZXljbG9hay50ZXN0MIIC
IjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAo3v/0s0OAKNG8508BGXHb6pW
5NMatadps42KYSY+PKNd96ANMfOrSstFCDgxMM33abOZl4FyLCfsZv5++XCYiQ6x
KCgO/RYqH0YXUOw560RKOismA3fWbIsgwb8LecOR73LpOot/pIo5HAgKYjMu72Gy
GBpBeKeMhIdKw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2OTl3TiBShaa
a7qB4pOI4n7TEso05PvPUlvNe/52iBz4dfd8Alic4G+4ApExrjiPBK2VdgVun0bQ
qN6M4RW7cudTORnOENDGp9aO+AB4G1xcH4kiZa/FWvgPRT3FmMzeV8cYQg23vM9q
066Vu3gp+lRLHncoBxdJuXtaY6gT3cgptnQLvXhiZfwaPaNQLDi+UWZ9+rPMGkD6
yBthELFTGw93h0RojVj+VKCUY6NnrNvbxhcQntwhNHt0ot7B280iR1eZnmlwbMCI
qpEVBfEoqIYxBQG/ksqYrICzsA==
-----END CERTIFICATE-----
52 changes: 52 additions & 0 deletions data/certs/master.keycloak.test.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCje//SzQ4Ao0bz
nTwEZcdvqlbk0xq1p2mzjYphJj48o133oA0x86tKy0UIODEwzfdps5mXgXIsJ+xm
/n75cJiJDrEoKA79FiofRhdQ7DnrREo6KyYDd9ZsiyDBvwt5w5Hvcuk6i3+kijkc
CApiMy7vYbIYGkF4p4yEh0rBoBh0KSPLVWwMh1oILRGtxH5k/c8jiSwLPHqJwgJF
4z1QmbO9G9Ng/P8T30699V353ZZCJLKx48vKBXTFgwjvRiRNMOtm8CzhHdB97UMZ
iosa7x28ux1rBY10lwBKC7U4NXSEpFksd37w6SmZE4btLFa/kX5fMimWYyPLQ3qH
FfNB5TDHRSH8sThCBbVlrSpL9IWR1pYGg/zpKmO9di+sCCJJCzdf4cunpKVkKCTR
+aFbN4uW5iRfKIaZMuehXr5ih5dHv0/ak9qgAybLJ6K0O0vMBp2cWZdrFX1moYRO
7VVI5m2M1HOwHPwSlug/Gm614NXeHkyVYw1HWaqO3xYI8fe8A/QhpcLbo6la6YOM
tXrHhSZy4EzHsZZKfHh/3gAy1qkQJqFZuqVj9mzzNGNQ/cagLyDhID8KTYNogRyM
AFgfdjJcv/gwDp9KrJMnzPAKyDQIhR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E5xy//sP2TV36qj2wIcmZca/zDIFt90Fzeau/teWMEzQe
FwdxAoIBAEZdO6/WwuXH7v5uKdInGmkxxswdnAaPCulSM6ruUHh2XvGFTa557OkT
p9zYDlMWrt7IZ55CaeLMbTqliY5/Ic+srBDw1111JJv1ARHg1+TrZ8AjgSzQSHX+
lO1UnQlu6eQ5PkE4Ns6yoD9gJzxRgHxHkifhWzJfwqHJ7bAk7CA/6Jbpvuwe7y4j
X2xf4k7HRrVzAP/jwL1d9Nnzk2xEJ6WjNcmWNeYOJt5Wog9t1pyqnI5iwZDhRHKi
H25jt3nPjG1LQU+Bix2qeuKoqjP3bsAakrsrQKckopA70egSPpUpwD5246TcItty
wpmmCXuBcDn5+o3D4ZI7fZ9QVn9bi28=
-----END PRIVATE KEY-----
2 changes: 2 additions & 0 deletions data/configs/dnsmasq.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ address=/master.ldap.test/172.16.100.20
address=/client.test/172.16.100.40
address=/nfs.test/172.16.100.50
address=/kdc.test/172.16.100.60
address=/master.keycloak.test/172.16.100.70

# Add SRV record for LDAP
srv-host=_ldap._tcp.ldap.test,master.ldap.test,389
Expand All @@ -30,3 +31,4 @@ ptr-record=20.100.16.172.in-addr.arpa,master.ldap.test
ptr-record=30.100.16.172.in-addr.arpa,dc.samba.test
ptr-record=40.100.16.172.in-addr.arpa,client.test
ptr-record=10.200.16.172.in-addr.arpa,dc.ad.test
ptr-record=70.100.16.172.in-addr.arpa,master.keycloak.test
9 changes: 9 additions & 0 deletions data/ssh-keys/hosts/master.keycloak.test.ecdsa_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS
1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQQo6x4yFjX+7NouHZzMyXid7gRR5C0W
UtZ8wzOyE8jMAmserl+FLtj5rh03iXnYNQyoM6e28YjFTW40S6QgGeEOAAAAuD0IGAs9CB
gLAAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCjrHjIWNf7s2i4d
nMzJeJ3uBFHkLRZS1nzDM7ITyMwCax6uX4Uu2PmuHTeJedg1DKgzp7bxiMVNbjRLpCAZ4Q
4AAAAhAJEZoIsYYJM1zgrQBNpJ/nBQkUB0KX/edjVHvxTtLcj8AAAAG1dlbGwga25vd24g
a2V5IGZvciBzc3NkLWNpLgECAwQ=
-----END OPENSSH PRIVATE KEY-----
1 change: 1 addition & 0 deletions data/ssh-keys/hosts/master.keycloak.test.ecdsa_key.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCjrHjIWNf7s2i4dnMzJeJ3uBFHkLRZS1nzDM7ITyMwCax6uX4Uu2PmuHTeJedg1DKgzp7bxiMVNbjRLpCAZ4Q4= Well known key for sssd-ci.
9 changes: 9 additions & 0 deletions data/ssh-keys/hosts/master.keycloak.test.ed25519_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS
1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQT5YcfqE2FEyZuoZAMuSoMl13D/SH4j
bYxbU/L7MWvpLeW2VvqQquJRGOzYCsGrWC5rSF1SjFm/dMilBJm2WhxsAAAAuCuqfD4rqn
w+AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPlhx+oTYUTJm6hk
Ay5KgyXXcP9IfiNtjFtT8vsxa+kt5bZW+pCq4lEY7NgKwatYLmtIXVKMWb90yKUEmbZaHG
wAAAAhAJi8m6d8fgyJSMNeKPf+U1BdH1PunSHV/VOpqPHSu4VsAAAAG1dlbGwga25vd24g
a2V5IGZvciBzc3NkLWNpLgECAwQ=
-----END OPENSSH PRIVATE KEY-----
1 change: 1 addition & 0 deletions data/ssh-keys/hosts/master.keycloak.test.ed25519_key.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPlhx+oTYUTJm6hkAy5KgyXXcP9IfiNtjFtT8vsxa+kt5bZW+pCq4lEY7NgKwatYLmtIXVKMWb90yKUEmbZaHGw= Well known key for sssd-ci.
9 changes: 9 additions & 0 deletions data/ssh-keys/hosts/master.keycloak.test.rsa_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS
1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQRIiqAbVB3EEMISmR5AGDh78F5/TK4l
+TrlOTvnye1/nx4kv/Nv2C3UDNsYENsePybKPiFNkd4i8UjCdjAIfgmGAAAAuDVOCT81Tg
k/AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEiKoBtUHcQQwhKZ
HkAYOHvwXn9MriX5OuU5O+fJ7X+fHiS/82/YLdQM2xgQ2x4/Jso+IU2R3iLxSMJ2MAh+CY
YAAAAhAM8elf2XwkTxqk2BecXGp9Vg5a+2Dnj2NU/m3zlB9fXjAAAAG1dlbGwga25vd24g
a2V5IGZvciBzc3NkLWNpLgECAwQ=
-----END OPENSSH PRIVATE KEY-----
1 change: 1 addition & 0 deletions data/ssh-keys/hosts/master.keycloak.test.rsa_key.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEiKoBtUHcQQwhKZHkAYOHvwXn9MriX5OuU5O+fJ7X+fHiS/82/YLdQM2xgQ2x4/Jso+IU2R3iLxSMJ2MAh+CYY= Well known key for sssd-ci.
21 changes: 21 additions & 0 deletions docker-compose.keycloak.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
keycloak:
image: ${REGISTRY}/ci-keycloak:${TAG}
container_name: keycloak
hostname: master.keycloak.test
dns: 172.16.100.2
env_file: ./env.containers
cap_add:
- SYS_ADMIN
- SYS_PTRACE
- AUDIT_WRITE
- AUDIT_CONTROL
- NET_ADMIN
- SYS_CHROOT
security_opt:
- apparmor=unconfined
- label=disable
- seccomp=unconfined
networks:
sssd:
ipv4_address: 172.16.100.70
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ perfoming an `ldapsearch`).
| client | `172.16.100.40` | `client.test` | Client machine with configured SSSD |
| nfs | `172.16.100.50` | `nfs.test` | NFS server |
| kdc | `172.16.100.60` | `kdc.test` | Kerberos KDC |
| keycloak | `172.16.100.70` | `master.keycloak.test` | Keycloak IdP |

## Available user accounts

Expand Down Expand Up @@ -278,6 +279,7 @@ are:
base-ground --> base-samba
base-ground --> base-nfs
base-ground --> base-kdc
base-ground --> base-keycloak
base-ldap --> base-ipa
base-ldap --> ldap
Expand All @@ -292,4 +294,6 @@ are:
base-nfs --> nfs
base-kdc --> kdc
base-keycloak --> keycloak
```
5 changes: 5 additions & 0 deletions src/ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ service: {
fqn: kdc.test,
master_password: Secret123
},
keycloak: {
domain: keycloak.test,
fqn: master.keycloak.test,
admin_password: Secret123
},
ad: {
domain: ad.test,
hostname: 'dc',
Expand Down
7 changes: 7 additions & 0 deletions src/ansible/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ all:
base_kdc:
hosts:
base-kdc
base_keycloak:
hosts:
base-keycloak
base_ground:
hosts:
base-ground
Expand Down Expand Up @@ -62,6 +65,10 @@ all:
hosts:
kdc.test:
ansible_host: sssd-wip-kdc
keycloak:
hosts:
master.keycloak.test:
ansible_host: sssd-wip-keycloak
vars:
ansible_connection: podman
ansible_python_interpreter: /usr/bin/python3
Expand Down
5 changes: 5 additions & 0 deletions src/ansible/playbook_image_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
roles:
- kdc

- hosts: master.keycloak.test
gather_facts: no
roles:
- keycloak

- hosts: services
gather_facts: no
roles:
Expand Down
9 changes: 9 additions & 0 deletions src/ansible/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,12 @@
- { src: 'ci.id_rsa', dest: 'id_rsa' }
- { src: 'ci.id_rsa.pub', dest: 'authorized_keys' }
- { src: 'ci.id_rsa.pub', dest: 'id_rsa.pub' }

- name: Copy CA certificate to local pki anchors
copy:
src: /data/certs/ca.crt
dest: "{{ ca_trust_dir }}"
remote_src: yes

- name: Update system CA trusts to pick up new certificate
command: "{{ ca_trust_update }}"
2 changes: 2 additions & 0 deletions src/ansible/roles/facts/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
krb5kdc: krb5-kdc.service
sshd: ssh.service
passkey_support: No
ca_trust_dir: /etc/ssl/certs
ca_trust_update: update-ca-certificates
2 changes: 2 additions & 0 deletions src/ansible/roles/facts/tasks/Fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
buildroot: yes
debuginfo: yes
passkey_support: Yes
ca_trust_dir: /etc/pki/ca-trust/source/anchors/
ca_trust_update: update-ca-trust
2 changes: 2 additions & 0 deletions src/ansible/roles/facts/tasks/Ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
krb5kdc: krb5-kdc.service
sshd: ssh.service
passkey_support: Yes
ca_trust_dir: /etc/ssl/certs
ca_trust_update: update-ca-certificates
1 change: 1 addition & 0 deletions src/ansible/roles/keycloak/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
base_url: https://github.com/keycloak/keycloak/releases/download
118 changes: 118 additions & 0 deletions src/ansible/roles/keycloak/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
- name: Get Keycloak latest version info
uri:
url: https://api.github.com/repos/keycloak/keycloak/releases/latest
method: GET
return_content: yes
status_code: 200
body_format: json
register: result

- name: Set keycloak_url fact
set_fact:
keycloak_url: "{{ base_url }}/{{ result.json.tag_name }}/keycloak-{{ result.json.tag_name }}.tar.gz"

- name: Print keycloak_url
debug:
msg: "keycloak_url={{ keycloak_url }}"

- name: Create Keycloak user/group
user:
name: keycloak
home: /opt/keycloak
system: yes
create_home: yes

- name: Download software zipfile
get_url:
url: "{{ keycloak_url }}"
dest: /tmp/keycloak.tgz

- name: Unzip software
unarchive:
remote_src: yes
src: /tmp/keycloak.tgz
dest: /opt/keycloak
owner: keycloak
group: keycloak
extra_opts:
- --strip-components=1

- name: Change ownership of files in /data/certs
file:
path: /data/certs/master.keycloak.test.key
mode: 0644

- name: Add CA certificate to keystore
shell: |
keytool -noprompt -import \
-keystore /data/certs/master.keycloak.test.keystore \
-file /data/certs/ca.crt \
-alias ca.crt \
-trustcacerts -storepass {{ service.keycloak.admin_password }}
args:
creates: /data/certs/master.keycloak.test.keystore

- name: Add Keycloak certificate to keystore
shell: |
keytool -noprompt -import \
-keystore /data/certs/master.keycloak.test.keystore \
-file /data/certs/master.keycloak.test.crt \
-alias master.keycloak.test.crt \
-trustcacerts -storepass {{ service.keycloak.admin_password }}
- name: Run build step for Keycloak
shell: |
su - keycloak -c '''
export KEYCLOAK_ADMIN=admin
export KEYCLOAK_ADMIN_PASSWORD={{ service.keycloak.admin_password }}
export KC_HOSTNAME=$(hostname):8443
export KC_HTTPS_CERTIFICATE_FILE=/data/certs/master.keycloak.test.crt
export KC_HTTPS_CERTIFICATE_KEY_FILE=/data/certs/master.keycloak.test.key
export KC_HTTPS_TRUST_STORE_FILE=/data/certs/master.keycloak.test.keystore
export KC_HTTPS_TRUST_STORE_PASSWORD={{ service.keycloak.admin_password }}
export KC_HTTP_RELATIVE_PATH=/auth
/opt/keycloak/bin/kc.sh build
'''
- name: Create Keycloak service env file
copy:
content: |
KEYCLOAK_ADMIN=admin
KEYCLOAK_ADMIN_PASSWORD={{ service.keycloak.admin_password }}
KC_HOSTNAME={{ inventory_hostname }}
KC_HTTPS_CERTIFICATE_FILE=/data/certs/master.keycloak.test.crt
KC_HTTPS_CERTIFICATE_KEY_FILE=/data/certs/master.keycloak.test.key
KC_HTTPS_TRUST_STORE_FILE=/data/certs/master.keycloak.test.keystore
KC_HTTPS_TRUST_STORE_PASSWORD={{ service.keycloak.admin_password }}
KC_HTTP_RELATIVE_PATH=/auth
dest: /etc/keycloak.env

- name: Create systemd Keycloak service file
copy:
content: |
[Unit]
Description=Keycloak Server
After=network.target
[Service]
Type=idle
EnvironmentFile=/etc/keycloak.env
User=keycloak
Group=keycloak
ExecStart=/opt/keycloak/bin/kc.sh start
TimeoutStartSec=600
TimeoutStopSec=600
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/keycloak.service

- name: Reload systemd to pickup changes added for Keycloak
systemd:
daemon_reload: yes

- name: Enable Keycloak service
systemd:
name: keycloak
enabled: yes
Loading

0 comments on commit 5aa154c

Please sign in to comment.