mirror of
https://github.com/ansible-middleware/keycloak.git
synced 2026-03-27 13:53:04 +00:00
Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d57057272 | ||
|
|
fddfa9a493 | ||
|
|
5cbe905dda | ||
|
|
4e6ea2f1ca | ||
|
|
28ff78d809 | ||
|
|
9365d38162 | ||
|
|
d3f9b0ca86 | ||
|
|
bada6f4073 | ||
|
|
b91c9e17fc | ||
|
|
b974bf1967 | ||
|
|
9ee6788f98 | ||
|
|
c166c643fc | ||
|
|
abd922417c | ||
|
|
5a45d1f4f8 | ||
|
|
6091477294 | ||
|
|
63f31fe258 | ||
|
|
fc780599b0 | ||
|
|
494a1c518b | ||
|
|
f736ad5632 | ||
|
|
b0a11013fa | ||
|
|
10ff1763c1 | ||
|
|
85b0a2549a | ||
|
|
d854791183 | ||
|
|
a67081a68d | ||
|
|
8173be4b58 | ||
|
|
6270762a3a | ||
|
|
5828c0a7bb | ||
|
|
e773e12e24 | ||
|
|
33e80a0cd4 | ||
|
|
bf26c727a8 | ||
|
|
d5bf0a195a | ||
|
|
c5b38e8bac | ||
|
|
266f2bc00b | ||
|
|
cfdc043770 | ||
|
|
707d8cfb11 | ||
|
|
f5cd6d8061 | ||
|
|
b88c43933c | ||
|
|
0bc81cc781 | ||
|
|
60c5a42ae4 | ||
|
|
2073c90e1d | ||
|
|
ffd146d392 | ||
|
|
78f225b10c | ||
|
|
a043021e48 | ||
|
|
a0ea9c62a7 | ||
|
|
b90684a44a | ||
|
|
73bbca9fc1 | ||
|
|
124c8ae0ad | ||
|
|
bce963923d | ||
|
|
147ee5214e | ||
|
|
042089d100 | ||
|
|
ac62d2e43d | ||
|
|
662918f5f8 | ||
|
|
e0664d53a9 | ||
|
|
20f321c628 | ||
|
|
9cafd431fb | ||
|
|
f74d504b53 | ||
|
|
c853df5745 | ||
|
|
a800517422 | ||
|
|
cbb8ed4993 |
27
.ansible-lint
Normal file
27
.ansible-lint
Normal file
@@ -0,0 +1,27 @@
|
||||
# .ansible-lint
|
||||
exclude_paths:
|
||||
- .cache/
|
||||
- .github/
|
||||
- molecule/
|
||||
- .ansible-lint
|
||||
- .yamllint
|
||||
|
||||
rulesdir:
|
||||
- ../../ansible-lint-custom-rules/rules/
|
||||
|
||||
enable_list:
|
||||
- fqcn-builtins # opt-in
|
||||
- no-log-password # opt-in
|
||||
|
||||
warn_list:
|
||||
- role_vars_start_with_role_name
|
||||
- vars_in_vars_files_have_valid_names
|
||||
- vars_should_not_be_used
|
||||
- experimental
|
||||
- ignore-errors
|
||||
- no-handler
|
||||
- fqcn-builtins
|
||||
- no-log-password
|
||||
|
||||
use_default_rules: true
|
||||
parseable: true
|
||||
48
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
48
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
name: 🐛 Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
|
||||
##### SUMMARY
|
||||
<!-- Explain the problem briefly -->
|
||||
|
||||
|
||||
##### ISSUE TYPE
|
||||
- Bug Report
|
||||
|
||||
|
||||
##### ANSIBLE VERSION
|
||||
<!-- Paste, BELOW THIS COMMENT, verbatim output from "ansible --version"-->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
##### COLLECTION VERSION
|
||||
<!-- Paste, BELOW THIS COMMENT, verbatim output from "ansible-galaxy collection list"-->
|
||||
<!-- If using virtual environments or execution environments, remember to activate them-->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
##### STEPS TO REPRODUCE
|
||||
<!-- List the steps to reproduce the problem, using a minimal test-case. -->
|
||||
|
||||
<!-- Paste example playbook below -->
|
||||
```yaml
|
||||
|
||||
```
|
||||
|
||||
##### EXPECTED RESULTS
|
||||
<!-- What did you expect to happen when running the steps above? -->
|
||||
|
||||
|
||||
##### ACTUAL RESULTS
|
||||
<!-- What actually happened? If possible run with extra verbosity (-vvvv) and diff (--diff) -->
|
||||
<!-- Please also include check mode (--check --diff) output if the API returns an error -->
|
||||
<!-- Be sure to mask any sensitive information -->
|
||||
|
||||
<!--- Paste verbatim command output between quotes below -->
|
||||
```
|
||||
|
||||
```
|
||||
12
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
12
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
name: ✨ Feature request
|
||||
about: Suggest an idea for this project
|
||||
|
||||
---
|
||||
|
||||
##### SUMMARY
|
||||
<!--- Explain the problem briefly -->
|
||||
|
||||
|
||||
##### ISSUE TYPE
|
||||
- Feature Idea
|
||||
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@@ -27,13 +27,20 @@ jobs:
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install yamllint 'molecule[docker]~=3.5.2' ansible-core flake8 ansible-lint voluptuous
|
||||
pip install -r ansible_collections/middleware_automation/keycloak/requirements.txt
|
||||
|
||||
- name: Install ansible-lint custom rules
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ansible-middleware/ansible-lint-custom-rules
|
||||
path: ansible_collections/ansible-lint-custom-rules/
|
||||
|
||||
- name: Create default collection path
|
||||
run: |
|
||||
mkdir -p /home/runner/.ansible/collections/ansible_collections
|
||||
|
||||
- name: Run sanity tests
|
||||
run: ansible-test sanity --docker -v --color --python ${{ matrix.python_version }}
|
||||
run: ansible-test sanity --docker -v --color --python ${{ matrix.python_version }} --exclude changelogs/fragments/.gitignore
|
||||
working-directory: ./ansible_collections/middleware_automation/keycloak
|
||||
|
||||
- name: Run molecule test
|
||||
|
||||
110
.github/workflows/docs.yml
vendored
Normal file
110
.github/workflows/docs.yml
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
---
|
||||
name: Documentation
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "[0-9]+.[0-9]+.[0-9]+"
|
||||
|
||||
env:
|
||||
COLORTERM: 'yes'
|
||||
TERM: 'xterm-256color'
|
||||
PYTEST_ADDOPTS: '--color=yes'
|
||||
|
||||
jobs:
|
||||
docs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'ansible-middleware/keycloak'
|
||||
permissions:
|
||||
actions: write
|
||||
checks: write
|
||||
contents: write
|
||||
deployments: write
|
||||
packages: write
|
||||
pages: write
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: ansible_collections/middleware_automation/keycloak
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.9
|
||||
|
||||
- name: Install doc dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r ansible_collections/middleware_automation/keycloak/docs/requirements.txt
|
||||
pip install -r ansible_collections/middleware_automation/keycloak/requirements.txt
|
||||
sudo apt install -y sed hub
|
||||
|
||||
- name: Create default collection path
|
||||
run: |
|
||||
mkdir -p /home/runner/.ansible/collections/ansible_collections
|
||||
|
||||
- name: Create doc directories and resources
|
||||
run: |
|
||||
mkdir -p ./docs/plugins ./docs/roles
|
||||
cat ./docs/roles.rst.template > ./docs/roles/index.rst
|
||||
antsibull-docs collection --use-current --squash-hierarchy --dest-dir docs/plugins middleware_automation.keycloak
|
||||
for role_readme in roles/*/README.md; do
|
||||
ln -f -s ../../$role_readme ./docs/roles/$(basename $(dirname $role_readme)).md
|
||||
echo " $(basename $(dirname $role_readme))" >> ./docs/roles/index.rst
|
||||
done
|
||||
working-directory: ansible_collections/middleware_automation/keycloak
|
||||
|
||||
- name: Scan PR merges from latest tag
|
||||
run: |
|
||||
TYPES=("minor_changes" "major_changes" "bugfixes" "deprecated_features" "removed_features" "breaking_changes")
|
||||
TAG=$(git describe --abbrev=0 --tags)
|
||||
if [[ "${{github.ref}}" == "refs/heads/main" ]]; then
|
||||
PRS=($(comm -12 <(git log --oneline ${TAG}.. --format="tformat:%H" | sort ) <(hub pr list -s all -f '%sm%n' --color=never | sort )))
|
||||
else
|
||||
PREV_TAG=$(git tag | grep -P "^[0-9]+[.][0-9]+[.][0-9]+$" | sort --version-sort -r | head -n2 | grep -v "${TAG}")
|
||||
PRS=($(comm -12 <(git log --oneline ${PREV_TAG}..${TAG} --format="tformat:%H" | sort ) <(hub pr list -s all -f '%sm%n' --color=never | sort )))
|
||||
fi
|
||||
if [[ ${#PRS[@]} > 0 ]]; then
|
||||
IFS=$'\n' FRAGMENTS=($(hub pr list -s all -f '%sm~%I~%L~%t~%n' --color=never | grep -P "$(echo "^(${PRS[@]})" | tr ' ' '|')"))
|
||||
for frag in "${FRAGMENTS[@]}"; do
|
||||
PR=$(echo $frag|cut -d~ -f2)
|
||||
type="$(echo $frag|cut -d~ -f3)"
|
||||
msg="$(echo $frag|cut -d~ -f4|sed 's/`/``/g')"
|
||||
if [[ "${TYPES[*]}" =~ "${type}" ]]; then
|
||||
echo -e "$type:\n - >\n $msg \`#${PR} <https://github.com/ansible-middleware/keycloak/pull/${PR}>\`_" \
|
||||
> changelogs/fragments/${PR}.yaml
|
||||
fi
|
||||
done
|
||||
antsibull-changelog lint -vvv
|
||||
if [[ "${{github.ref}}" == "refs/heads/main" ]]; then
|
||||
antsibull-changelog release --version "$(grep version galaxy.yml | awk -F'"' '{ print $2 }')-devel" -v
|
||||
fi
|
||||
fi
|
||||
working-directory: ansible_collections/middleware_automation/keycloak
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Run sphinx
|
||||
run: |
|
||||
sphinx-build -M html . _build -v
|
||||
working-directory: ansible_collections/middleware_automation/keycloak/docs/
|
||||
|
||||
- name: Commit docs
|
||||
run: |
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
git stash
|
||||
git checkout gh-pages
|
||||
rm -rf $(basename ${GITHUB_REF})
|
||||
mv docs/_build/html $(basename ${GITHUB_REF})
|
||||
ln --force --no-dereference --symbolic main latest
|
||||
git show origin/main:docs/_gh_include/header.inc > index.html
|
||||
(echo main; echo latest; dirname *.*.*/index.html | sort --version-sort --reverse) | xargs -I@@ -n1 echo '<li class="toctree-l1"><a class="reference internal" href="@@/">@@</a></li>' >> index.html
|
||||
git show origin/main:docs/_gh_include/footer.inc >> index.html
|
||||
git add $(basename ${GITHUB_REF}) latest index.html
|
||||
git commit -m "Update docs for $(basename ${GITHUB_REF})" || true
|
||||
git push origin gh-pages
|
||||
working-directory: ansible_collections/middleware_automation/keycloak/
|
||||
95
.github/workflows/release.yml
vendored
95
.github/workflows/release.yml
vendored
@@ -1,47 +1,112 @@
|
||||
---
|
||||
name: Release collection
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*.*.*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'ansible-middleware/keycloak'
|
||||
permissions:
|
||||
actions: write
|
||||
checks: write
|
||||
contents: write
|
||||
deployments: write
|
||||
packages: write
|
||||
pages: write
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Get Tag Version
|
||||
|
||||
- name: Get current version
|
||||
id: get_version
|
||||
run: echo ::set-output name=TAG_VERSION::${GITHUB_REF#refs/tags/}
|
||||
run: echo "::set-output name=TAG_VERSION::$(grep version galaxy.yml | awk -F'"' '{ print $2 }')"
|
||||
|
||||
- name: Check if tag exists
|
||||
id: check_tag
|
||||
run: echo "::set-output name=TAG_EXISTS::$(git tag | grep ${{ steps.get_version.outputs.TAG_VERSION }})"
|
||||
|
||||
- name: Fail if tag exists
|
||||
if: ${{ steps.get_version.outputs.TAG_VERSION == steps.check_tag.outputs.TAG_EXISTS }}
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release tag already exists')
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install ansible-core
|
||||
pip install ansible-core antsibull
|
||||
sudo apt install -y sed hub
|
||||
|
||||
- name: Build collection
|
||||
run: |
|
||||
ansible-galaxy collection build .
|
||||
- name: Publish Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
|
||||
- name: Scan PR merges from latest tag
|
||||
run: |
|
||||
TYPES=("minor_changes" "major_changes" "bugfixes" "deprecated_features" "removed_features" "breaking_changes")
|
||||
TAG=$(git describe --abbrev=0 --tags)
|
||||
PRS=($(comm -12 <(git log --oneline ${TAG}.. --format="tformat:%H" | sort ) <(hub pr list -s all -f '%sm%n' --color=never | sort )))
|
||||
IFS=$'\n' FRAGMENTS=($(hub pr list -s all -f '%sm~%I~%L~%t~%n' --color=never| grep -P "$(echo "^(${PRS[@]})" | tr ' ' '|')"))
|
||||
for frag in "${FRAGMENTS[@]}"; do
|
||||
PR=$(echo $frag|cut -d~ -f2)
|
||||
type="$(echo $frag|cut -d~ -f3)"
|
||||
msg="$(echo $frag|cut -d~ -f4|sed 's/`/``/g')"
|
||||
if [[ "${TYPES[*]}" =~ "${type}" ]]; then
|
||||
echo -e "$type:\n - >\n $msg \`#${PR} <https://github.com/ansible-middleware/keycloak/pull/${PR}>\`_" \
|
||||
> changelogs/fragments/${PR}.yaml
|
||||
fi
|
||||
done
|
||||
antsibull-changelog lint -vvv
|
||||
antsibull-changelog generate
|
||||
antsibull-changelog release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
files: "*.tar.gz"
|
||||
body: "Release ${{ steps.get_version.outputs.TAG_VERSION }}"
|
||||
|
||||
- name: Commit changelogs
|
||||
run: |
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
git diff --minimal --output-indicator-new=' ' -U0 --no-indent-heuristic CHANGELOG.rst | grep "^ "| sed -e 's/`\(#[0-9]\+\) <.*_/\1/g' > gh-release.md
|
||||
git add CHANGELOG.rst changelogs/changelog.yaml
|
||||
git commit -m "Update changelog for release ${{ steps.get_version.outputs.TAG_VERSION }}" || true
|
||||
git push origin
|
||||
|
||||
- name: Publish collection
|
||||
env:
|
||||
ANSIBLE_GALAXY_API_KEY: ${{ secrets.ANSIBLE_GALAXY_API_KEY }}
|
||||
run: |
|
||||
ansible-galaxy collection publish *.tar.gz --api-key $ANSIBLE_GALAXY_API_KEY
|
||||
|
||||
- name: Create release tag
|
||||
run: |
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
git tag -a ${{ steps.get_version.outputs.TAG_VERSION }} -m "Release v${{ steps.get_version.outputs.TAG_VERSION }}" || true
|
||||
git push origin --tags
|
||||
|
||||
- name: Publish Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.get_version.outputs.TAG_VERSION }}
|
||||
files: "*.tar.gz"
|
||||
body_path: gh-release.md
|
||||
|
||||
dispatch:
|
||||
needs: release
|
||||
strategy:
|
||||
matrix:
|
||||
repo: ['ansible-middleware/cross-dc-rhsso-demo', 'ansible-middleware/flange-demo']
|
||||
repo: ['ansible-middleware/cross-dc-rhsso-demo', 'ansible-middleware/flange-demo', 'ansible-middleware/ansible-middleware-ee']
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Repository Dispatch
|
||||
@@ -49,5 +114,5 @@ jobs:
|
||||
with:
|
||||
token: ${{ secrets.TRIGGERING_PAT }}
|
||||
repository: ${{ matrix.repo }}
|
||||
event-type: "Dependency released - Keycloak"
|
||||
event-type: "Dependency released - Keycloak v${{ steps.get_version.outputs.TAG_VERSION }}"
|
||||
client-payload: '{ "github": ${{toJson(github)}} }'
|
||||
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,2 +1,11 @@
|
||||
*.tar.gz
|
||||
*.zip
|
||||
.tmp
|
||||
.cache
|
||||
docs/plugins/
|
||||
docs/roles/
|
||||
docs/_build/
|
||||
.pytest_cache/
|
||||
.mypy_cache/
|
||||
*.retry
|
||||
changelogs/.plugin-cache.yaml
|
||||
|
||||
49
CHANGELOG.rst
Normal file
49
CHANGELOG.rst
Normal file
@@ -0,0 +1,49 @@
|
||||
============================================
|
||||
middleware_automation.keycloak Release Notes
|
||||
============================================
|
||||
|
||||
.. contents:: Topics
|
||||
|
||||
This changelog describes changes after version 0.2.6.
|
||||
|
||||
v1.0.2
|
||||
======
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- Make ``keycloak_admin_password`` a default with assert (was: role variable) `#26 <https://github.com/ansible-middleware/keycloak/pull/26>`_
|
||||
- Simplify dependency install logic and reduce play execution time `#19 <https://github.com/ansible-middleware/keycloak/pull/19>`_
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- Set ``keycloak_frontend_url`` default according to other defaults `#25 <https://github.com/ansible-middleware/keycloak/pull/25>`_
|
||||
|
||||
v1.0.1
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
Minor enhancements, bug and documentation fixes.
|
||||
|
||||
|
||||
Major Changes
|
||||
-------------
|
||||
|
||||
- Apply latest cumulative patch of RH-SSO automatically when new parameter ``keycloak_rhsso_apply_patches`` is ``true`` `#18 <https://github.com/ansible-middleware/keycloak/pull/18>`_
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- Clustered installs now perform database initialization on first node to avoid locking issues `#17 <https://github.com/ansible-middleware/keycloak/pull/17>`_
|
||||
|
||||
v1.0.0
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
This is the first stable release of the ``middleware_automation.keycloak`` collection.
|
||||
|
||||
14
CONTRIBUTING.md
Normal file
14
CONTRIBUTING.md
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
## Contributor's Guidelines
|
||||
|
||||
- All YAML files named with `.yml` extension
|
||||
- Use spaces around jinja variables. `{{ var }}` over `{{var}}`
|
||||
- Variables that are internal to the role should be lowercase and start with the role name
|
||||
- Keep roles self contained - Roles should avoid including tasks from other roles when possible
|
||||
- Plays should do nothing more than include a list of roles, except where `pre_tasks` and `post_tasks` are required, when possible
|
||||
- Separators - Use valid names, ie. underscores (e.g. `my_role` `my_playbook`) not dashes (`my-role`)
|
||||
- Paths - When defining paths, do not include trailing slashes (e.g. `my_path: /foo` not `my_path: /foo/`); when concatenating paths, follow the same convention (e.g. `{{ my_path }}/bar` not `{{ my_path }}bar`)
|
||||
- Indentation - Use 2 spaces for each indent
|
||||
- `vars/` vs `defaults/` - internal or interpolated variables that don't need to change or be overridden by user go in `vars/`, those that a user would likely override, go under `defaults/` directory
|
||||
- All role arguments have a specification in `meta/argument_specs.yml`
|
||||
- All playbooks/roles should be focused on compatibility with Ansible Automation Platform
|
||||
22
README.md
22
README.md
@@ -1,4 +1,4 @@
|
||||
# Ansible Collection - keycloak
|
||||
# Ansible Collection - middleware_automation.keycloak
|
||||
|
||||
[](https://github.com/ansible-middleware/keycloak/actions/workflows/ci.yml)
|
||||
|
||||
@@ -13,6 +13,7 @@ This collection has been tested against following Ansible versions: **>=2.9.10**
|
||||
Plugins and modules within a collection may be tested with only specific Ansible versions. A collection may contain metadata that identifies these versions.
|
||||
<!--end requires_ansible-->
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
### Installing the Collection from Ansible Galaxy
|
||||
@@ -49,17 +50,17 @@ A requirement file is provided to install:
|
||||
|
||||
### Install Playbook
|
||||
|
||||
* [`playbooks/keycloak.yml`](playbooks/keycloak.yml) installs the upstream(Keycloak) based on the defined variables.
|
||||
* [`playbooks/rhsso.yml`](playbooks/rhsso.yml) installs Red Hat Single Sign-On(RHSSO) based on defined variables.
|
||||
* [`playbooks/keycloak.yml`](https://github.com/ansible-middleware/keycloak/blob/main/playbooks/keycloak.yml) installs the upstream(Keycloak) based on the defined variables.
|
||||
* [`playbooks/rhsso.yml`](https://github.com/ansible-middleware/keycloak/blob/main/playbooks/rhsso.yml) installs Red Hat Single Sign-On(RHSSO) based on defined variables.
|
||||
|
||||
Both playbooks include the `keycloak` role, with different settings, as described in the following sections.
|
||||
|
||||
For service configuration details, refer to the [keycloak role README](roles/keycloak/README.md).
|
||||
For full service configuration details, refer to the [keycloak role README](https://github.com/ansible-middleware/keycloak/blob/main/roles/keycloak/README.md).
|
||||
|
||||
|
||||
### Choosing between upstream project (Keycloak) and Red Hat Single Sign-On (RHSSO)
|
||||
|
||||
The general flag `keycloak_rhsso_enable` controls what to install between upstream(Keycloak, when `False`) or Red Hat Single Sign-On (when `True`).
|
||||
The general flag `keycloak_rhsso_enable` controls what to install between upstream (Keycloak, when `False`) or Red Hat Single Sign-On (when `True`).
|
||||
The default value for the flag if `True` when Red Hat Network credentials are defined, `False` otherwise.
|
||||
|
||||
|
||||
@@ -133,15 +134,15 @@ ansible-playbook -i <ansible_hosts> -e @rhn-creds.yml playbooks/keycloak.yml -e
|
||||
|
||||
### Config Playbook
|
||||
|
||||
[`playbooks/keycloak-realm.yml`](playbooks/keycloak-realm.yml) creates provided realm, user federation(s), client(s), client role(s) and client user(s) if they don't exist.
|
||||
[`playbooks/keycloak_realm.yml`](https://github.com/ansible-middleware/keycloak/blob/main/playbooks/keycloak_realm.yml) creates or updates provided realm, user federation(s), client(s), client role(s) and client user(s).
|
||||
|
||||
|
||||
### Example configuration command
|
||||
|
||||
Execute the following command from the source root directory
|
||||
Execute the following command from the source root directory:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i <ansible_hosts> playbooks/keycloak-realm.yml -e keycloak_admin_password=<changeme> -e keycloak_realm=test
|
||||
ansible-playbook -i <ansible_hosts> playbooks/keycloak_realm.yml -e keycloak_admin_password=<changeme> -e keycloak_realm=test
|
||||
```
|
||||
|
||||
- `keycloak_admin_password` password for the administration console user account.
|
||||
@@ -153,8 +154,11 @@ ansible-playbook -i <ansible_hosts> playbooks/keycloak-realm.yml -e keycloak_adm
|
||||
localhost ansible_connection=local
|
||||
```
|
||||
|
||||
For configuration details, refer to the [keycloak_realm role README](roles/keycloak_realm/README.md).
|
||||
For full configuration details, refer to the [keycloak_realm role README](https://github.com/ansible-middleware/keycloak/blob/main/roles/keycloak_realm/README.md).
|
||||
|
||||
## Support
|
||||
|
||||
Keycloak collection v1.0.0 is a Beta release and for [Technical Preview](https://access.redhat.com/support/offerings/techpreview). If you have any issues or questions related to collection, please don't hesitate to contact us on Ansible-middleware-core@redhat.com or open an issue on https://github.com/ansible-middleware/keycloak/issues
|
||||
|
||||
## License
|
||||
|
||||
|
||||
40
changelogs/changelog.yaml
Normal file
40
changelogs/changelog.yaml
Normal file
@@ -0,0 +1,40 @@
|
||||
ancestor: 0.2.6
|
||||
releases:
|
||||
1.0.0:
|
||||
changes:
|
||||
release_summary: 'This is the first stable release of the ``middleware_automation.keycloak``
|
||||
collection.
|
||||
|
||||
'
|
||||
release_date: '2022-03-04'
|
||||
1.0.1:
|
||||
changes:
|
||||
major_changes:
|
||||
- Apply latest cumulative patch of RH-SSO automatically when new parameter ``keycloak_rhsso_apply_patches``
|
||||
is ``true`` `#18 <https://github.com/ansible-middleware/keycloak/pull/18>`_
|
||||
minor_changes:
|
||||
- Clustered installs now perform database initialization on first node to avoid
|
||||
locking issues `#17 <https://github.com/ansible-middleware/keycloak/pull/17>`_
|
||||
release_summary: 'Minor enhancements, bug and documentation fixes.
|
||||
|
||||
'
|
||||
release_date: '2022-03-11'
|
||||
1.0.2:
|
||||
changes:
|
||||
bugfixes:
|
||||
- 'Set ``keycloak_frontend_url`` default according to other defaults `#25 <https://github.com/ansible-middleware/keycloak/pull/25>`_
|
||||
|
||||
'
|
||||
minor_changes:
|
||||
- 'Make ``keycloak_admin_password`` a default with assert (was: role variable)
|
||||
`#26 <https://github.com/ansible-middleware/keycloak/pull/26>`_
|
||||
|
||||
'
|
||||
- 'Simplify dependency install logic and reduce play execution time `#19 <https://github.com/ansible-middleware/keycloak/pull/19>`_
|
||||
|
||||
'
|
||||
fragments:
|
||||
- 19.yaml
|
||||
- 25.yaml
|
||||
- 26.yaml
|
||||
release_date: '2022-04-01'
|
||||
32
changelogs/config.yaml
Normal file
32
changelogs/config.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
changelog_filename_template: ../CHANGELOG.rst
|
||||
changelog_filename_version_depth: 0
|
||||
changes_file: changelog.yaml
|
||||
changes_format: combined
|
||||
ignore_other_fragment_extensions: true
|
||||
keep_fragments: false
|
||||
mention_ancestor: true
|
||||
new_plugins_after_name: removed_features
|
||||
notesdir: fragments
|
||||
prelude_section_name: release_summary
|
||||
prelude_section_title: Release Summary
|
||||
sections:
|
||||
- - major_changes
|
||||
- Major Changes
|
||||
- - minor_changes
|
||||
- Minor Changes
|
||||
- - breaking_changes
|
||||
- Breaking Changes / Porting Guide
|
||||
- - deprecated_features
|
||||
- Deprecated Features
|
||||
- - removed_features
|
||||
- Removed Features
|
||||
- - security_fixes
|
||||
- Security Fixes
|
||||
- - bugfixes
|
||||
- Bugfixes
|
||||
- - known_issues
|
||||
- Known Issues
|
||||
title: middleware_automation.keycloak
|
||||
trivial_section_name: trivial
|
||||
use_fqcn: true
|
||||
2
changelogs/fragments/.gitignore
vendored
Normal file
2
changelogs/fragments/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
1
docs/CHANGELOG.rst
Symbolic link
1
docs/CHANGELOG.rst
Symbolic link
@@ -0,0 +1 @@
|
||||
../CHANGELOG.rst
|
||||
1
docs/README.md
Symbolic link
1
docs/README.md
Symbolic link
@@ -0,0 +1 @@
|
||||
../README.md
|
||||
21
docs/_gh_include/footer.inc
Normal file
21
docs/_gh_include/footer.inc
Normal file
@@ -0,0 +1,21 @@
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
||||
</div>
|
||||
<hr/>
|
||||
<div role="contentinfo">
|
||||
<p>© Copyright 2022, Red Hat, Inc.</p>
|
||||
</div>
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
43
docs/_gh_include/header.inc
Normal file
43
docs/_gh_include/header.inc
Normal file
@@ -0,0 +1,43 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Keycloak Ansible Collection documentation index</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="https://ansible-middleware.github.io/keycloak/main/_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="https://ansible-middleware.github.io/keycloak/main/_static/css/theme.css" type="text/css" />
|
||||
<link rel="stylesheet" href="https://ansible-middleware.github.io/keycloak/main/_static/ansible-basic-sphinx-ext.css" type="text/css" />
|
||||
<script data-url_root="./" id="documentation_options" src="https://ansible-middleware.github.io/keycloak/main/_static/documentation_options.js"></script>
|
||||
<script src="https://ansible-middleware.github.io/keycloak/main/_static/jquery.js"></script>
|
||||
<script src="https://ansible-middleware.github.io/keycloak/main/_static/underscore.js"></script>
|
||||
<script src="https://ansible-middleware.github.io/keycloak/main/_static/doctools.js"></script>
|
||||
<script src="https://ansible-middleware.github.io/keycloak/main/_static/js/theme.js"></script>
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="#" class="icon icon-home"> Keycloak Ansible Collection</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="#" class="icon icon-home"></a> »</li>
|
||||
<li>Welcome to Keycloak Collection documentation</li>
|
||||
<li class="wy-breadcrumbs-aside"></li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div itemprop="articleBody">
|
||||
<section id="welcome-to-keycloak-collection-documentation">
|
||||
<h1>Welcome to Keycloak Collection documentation<a class="headerlink" href="#welcome-to-keycloak-collection-documentation" title="Permalink to this headline"></a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
<p class="caption" role="heading"><span class="caption-text">Pick collection version:</span></p>
|
||||
<ul>
|
||||
170
docs/conf.py
Normal file
170
docs/conf.py
Normal file
@@ -0,0 +1,170 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file does only contain a selection of the most common options. For a
|
||||
# full list see the documentation:
|
||||
# http://www.sphinx-doc.org/en/master/config
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
import datetime
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('../plugins/module_utils/'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'Keycloak Ansible Collection'
|
||||
copyright = '{y}, Red Hat, Inc.'.format(y=datetime.date.today().year)
|
||||
author = 'Red Hat, Inc.'
|
||||
|
||||
# The short X.Y version
|
||||
version = ''
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = ''
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'myst_parser',
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.intersphinx',
|
||||
'ansible_basic_sphinx_ext',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = ['.rst', '.md']
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path .
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.tmp']
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
highlight_language = 'YAML+Jinja'
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
html_theme_path = ['_themes']
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
# html_theme = 'alabaster'
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = []
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
#
|
||||
# The default sidebars (for documents that don't match any pattern) are
|
||||
# defined by theme itself. Builtin themes are using these templates by
|
||||
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
|
||||
# 'searchbox.html']``.
|
||||
#
|
||||
# html_sidebars = {}
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ---------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'KeycloakCollectionDoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'KeycloakCollection.tex', 'Red Hat Single Sign-On Ansible Collection Documentation',
|
||||
'Red Hat, Inc.', 'manual'),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for manual page output ------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'keycloakcollection', 'Red Hat Single Sign-On Ansible Collection Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output ----------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'KeycloakCollection', 'Red Hat Single Sign-On Ansible Collection Documentation',
|
||||
author, 'KeycloakCollection', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
# -- Extension configuration -------------------------------------------------
|
||||
|
||||
# -- Options for intersphinx extension ---------------------------------------
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'python': ('https://docs.python.org/2', None), 'ansible': ('https://docs.ansible.com/ansible/latest/', None)}
|
||||
1
docs/developing.md
Symbolic link
1
docs/developing.md
Symbolic link
@@ -0,0 +1 @@
|
||||
../CONTRIBUTING.md
|
||||
32
docs/index.rst
Normal file
32
docs/index.rst
Normal file
@@ -0,0 +1,32 @@
|
||||
.. Red Hat middleware_automation Keycloak Ansible Collection documentation main file
|
||||
|
||||
Welcome to Keycloak Collection documentation
|
||||
============================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: User documentation
|
||||
|
||||
README
|
||||
plugins/index
|
||||
roles/index
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Developer documentation
|
||||
|
||||
testing
|
||||
developing
|
||||
releasing
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: General
|
||||
|
||||
Changelog <CHANGELOG>
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`search`
|
||||
61
docs/releasing.md
Normal file
61
docs/releasing.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Collection Versioning Strategy
|
||||
|
||||
Each supported collection maintained by Ansible follows Semantic Versioning 2.0.0 (https://semver.org/), for example:
|
||||
Given a version number MAJOR.MINOR.PATCH, the following is incremented:
|
||||
|
||||
MAJOR version: when making incompatible API changes (see Feature Release scenarios below for examples)
|
||||
|
||||
MINOR version: when adding features or functionality in a backwards compatible manner, or updating testing matrix and/or metadata (deprecation)
|
||||
|
||||
PATCH version: when adding backwards compatible bug fixes or security fixes (strict).
|
||||
|
||||
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
|
||||
|
||||
The first version of a generally available supported collection on Ansible Automation Hub shall be version 1.0.0. NOTE: By default, all newly created collections may begin with a smaller default version of 0.1.0, and therefore a version of 1.0.0 should be explicitly stated by the collection maintainer.
|
||||
|
||||
## New content is added to an existing collection
|
||||
|
||||
Assuming the current release is 1.0.0, and a new module is ready to be added to the collection, the minor version would be incremented to 1.1.0. The change in the MINOR version indicates an additive change was made while maintaining backward compatibility for existing content within the collection.
|
||||
|
||||
|
||||
## New feature to existing plugin or role within a collection (backwards compatible)
|
||||
|
||||
Assuming the current release is 1.0.0, and new features for an existing module are ready for release . We would increment the MINOR version to 1.1.0. The change in the MINOR version indicates an additive change was made while maintaining backward compatibility for existing content within the collection.
|
||||
|
||||
|
||||
## Bug fix or security fix to existing content within a collection
|
||||
|
||||
Assuming the current release is 1.0.0 and a bug is fixed prior to the next minor release, the PATCH version would be incremented to 1.0.1. The patch indicates only a bug was fixed within a current version. The PATCH release does not contain new content, nor was functionality removed. Bug fixes may be included in a MINOR or MAJOR feature release if the timing allows, eliminating the need for a PATCH dedicated to the fix.
|
||||
|
||||
|
||||
## Breaking change to any content within a collection
|
||||
|
||||
Assuming the current release is 1.0.0, and a breaking change (API or module) is introduced for a user or developer. The MAJOR version would be incremented to 2.0.0.
|
||||
|
||||
Examples of breaking changes within a collection may include but are not limited to:
|
||||
|
||||
- Argspec changes for a module that require either inventory structure or playbook changes.
|
||||
- A change in the shape of either the inbound or returned payload of a filter plugin.
|
||||
- Changes to a connection plugin that require additional inventory parameters or ansible.cfg entries.
|
||||
- New functionality added to a module that changes the outcome of that module as released in previous versions.
|
||||
- The removal of plugins from a collection.
|
||||
|
||||
|
||||
## Content removed from a collection
|
||||
|
||||
Deleting a module or API is a breaking change. Please see the 'Breaking change' section for how to version this.
|
||||
|
||||
|
||||
## A typographical error was fixed in the documentation for a collection
|
||||
|
||||
A correction to the README would be considered a bug fix and the PATCH incremented. See 'Bug fix' above.
|
||||
|
||||
|
||||
## Documentation added/removed/modified within a collection
|
||||
|
||||
Only the PATCH version should be increased for a release that contains changes limited to revised documentation.
|
||||
|
||||
|
||||
## Release automation
|
||||
|
||||
New releases are triggered by annotated git tags named after semantic versioning. The automation publishes the built artifacts to ansible-galaxy and github releases page.
|
||||
5
docs/requirements.txt
Normal file
5
docs/requirements.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
antsibull>=0.17.0
|
||||
ansible-base>=2.10.12
|
||||
sphinx-rtd-theme
|
||||
git+https://github.com/felixfontein/ansible-basic-sphinx-ext
|
||||
myst-parser
|
||||
4
docs/roles.rst.template
Normal file
4
docs/roles.rst.template
Normal file
@@ -0,0 +1,4 @@
|
||||
Role Index
|
||||
==========
|
||||
|
||||
.. toctree::
|
||||
49
docs/testing.md
Normal file
49
docs/testing.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Testing
|
||||
|
||||
## Continuous integration
|
||||
|
||||
The collection is tested with a [molecule](https://github.com/ansible-community/molecule) setup covering the included roles and verifying correct installation and idempotency.
|
||||
In order to run the molecule tests locally with python 3.9 available, after cloning the repository:
|
||||
|
||||
```
|
||||
pip install yamllint 'molecule[docker]~=3.5.2' ansible-core flake8 ansible-lint voluptuous
|
||||
molecule test --all
|
||||
```
|
||||
|
||||
|
||||
## Integration testing
|
||||
|
||||
Demo repositories which depend on the collection, and aggregate functionality with other middleware_automation collections, are automatically rebuilt
|
||||
at every collection release to ensure non-breaking changes and consistent behaviour.
|
||||
|
||||
The repository are:
|
||||
|
||||
- [Flange demo](https://github.com/ansible-middleware/flange-demo)
|
||||
A deployment of Wildfly cluster integrated with keycloak and infinispan.
|
||||
- [CrossDC keycloak demo](https://github.com/ansible-middleware/cross-dc-rhsso-demo)
|
||||
A clustered multi-regional installation of keycloak with infinispan remote caches.
|
||||
|
||||
|
||||
## Test playbooks
|
||||
|
||||
Sample playbooks are provided in the `playbooks/` directory; to run the playbooks locally (requires a rhel system with python 3.9+, ansible, and systemd) the steps are as follows:
|
||||
|
||||
```
|
||||
# setup environment
|
||||
pip install ansible-core
|
||||
# clone the repository
|
||||
git clone https://github.com/ansible-middleware/keycloak
|
||||
cd keycloak
|
||||
# install collection dependencies
|
||||
ansible-galaxy collection install -r requirements.yml
|
||||
# install collection python deps
|
||||
pip install -r requirements.txt
|
||||
# create inventory for localhost
|
||||
cat << EOF > inventory
|
||||
[keycloak]
|
||||
localhost ansible_connection=local
|
||||
EOF
|
||||
# run the playbook
|
||||
ansible-playbook -i inventory playbooks/keycloak.yml
|
||||
```
|
||||
|
||||
19
galaxy.yml
19
galaxy.yml
@@ -1,6 +1,7 @@
|
||||
---
|
||||
namespace: middleware_automation
|
||||
name: keycloak
|
||||
version: "0.2.2"
|
||||
version: "1.0.2"
|
||||
readme: README.md
|
||||
authors:
|
||||
- Romain Pelisse <rpelisse@redhat.com>
|
||||
@@ -12,12 +13,22 @@ tags:
|
||||
- keycloak
|
||||
- redhat
|
||||
- rhel
|
||||
- rhn
|
||||
- sso
|
||||
- openid
|
||||
- application
|
||||
- identity
|
||||
- security
|
||||
- infrastructure
|
||||
- authentication
|
||||
dependencies:
|
||||
"middleware_automation.redhat_csp_download": ">=1.2.1"
|
||||
"middleware_automation.wildfly": ">=0.0.4"
|
||||
"middleware_automation.wildfly": ">=1.0.0"
|
||||
repository: https://github.com/ansible-middleware/keycloak
|
||||
documentation: https://github.com/ansible-middleware/keycloak
|
||||
documentation: https://ansible-middleware.github.io/keycloak
|
||||
homepage: https://github.com/ansible-middleware/keycloak
|
||||
issues: https://github.com/ansible-middleware/keycloak/issues
|
||||
build_ignore:
|
||||
- molecule
|
||||
- .github
|
||||
- '*.tar.gz'
|
||||
- '*.zip'
|
||||
|
||||
@@ -2,17 +2,15 @@
|
||||
- name: Converge
|
||||
hosts: all
|
||||
vars:
|
||||
keycloak_admin_password: "remembertochangeme"
|
||||
tasks:
|
||||
- name: Include keycloak role
|
||||
include_role:
|
||||
name: ../../roles/keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
- name: Keycloak Realm Role
|
||||
include_role:
|
||||
name: ../../roles/keycloak_realm
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
keycloak_client_default_roles:
|
||||
- TestRoleAdmin
|
||||
- TestRoleUser
|
||||
|
||||
@@ -4,6 +4,9 @@ dependency:
|
||||
command: ansible-galaxy collection install -r molecule/default/requirements.yml -p $HOME/.ansible/collections --force-with-deps
|
||||
driver:
|
||||
name: docker
|
||||
lint: |
|
||||
ansible-lint --version
|
||||
ansible-lint -v
|
||||
platforms:
|
||||
- name: instance
|
||||
image: registry.access.redhat.com/ubi8/ubi-init:latest
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Disable beta repos
|
||||
command: yum config-manager --disable '*beta*'
|
||||
ansible.builtin.command: yum config-manager --disable '*beta*'
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Install sudo
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name: sudo
|
||||
state: present
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
collections:
|
||||
- name: middleware_automation.redhat_csp_download
|
||||
version: ">=1.2.1"
|
||||
- name: middleware_automation.jcliff
|
||||
version: ">=0.0.19"
|
||||
- name: middleware_automation.wildfly
|
||||
version: ">=0.0.5"
|
||||
- name: community.general
|
||||
- name: community.docker
|
||||
version: ">=1.9.1"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
- name: Populate service facts
|
||||
ansible.builtin.service_facts:
|
||||
- name: Check if keycloak service started
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts.services["keycloak.service"]["state"] == "running"
|
||||
- ansible_facts.services["keycloak.service"]["status"] == "enabled"
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
---
|
||||
- name: Playbook for Keycloak Hosts
|
||||
hosts: keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "remembertochangeme"
|
||||
collections:
|
||||
- middleware_automation.keycloak
|
||||
tasks:
|
||||
- name: Include keycloak role
|
||||
include_role:
|
||||
name: keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
roles:
|
||||
- middleware_automation.keycloak.keycloak
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
hosts: keycloak
|
||||
tasks:
|
||||
- name: Keycloak Realm Role
|
||||
include_role:
|
||||
name: keycloak_realm
|
||||
ansible.builtin.include_role:
|
||||
name: middleware_automation.keycloak.keycloak_realm
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
keycloak_admin_password: "remembertochangeme"
|
||||
keycloak_realm: TestRealm
|
||||
keycloak_user_federation:
|
||||
- realm: TestRealm
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
- name: Playbook for Keycloak Hosts
|
||||
hosts: keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "remembertochangeme"
|
||||
keycloak_rhsso_enable: True
|
||||
collections:
|
||||
- middleware_automation.redhat_csp_download
|
||||
- middleware_automation.keycloak
|
||||
roles:
|
||||
- redhat_csp_download
|
||||
tasks:
|
||||
- name: Keycloak Role
|
||||
include_role:
|
||||
name: keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
keycloak_rhsso_enable: True
|
||||
- middleware_automation.redhat_csp_download.redhat_csp_download
|
||||
- middleware_automation.keycloak.keycloak
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
collections:
|
||||
- name: middleware_automation.redhat_csp_download
|
||||
version: ">=1.2.1"
|
||||
- name: middleware_automation.jcliff
|
||||
version: ">=0.0.19"
|
||||
- name: middleware_automation.wildfly
|
||||
version: ">=0.0.5"
|
||||
- name: community.general
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
keycloak
|
||||
========
|
||||
|
||||
Install [keycloak](https://keycloak.org/) or [Red Hat Single Sing-On](https://access.redhat.com/products/red-hat-single-sign-on) server configurations.
|
||||
Install [keycloak](https://keycloak.org/) or [Red Hat Single Sign-On](https://access.redhat.com/products/red-hat-single-sign-on) server configurations.
|
||||
|
||||
|
||||
Requirements
|
||||
@@ -31,6 +31,17 @@ Versions
|
||||
|`7.5.0 GA` |September 20, 2021 |`15.0.2` | `7.4.0` |[Release Notes](https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.5/html/release_notes/index)|
|
||||
|
||||
|
||||
Patching
|
||||
--------
|
||||
|
||||
When variable `keycloak_rhsso_apply_patches` is `True` (default: `False`), the role will automatically apply the latest cumulative patch for the selected base version.
|
||||
|
||||
| RH-SSO VERSION | Release Date | RH-SSO LATEST CP | Notes |
|
||||
|:---------------|:------------------|:-----------------|:----------------|
|
||||
|`7.5.0 GA` |January 20, 2022 |`7.5.1 GA` |[Release Notes](https://access.redhat.com/articles/6646321)|
|
||||
|
||||
|
||||
|
||||
Role Defaults
|
||||
-------------
|
||||
|
||||
@@ -55,20 +66,45 @@ Role Defaults
|
||||
|`keycloak_service_user`| posix account username | `keycloak` |
|
||||
|`keycloak_service_group`| posix account group | `keycloak` |
|
||||
|`keycloak_service_pidfile`| pid file path for service | `/run/keycloak.pid` |
|
||||
|`jvm_package`| RHEL java package runtime | `java-1.8.0-openjdk-devel` |
|
||||
|`keycloak_jvm_package`| RHEL java package runtime | `java-1.8.0-openjdk-devel` |
|
||||
|
||||
|
||||
* Install options
|
||||
|
||||
| Variable | Description | Default |
|
||||
|:---------|:------------|:---------|
|
||||
|`keycloak_rhsso_enable`| Enable Red Hat Single Sign-on installation | `False` |
|
||||
|`keycloak_rhsso_enable`| Enable Red Hat Single Sign-on installation | `False` |
|
||||
|`keycloak_offline_install` | perform an offline install | `False`|
|
||||
|`keycloak_download_url`| Download URL for keycloak | `https://github.com/keycloak/keycloak/releases/download/<version>/<archive>`|
|
||||
|`keycloak_rhsso_download_url`| Download URL for RHSSO | `https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId=<productID>`|
|
||||
|`keycloak_version`| keycloak.org package version | `15.0.2` |
|
||||
|`keycloak_rhsso_version`| RHSSO version | `7.5.0` |
|
||||
|`keycloak_rhsso_apply_patches`| Install RHSSO more recent cumulative patch | `False` |
|
||||
|`keycloak_dest`| Installation root path | `/opt/keycloak` |
|
||||
|`keycloak_download_url` | Download URL for keycloak | `https://github.com/keycloak/keycloak/releases/download/{{ keycloak_version }}/{{ keycloak_archive }}` |
|
||||
|`keycloak_rhn_url` | Base download URI for customer portal | `https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId=` |
|
||||
|`keycloak_configure_firewalld` | Ensure firewalld is running and configure keycloak ports | `False` |
|
||||
|
||||
|
||||
* Miscellaneous configuration
|
||||
|
||||
| Variable | Description | Default |
|
||||
|:---------|:------------|:--------|
|
||||
|`keycloak_archive` | keycloak install archive filename | `keycloak-{{ keycloak_version }}.zip` |
|
||||
|`keycloak_download_url_9x` | Download URL for keycloak (deprecated) | `https://downloads.jboss.org/keycloak/{{ keycloak_version }}/{{ keycloak_archive }}` |
|
||||
|`keycloak_installdir` | Installation path | `{{ keycloak_dest }}/keycloak-{{ keycloak_version }}` |
|
||||
|`keycloak_rhsso_archive` | Red Hat SSO install archive filename | `rh-sso-{{ keycloak_rhsso_version }}-server-dist.zip` |
|
||||
|`keycloak_rhsso_installdir`| Installation path for Red Hat SSO | `{{ keycloak_dest }}/rh-sso-{{ keycloak_rhsso_version | regex_replace('^([0-9])\.([0-9]*).*', '\1.\2') }}` |
|
||||
|`keycloak_rhsso_download_url`| Full download URI for Red Hat SSO | `{{ keycloak_rhn_url }}{{ rhsso_rhn_id }}` |
|
||||
|`keycloak_jboss_home` | Installation work directory | `{{ keycloak_rhsso_installdir if keycloak_rhsso_enable else keycloak_installdir }}` |
|
||||
|`keycloak_config_dir` | Path for configuration | `{{ keycloak_jboss_home }}/standalone/configuration` |
|
||||
|`keycloak_config_path_to_standalone_xml` | Custom path for configuration | `{{ keycloak_jboss_home }}/standalone/configuration/{{ keycloak_config_standalone_xml }}` |
|
||||
|`keycloak_auth_realm` | Name for rest authentication realm | `master` |
|
||||
|`keycloak_auth_client` | Authentication client for configuration REST calls | `admin-cli` |
|
||||
|`keycloak_force_install` | Remove pre-existing versions of service | `False` |
|
||||
|`keycloak_url` | URL for configuration rest calls | `http://{{ keycloak_host }}:{{ keycloak_http_port }}` |
|
||||
|`keycloak_management_url` | URL for management console rest calls | `http://{{ keycloak_host }}:{{ keycloak_management_http_port }}` |
|
||||
|`rhsso_rhn_id` | Customer Portal product ID for Red Hat SSO | `{{ rhsso_rhn_ids[keycloak_rhsso_version].id }}` |
|
||||
|
||||
|
||||
Role Variables
|
||||
@@ -78,7 +114,8 @@ The following are a set of _required_ variables for the role:
|
||||
|
||||
| Variable | Description |
|
||||
|:---------|:------------|
|
||||
|`keycloak_admin_password`| Password for the administration console user account |
|
||||
|`keycloak_admin_password`| Password for the administration console user account (minimum 12 characters) |
|
||||
|`keycloak_frontend_url` | frontend URL for keycloak endpoint | `http://localhost:8080/auth` |
|
||||
|
||||
|
||||
The following variables are _required_ only when `keycloak_ha_enabled` is True:
|
||||
@@ -86,8 +123,7 @@ The following variables are _required_ only when `keycloak_ha_enabled` is True:
|
||||
| Variable | Description | Default |
|
||||
|:---------|:------------|:---------|
|
||||
|`keycloak_modcluster_url` | URL for the modcluster reverse proxy | `localhost` |
|
||||
|`keycloak_frontend_url` | frontend URL for keycloak endpoints when a reverse proxy is used | `http://localhost` |
|
||||
|`keycloak_jdbc_engine` | backend database flavour when db is enabled: [ postgres, mariadb ] | `postgres` |
|
||||
|`keycloak_jdbc_engine` | backend database engine when db is enabled: [ postgres, mariadb ] | `postgres` |
|
||||
|`infinispan_url` | URL for the infinispan remote-cache server | `localhost:11122` |
|
||||
|`infinispan_user` | username for connecting to infinispan | `supervisor` |
|
||||
|`infinispan_pass` | password for connecting to infinispan | `supervisor` |
|
||||
@@ -118,14 +154,12 @@ _NOTE_: use ansible vaults or other security systems for storing credentials.
|
||||
```yaml
|
||||
---
|
||||
- hosts: ...
|
||||
vars:
|
||||
keycloak_admin_password: "remembertochangeme"
|
||||
collections:
|
||||
- middleware_automation.keycloak
|
||||
tasks:
|
||||
- name: Include keycloak role
|
||||
include_role:
|
||||
name: keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
roles:
|
||||
- middleware_automation.keycloak.keycloak
|
||||
```
|
||||
|
||||
* The following is an example playbook that makes use of the role to install Red Hat Single Sign-On from RHN:
|
||||
@@ -143,7 +177,7 @@ _NOTE_: use ansible vaults or other security systems for storing credentials.
|
||||
include_role:
|
||||
name: keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
keycloak_admin_password: "remembertochangeme"
|
||||
keycloak_rhsso_enable: True
|
||||
rhn_username: '<customer portal username>'
|
||||
rhn_password: '<customer portal password>'
|
||||
@@ -162,7 +196,7 @@ _NOTE_: use ansible vaults or other security systems for storing credentials.
|
||||
include_role:
|
||||
name: keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
keycloak_admin_password: "remembertochangeme"
|
||||
keycloak_offline_install: True
|
||||
# This should be the filename of keycloak archive on Ansible node: keycloak-16.1.0.zip
|
||||
```
|
||||
@@ -180,14 +214,14 @@ _NOTE_: use ansible vaults or other security systems for storing credentials.
|
||||
include_role:
|
||||
name: keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
keycloak_admin_password: "remembertochangeme"
|
||||
keycloak_rhsso_enable: True
|
||||
keycloak_rhsso_download_url: "<REPLACE with download url>"
|
||||
# This should be the full of remote source rhsso zip file and can contain basic authentication credentials
|
||||
```
|
||||
|
||||
|
||||
* The following is an example playbook that makes use of the role to install Red Hat Single Sign-On from the controller node:
|
||||
* The following is an example playbook that makes use of the role to install Red Hat Single Sign-On offline from the controller node, and apply latest cumulative patch:
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -199,9 +233,10 @@ _NOTE_: use ansible vaults or other security systems for storing credentials.
|
||||
include_role:
|
||||
name: keycloak
|
||||
vars:
|
||||
keycloak_admin_password: "changeme"
|
||||
keycloak_admin_password: "remembertochangeme"
|
||||
keycloak_rhsso_enable: True
|
||||
keycloak_offline_install: True
|
||||
keycloak_rhsso_apply_patches: True
|
||||
# This should be the filename of rhsso zip file on Ansible node: rh-sso-7.5-server-dist.zip
|
||||
```
|
||||
|
||||
|
||||
@@ -6,13 +6,14 @@ keycloak_download_url: "https://github.com/keycloak/keycloak/releases/download/{
|
||||
keycloak_download_url_9x: "https://downloads.jboss.org/keycloak/{{ keycloak_version }}/{{ keycloak_archive }}"
|
||||
keycloak_installdir: "{{ keycloak_dest }}/keycloak-{{ keycloak_version }}"
|
||||
|
||||
### Configuration specific to Red Hat Single Sing-On
|
||||
### Configuration specific to Red Hat Single Sign-On
|
||||
keycloak_rhsso_version: 7.5.0
|
||||
rhsso_rhn_id: "{{ rhsso_rhn_ids[keycloak_rhsso_version] }}"
|
||||
rhsso_rhn_id: "{{ rhsso_rhn_ids[keycloak_rhsso_version].id }}"
|
||||
keycloak_rhsso_archive: "rh-sso-{{ keycloak_rhsso_version }}-server-dist.zip"
|
||||
keycloak_rhsso_installdir: "{{ keycloak_dest }}/rh-sso-{{ keycloak_rhsso_version | regex_replace('^([0-9])\\.([0-9]*).*', '\\1.\\2') }}"
|
||||
keycloak_rhn_url: 'https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId='
|
||||
keycloak_rhsso_download_url: "{{ keycloak_rhn_url }}{{ rhsso_rhn_id }}"
|
||||
keycloak_rhsso_apply_patches: False
|
||||
|
||||
### keycloak/rhsso choice: by default install rhsso if rhn credentials are defined
|
||||
keycloak_rhsso_enable: "{{ True if rhsso_rhn_id is defined and rhn_username is defined and rhn_password is defined else False }}"
|
||||
@@ -20,7 +21,7 @@ keycloak_rhsso_enable: "{{ True if rhsso_rhn_id is defined and rhn_username is d
|
||||
keycloak_offline_install: False
|
||||
|
||||
### Install location and service settings
|
||||
jvm_package: java-1.8.0-openjdk-devel
|
||||
keycloak_jvm_package: java-1.8.0-openjdk-devel
|
||||
keycloak_dest: /opt/keycloak
|
||||
keycloak_jboss_home: "{{ keycloak_rhsso_installdir if keycloak_rhsso_enable else keycloak_installdir }}"
|
||||
keycloak_config_dir: "{{ keycloak_jboss_home }}/standalone/configuration"
|
||||
@@ -29,6 +30,10 @@ keycloak_config_path_to_standalone_xml: "{{ keycloak_jboss_home }}/standalone/co
|
||||
keycloak_service_user: keycloak
|
||||
keycloak_service_group: keycloak
|
||||
keycloak_service_pidfile: "/run/keycloak.pid"
|
||||
keycloak_configure_firewalld: False
|
||||
|
||||
### administrator console password
|
||||
keycloak_admin_password: ''
|
||||
|
||||
### Common configuration settings
|
||||
keycloak_bind_address: 0.0.0.0
|
||||
@@ -56,7 +61,9 @@ keycloak_force_install: False
|
||||
|
||||
### mod_cluster reverse proxy
|
||||
keycloak_modcluster_url: localhost
|
||||
keycloak_frontend_url: http://localhost
|
||||
|
||||
### keycloak frontend url
|
||||
keycloak_frontend_url: http://localhost:8080/auth
|
||||
|
||||
### infinispan remote caches access (hotrod)
|
||||
infinispan_user: supervisor
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
---
|
||||
- name: restart keycloak
|
||||
include_tasks: restart_keycloak.yml
|
||||
- name: "Restart {{ keycloak.service_name }}"
|
||||
ansible.builtin.include_tasks: restart_keycloak.yml
|
||||
listen: "restart keycloak"
|
||||
|
||||
288
roles/keycloak/meta/argument_specs.yml
Normal file
288
roles/keycloak/meta/argument_specs.yml
Normal file
@@ -0,0 +1,288 @@
|
||||
argument_specs:
|
||||
main:
|
||||
options:
|
||||
keycloak_version:
|
||||
# line 3 of keycloak/defaults/main.yml
|
||||
default: "15.0.2"
|
||||
description: "keycloak.org package version"
|
||||
type: "str"
|
||||
keycloak_archive:
|
||||
# line 4 of keycloak/defaults/main.yml
|
||||
default: "keycloak-{{ keycloak_version }}.zip"
|
||||
description: "keycloak install archive filename"
|
||||
type: "str"
|
||||
keycloak_configure_firewalld:
|
||||
# line 33 of keycloak/defaults/main.yml
|
||||
default: false
|
||||
description: "Ensure firewalld is running and configure keycloak ports"
|
||||
type: "bool"
|
||||
keycloak_download_url:
|
||||
# line 5 of keycloak/defaults/main.yml
|
||||
default: "https://github.com/keycloak/keycloak/releases/download/{{ keycloak_version }}/{{ keycloak_archive }}"
|
||||
description: "Download URL for keycloak"
|
||||
type: "str"
|
||||
keycloak_download_url_9x:
|
||||
# line 6 of keycloak/defaults/main.yml
|
||||
default: "https://downloads.jboss.org/keycloak/{{ keycloak_version }}/{{ keycloak_archive }}"
|
||||
description: "Download URL for keycloak (deprecated)"
|
||||
type: "str"
|
||||
keycloak_installdir:
|
||||
# line 7 of keycloak/defaults/main.yml
|
||||
default: "{{ keycloak_dest }}/keycloak-{{ keycloak_version }}"
|
||||
description: "Installation path"
|
||||
type: "str"
|
||||
keycloak_rhsso_version:
|
||||
# line 10 of keycloak/defaults/main.yml
|
||||
default: "7.5.0"
|
||||
description: "Red Hat Single Sign-On version"
|
||||
type: "str"
|
||||
rhsso_rhn_id:
|
||||
# line 11 of keycloak/defaults/main.yml
|
||||
default: "{{ rhsso_rhn_ids[keycloak_rhsso_version].id }}"
|
||||
description: "Customer Portal product ID for Red Hat SSO"
|
||||
type: "str"
|
||||
keycloak_rhsso_archive:
|
||||
# line 12 of keycloak/defaults/main.yml
|
||||
default: "rh-sso-{{ keycloak_rhsso_version }}-server-dist.zip"
|
||||
description: "ed Hat SSO install archive filename"
|
||||
type: "str"
|
||||
keycloak_rhsso_apply_patches:
|
||||
# line 16 of keycloak/defaults/main.yml
|
||||
default: false
|
||||
description: "Install RHSSO more recent cumulative patch"
|
||||
type: "bool"
|
||||
keycloak_rhsso_installdir:
|
||||
# line 13 of keycloak/defaults/main.yml
|
||||
default: "{{ keycloak_dest }}/rh-sso-{{ keycloak_rhsso_version | regex_replace('^([0-9])\\.([0-9]*).*', '\\1.\\2') }}"
|
||||
description: "Installation path for Red Hat SSO"
|
||||
type: "str"
|
||||
keycloak_rhn_url:
|
||||
# line 14 of keycloak/defaults/main.yml
|
||||
default: "https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId="
|
||||
description: "Base download URI for customer portal"
|
||||
type: "str"
|
||||
keycloak_rhsso_download_url:
|
||||
# line 15 of keycloak/defaults/main.yml
|
||||
default: "{{ keycloak_rhn_url }}{{ rhsso_rhn_id }}"
|
||||
description: "Full download URI for Red Hat SSO"
|
||||
type: "str"
|
||||
keycloak_rhsso_enable:
|
||||
# line 18 of keycloak/defaults/main.yml
|
||||
default: "{{ True if rhsso_rhn_id is defined and rhn_username is defined and rhn_password is defined else False }}"
|
||||
description: "Enable Red Hat Single Sign-on installation"
|
||||
type: "str"
|
||||
keycloak_offline_install:
|
||||
# line 20 of keycloak/defaults/main.yml
|
||||
default: false
|
||||
description: "Perform an offline install"
|
||||
type: "bool"
|
||||
keycloak_jvm_package:
|
||||
# line 23 of keycloak/defaults/main.yml
|
||||
default: "java-1.8.0-openjdk-devel"
|
||||
description: "RHEL java package runtime rpm"
|
||||
type: "str"
|
||||
keycloak_dest:
|
||||
# line 24 of keycloak/defaults/main.yml
|
||||
default: "/opt/keycloak"
|
||||
description: "Root installation directory"
|
||||
type: "str"
|
||||
keycloak_jboss_home:
|
||||
# line 25 of keycloak/defaults/main.yml
|
||||
default: "{{ keycloak_rhsso_installdir if keycloak_rhsso_enable else keycloak_installdir }}"
|
||||
description: "Installation work directory"
|
||||
type: "str"
|
||||
keycloak_config_dir:
|
||||
# line 26 of keycloak/defaults/main.yml
|
||||
default: "{{ keycloak_jboss_home }}/standalone/configuration"
|
||||
description: "Path for configuration"
|
||||
type: "str"
|
||||
keycloak_config_standalone_xml:
|
||||
# line 27 of keycloak/defaults/main.yml
|
||||
default: "keycloak.xml"
|
||||
description: "Service configuration filename"
|
||||
type: "str"
|
||||
keycloak_config_path_to_standalone_xml:
|
||||
# line 28 of keycloak/defaults/main.yml
|
||||
default: "{{ keycloak_jboss_home }}/standalone/configuration/{{ keycloak_config_standalone_xml }}"
|
||||
description: "Custom path for configuration"
|
||||
type: "str"
|
||||
keycloak_service_user:
|
||||
# line 29 of keycloak/defaults/main.yml
|
||||
default: "keycloak"
|
||||
description: "posix account username"
|
||||
type: "str"
|
||||
keycloak_service_group:
|
||||
# line 30 of keycloak/defaults/main.yml
|
||||
default: "keycloak"
|
||||
description: "posix account group"
|
||||
type: "str"
|
||||
keycloak_service_pidfile:
|
||||
# line 31 of keycloak/defaults/main.yml
|
||||
default: "/run/keycloak.pid"
|
||||
description: "PID file path for service"
|
||||
type: "str"
|
||||
keycloak_bind_address:
|
||||
# line 34 of keycloak/defaults/main.yml
|
||||
default: "0.0.0.0"
|
||||
description: "Address for binding service ports"
|
||||
type: "str"
|
||||
keycloak_host:
|
||||
# line 35 of keycloak/defaults/main.yml
|
||||
default: "localhost"
|
||||
description: "Hostname for service"
|
||||
type: "str"
|
||||
keycloak_http_port:
|
||||
# line 36 of keycloak/defaults/main.yml
|
||||
default: 8080
|
||||
description: "Listening HTTP port"
|
||||
type: "int"
|
||||
keycloak_https_port:
|
||||
# line 37 of keycloak/defaults/main.yml
|
||||
default: 8443
|
||||
description: "Listening HTTPS port"
|
||||
type: "int"
|
||||
keycloak_ajp_port:
|
||||
# line 38 of keycloak/defaults/main.yml
|
||||
default: 8009
|
||||
description: "Listening AJP port"
|
||||
type: "int"
|
||||
keycloak_jgroups_port:
|
||||
# line 39 of keycloak/defaults/main.yml
|
||||
default: 7600
|
||||
description: "jgroups cluster tcp port"
|
||||
type: "int"
|
||||
keycloak_management_http_port:
|
||||
# line 40 of keycloak/defaults/main.yml
|
||||
default: 9990
|
||||
description: "Management port (http)"
|
||||
type: "int"
|
||||
keycloak_management_https_port:
|
||||
# line 41 of keycloak/defaults/main.yml
|
||||
default: 9993
|
||||
description: "Management port (https)"
|
||||
type: "int"
|
||||
keycloak_java_opts:
|
||||
# line 42 of keycloak/defaults/main.yml
|
||||
default: "-Xms1024m -Xmx2048m"
|
||||
description: "Additional JVM options"
|
||||
type: "str"
|
||||
keycloak_prefer_ipv4:
|
||||
# line 43 of keycloak/defaults/main.yml
|
||||
default: true
|
||||
description: "Prefer IPv4 stack and addresses for port binding"
|
||||
type: "bool"
|
||||
keycloak_ha_enabled:
|
||||
# line 46 of keycloak/defaults/main.yml
|
||||
default: false
|
||||
description: "Enable auto configuration for database backend, clustering and remote caches on infinispan"
|
||||
type: "bool"
|
||||
keycloak_db_enabled:
|
||||
# line 48 of keycloak/defaults/main.yml
|
||||
default: "{{ True if keycloak_ha_enabled else False }}"
|
||||
description: "Enable auto configuration for database backend"
|
||||
type: "str"
|
||||
keycloak_admin_user:
|
||||
# line 51 of keycloak/defaults/main.yml
|
||||
default: "admin"
|
||||
description: "Administration console user account"
|
||||
type: "str"
|
||||
keycloak_auth_realm:
|
||||
# line 52 of keycloak/defaults/main.yml
|
||||
default: "master"
|
||||
description: "Name for rest authentication realm"
|
||||
type: "str"
|
||||
keycloak_auth_client:
|
||||
# line 53 of keycloak/defaults/main.yml
|
||||
default: "admin-cli"
|
||||
description: "Authentication client for configuration REST calls"
|
||||
type: "str"
|
||||
keycloak_force_install:
|
||||
# line 55 of keycloak/defaults/main.yml
|
||||
default: false
|
||||
description: "Remove pre-existing versions of service"
|
||||
type: "bool"
|
||||
keycloak_modcluster_url:
|
||||
# line 58 of keycloak/defaults/main.yml
|
||||
default: "localhost"
|
||||
description: "URL for the modcluster reverse proxy"
|
||||
type: "str"
|
||||
keycloak_frontend_url:
|
||||
# line 59 of keycloak/defaults/main.yml
|
||||
default: "http://localhost"
|
||||
description: "Frontend URL for keycloak endpoints when a reverse proxy is used"
|
||||
type: "str"
|
||||
infinispan_user:
|
||||
# line 62 of keycloak/defaults/main.yml
|
||||
default: "supervisor"
|
||||
description: "Username for connecting to infinispan"
|
||||
type: "str"
|
||||
infinispan_pass:
|
||||
# line 63 of keycloak/defaults/main.yml
|
||||
default: "supervisor"
|
||||
description: "Password for connecting to infinispan"
|
||||
type: "str"
|
||||
infinispan_url:
|
||||
# line 64 of keycloak/defaults/main.yml
|
||||
default: "localhost"
|
||||
description: "URL for the infinispan remote-cache server"
|
||||
type: "str"
|
||||
infinispan_sasl_mechanism:
|
||||
# line 65 of keycloak/defaults/main.yml
|
||||
default: "SCRAM-SHA-512"
|
||||
description: "Authentication type to infinispan server"
|
||||
type: "str"
|
||||
infinispan_use_ssl:
|
||||
# line 66 of keycloak/defaults/main.yml
|
||||
default: false
|
||||
description: "Enable hotrod client TLS communication"
|
||||
type: "bool"
|
||||
infinispan_trust_store_path:
|
||||
# line 68 of keycloak/defaults/main.yml
|
||||
default: "/etc/pki/java/cacerts"
|
||||
description: "TODO document argument"
|
||||
type: "str"
|
||||
infinispan_trust_store_password:
|
||||
# line 69 of keycloak/defaults/main.yml
|
||||
default: "changeit"
|
||||
description: "Path to truststore containing infinispan server certificate"
|
||||
type: "str"
|
||||
keycloak_jdbc_engine:
|
||||
# line 72 of keycloak/defaults/main.yml
|
||||
default: "postgres"
|
||||
description: "Backend database flavour when db is enabled: [ postgres, mariadb ]"
|
||||
type: "str"
|
||||
keycloak_db_user:
|
||||
# line 74 of keycloak/defaults/main.yml
|
||||
default: "keycloak-user"
|
||||
description: "Username for connecting to database"
|
||||
type: "str"
|
||||
keycloak_db_pass:
|
||||
# line 75 of keycloak/defaults/main.yml
|
||||
default: "keycloak-pass"
|
||||
description: "Password for connecting to database"
|
||||
type: "str"
|
||||
keycloak_jdbc_url:
|
||||
# line 76 of keycloak/defaults/main.yml
|
||||
default: "{{ keycloak_default_jdbc[keycloak_jdbc_engine].url }}"
|
||||
description: "URL for connecting to backend database"
|
||||
type: "str"
|
||||
keycloak_jdbc_driver_version:
|
||||
# line 77 of keycloak/defaults/main.yml
|
||||
default: "{{ keycloak_default_jdbc[keycloak_jdbc_engine].version }}"
|
||||
description: "Version for the JDBC driver to download"
|
||||
type: "str"
|
||||
keycloak_admin_password:
|
||||
# line 4 of keycloak/vars/main.yml
|
||||
required: true
|
||||
description: "Password for the administration console user account"
|
||||
type: "str"
|
||||
keycloak_url:
|
||||
# line 12 of keycloak/vars/main.yml
|
||||
default: "http://{{ keycloak_host }}:{{ keycloak_http_port }}"
|
||||
description: "URL for configuration rest calls"
|
||||
type: "str"
|
||||
keycloak_management_url:
|
||||
# line 13 of keycloak/vars/main.yml
|
||||
default: "http://{{ keycloak_host }}:{{ keycloak_management_http_port }}"
|
||||
description: "URL for management console rest calls"
|
||||
type: "str"
|
||||
@@ -6,8 +6,8 @@ collections:
|
||||
galaxy_info:
|
||||
role_name: keycloak
|
||||
namespace: middleware_automation
|
||||
author: Romain Pelisse, Guido Grazioli
|
||||
description: Install keycloak or Red Hat Single Sing-On server configurations
|
||||
author: Romain Pelisse, Guido Grazioli, Pavan Kumar Motaparthi
|
||||
description: Install keycloak or Red Hat Single Sign-On server configurations
|
||||
company: Red Hat, Inc.
|
||||
|
||||
license: Apache License 2.0
|
||||
@@ -17,12 +17,13 @@ galaxy_info:
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
- 8
|
||||
|
||||
galaxy_tags:
|
||||
- keycloak
|
||||
- redhat
|
||||
- rhel
|
||||
- rhn
|
||||
- sso
|
||||
- sso
|
||||
- authentication
|
||||
- identity
|
||||
- security
|
||||
|
||||
21
roles/keycloak/tasks/fastpackages.yml
Normal file
21
roles/keycloak/tasks/fastpackages.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
- block:
|
||||
- name: "Check if packages are already installed"
|
||||
ansible.builtin.command: "rpm -q {{ packages_list | join(' ') }}"
|
||||
args:
|
||||
warn: no
|
||||
register: rpm_info
|
||||
changed_when: rpm_info.failed
|
||||
|
||||
rescue:
|
||||
- name: "Add missing packages to the yum install list"
|
||||
ansible.builtin.set_fact:
|
||||
packages_to_install: "{{ packages_to_install | default([]) + rpm_info.stdout_lines | map('regex_findall', 'package (.+) is not installed$') | flatten }}"
|
||||
when: rpm_info.failed
|
||||
|
||||
- name: "Install packages: {{ packages_to_install }}"
|
||||
become: yes
|
||||
ansible.builtin.yum:
|
||||
name: "{{ packages_to_install }}"
|
||||
state: present
|
||||
when: packages_to_install | default([]) | length > 0
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
- block:
|
||||
- name: "Check if package {{ package_name }} is already installed"
|
||||
command: rpm -q {{ package_name }}
|
||||
args:
|
||||
warn: no
|
||||
register: rpm_info
|
||||
changed_when: rpm_info.failed
|
||||
|
||||
rescue:
|
||||
- name: "If package {{ package_name }} is missing, add it to the yum install list."
|
||||
set_fact:
|
||||
packages_to_install: "{{ packages_to_install + [ package_name ] }}"
|
||||
when: rpm_info.failed
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
- set_fact:
|
||||
update_cache: true
|
||||
packages_to_install: []
|
||||
|
||||
- name: "Check packages to be installed"
|
||||
include_tasks: check.yml
|
||||
loop: "{{ packages_list | flatten }}"
|
||||
loop_control:
|
||||
loop_var: package_name
|
||||
|
||||
- name: "Install packages: {{ packages_to_install }}"
|
||||
become: yes
|
||||
yum:
|
||||
name: "{{ packages_to_install }}"
|
||||
state: present
|
||||
when: packages_to_install | length > 0
|
||||
@@ -1,18 +1,18 @@
|
||||
---
|
||||
- name: Ensures required package firewalld are installed
|
||||
ansible.builtin.include_tasks: fastpackages/install.yml
|
||||
- name: Ensure required package firewalld are installed
|
||||
ansible.builtin.include_tasks: fastpackages.yml
|
||||
vars:
|
||||
packages_list:
|
||||
- firewalld
|
||||
|
||||
- name: Enable and start the firewalld service
|
||||
become: yes
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: firewalld
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: Configure firewall for keycloak ports
|
||||
- name: "Configure firewall for {{ keycloak.service_name }} ports"
|
||||
become: yes
|
||||
firewalld:
|
||||
port: "{{ item }}"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Validate parameters
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- keycloak_jboss_home is defined
|
||||
- keycloak_service_user is defined
|
||||
@@ -12,40 +12,40 @@
|
||||
|
||||
- name: Check for an existing deployment
|
||||
become: yes
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak_jboss_home }}"
|
||||
register: existing_deploy
|
||||
|
||||
- block:
|
||||
- name: Stop the old keycloak service
|
||||
- name: "Stop the old {{ keycloak.service_name }} service"
|
||||
become: yes
|
||||
ignore_errors: yes
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
state: stopped
|
||||
- name: Remove the old Keycloak deployment
|
||||
- name: "Remove the old {{ keycloak.service_name }} deployment"
|
||||
become: yes
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ keycloak_jboss_home }}"
|
||||
state: absent
|
||||
when: existing_deploy.stat.exists and keycloak_force_install|bool
|
||||
|
||||
- name: check for an existing deployment after possible forced removal
|
||||
- name: Check for an existing deployment after possible forced removal
|
||||
become: yes
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak_jboss_home }}"
|
||||
|
||||
- name: create Keycloak service user/group
|
||||
- name: "Create {{ keycloak.service_name }} service user/group"
|
||||
become: yes
|
||||
user:
|
||||
ansible.builtin.user:
|
||||
name: "{{ keycloak_service_user }}"
|
||||
home: /opt/keycloak
|
||||
system: yes
|
||||
create_home: no
|
||||
|
||||
- name: create Keycloak install location
|
||||
- name: "Create {{ keycloak.service_name }} install location"
|
||||
become: yes
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
dest: "{{ keycloak_dest }}"
|
||||
state: directory
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
@@ -54,23 +54,24 @@
|
||||
|
||||
## check remote archive
|
||||
- name: Set download archive path
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
archive: "{{ keycloak_dest }}/{{ keycloak.bundle }}"
|
||||
|
||||
- name: Check download archive path
|
||||
stat:
|
||||
become: yes
|
||||
ansible.builtin.stat:
|
||||
path: "{{ archive }}"
|
||||
register: archive_path
|
||||
|
||||
## download to controller
|
||||
- name: Check load download archive path
|
||||
stat:
|
||||
- name: Check local download archive path
|
||||
ansible.builtin.stat:
|
||||
path: "{{ lookup('env', 'PWD') }}"
|
||||
register: local_path
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Download keycloak archive
|
||||
get_url:
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ keycloak_download_url }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
delegate_to: localhost
|
||||
@@ -81,8 +82,8 @@
|
||||
- not keycloak_rhsso_enable
|
||||
- not keycloak_offline_install
|
||||
|
||||
- name: Performing download from RHN
|
||||
redhat_csp_download:
|
||||
- name: Perform download from RHN
|
||||
middleware_automation.redhat_csp_download.redhat_csp_download:
|
||||
url: "{{ keycloak_rhsso_download_url }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
username: "{{ rhn_username }}"
|
||||
@@ -98,7 +99,7 @@
|
||||
- keycloak_rhn_url in keycloak_rhsso_download_url
|
||||
|
||||
- name: Download rhsso archive from alternate location
|
||||
get_url:
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ keycloak_rhsso_download_url }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
delegate_to: localhost
|
||||
@@ -110,25 +111,35 @@
|
||||
- not keycloak_offline_install
|
||||
- not keycloak_rhn_url in keycloak_rhsso_download_url
|
||||
|
||||
- name: Check downloaded archive
|
||||
ansible.builtin.stat:
|
||||
path: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
register: local_archive_path
|
||||
delegate_to: localhost
|
||||
|
||||
## copy and unpack
|
||||
- name: Copy archive to target nodes
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: "{{ local_path.stat.path }}/{{ keycloak.bundle }}"
|
||||
dest: "{{ archive }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
group: "{{ keycloak_service_group }}"
|
||||
mode: 0750
|
||||
register: new_version_downloaded
|
||||
when:
|
||||
- not archive_path.stat.exists
|
||||
- local_archive_path.stat is defined
|
||||
- local_archive_path.stat.exists
|
||||
become: yes
|
||||
|
||||
- name: "Check target directory: {{ keycloak.home }}"
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ keycloak.home }}"
|
||||
register: path_to_workdir
|
||||
become: yes
|
||||
|
||||
- name: "Extract {{ 'Red Hat Single Sign-On' if keycloak_rhsso_enable else 'Keycloak' }} archive on target"
|
||||
unarchive:
|
||||
ansible.builtin.unarchive:
|
||||
remote_src: yes
|
||||
src: "{{ archive }}"
|
||||
dest: "{{ keycloak_dest }}"
|
||||
@@ -142,13 +153,13 @@
|
||||
- restart keycloak
|
||||
|
||||
- name: Inform decompression was not executed
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ keycloak.home }} already exists and version unchanged, skipping decompression"
|
||||
when:
|
||||
- not new_version_downloaded.changed and path_to_workdir.stat.exists
|
||||
|
||||
- name: "Reown installation directory to {{ keycloak_service_user }}"
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ keycloak.home }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
group: "{{ keycloak_service_group }}"
|
||||
@@ -158,9 +169,8 @@
|
||||
|
||||
# driver and configuration
|
||||
- name: "Install {{ keycloak_jdbc_engine }} driver"
|
||||
include_role:
|
||||
name: wildfly_driver
|
||||
tasks_from: jdbc_driver.yml
|
||||
ansible.builtin.include_role:
|
||||
name: middleware_automation.wildfly.wildfly_driver
|
||||
vars:
|
||||
wildfly_user: "{{ keycloak_service_user }}"
|
||||
jdbc_driver_module_dir: "{{ keycloak_jdbc[keycloak_jdbc_engine].driver_module_dir }}"
|
||||
@@ -173,7 +183,7 @@
|
||||
|
||||
- name: "Deploy {{ keycloak.service_name }} config to {{ keycloak_config_path_to_standalone_xml }}"
|
||||
become: yes
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: templates/standalone.xml.j2
|
||||
dest: "{{ keycloak_config_path_to_standalone_xml }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
@@ -185,7 +195,7 @@
|
||||
|
||||
- name: "Deploy {{ keycloak.service_name }} config with remote cache store to {{ keycloak_config_path_to_standalone_xml }}"
|
||||
become: yes
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: templates/standalone-infinispan.xml.j2
|
||||
dest: "{{ keycloak_config_path_to_standalone_xml }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
|
||||
@@ -1,26 +1,43 @@
|
||||
---
|
||||
# tasks file for keycloak
|
||||
|
||||
- name: Prerequisites
|
||||
include_tasks: prereqs.yml
|
||||
- name: Check prerequisites
|
||||
ansible.builtin.include_tasks: prereqs.yml
|
||||
tags:
|
||||
- prereqs
|
||||
|
||||
- name: Include firewall config tasks
|
||||
ansible.builtin.include_tasks: firewalld.yml
|
||||
when: keycloak_configure_firewalld
|
||||
tags:
|
||||
- firewall
|
||||
|
||||
- name: Include install tasks
|
||||
include_tasks: tasks/install.yml
|
||||
ansible.builtin.include_tasks: install.yml
|
||||
tags:
|
||||
- install
|
||||
|
||||
- name: Include systemd tasks
|
||||
include_tasks: tasks/systemd.yml
|
||||
ansible.builtin.include_tasks: systemd.yml
|
||||
tags:
|
||||
- systemd
|
||||
|
||||
- name: Include patch install tasks
|
||||
ansible.builtin.include_tasks: rhsso_patch.yml
|
||||
when: keycloak_rhsso_apply_patches and keycloak_rhsso_enable
|
||||
tags:
|
||||
- install
|
||||
- patch
|
||||
|
||||
- name: Link default logs directory
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
state: link
|
||||
src: "{{ keycloak_jboss_home }}/standalone/log"
|
||||
dest: /var/log/keycloak
|
||||
|
||||
- block:
|
||||
- name: Check admin credentials by generating a token
|
||||
uri:
|
||||
- name: Check admin credentials by generating a token (supposed to fail on first installation)
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/realms/master/protocol/openid-connect/token"
|
||||
method: POST
|
||||
body: "client_id={{ keycloak_auth_client }}&username={{ keycloak_admin_user }}&password={{ keycloak_admin_password }}&grant_type=password"
|
||||
@@ -31,18 +48,19 @@
|
||||
delay: 2
|
||||
rescue:
|
||||
- name: "Create {{ keycloak.service_name }} admin user"
|
||||
command:
|
||||
ansible.builtin.command:
|
||||
args:
|
||||
argv:
|
||||
- "{{ keycloak_jboss_home }}/bin/add-user-keycloak.sh"
|
||||
- "-rmaster"
|
||||
- "-u{{ keycloak_admin_user }}"
|
||||
- "-p{{ keycloak_admin_password }}"
|
||||
changed_when: yes
|
||||
become: yes
|
||||
- name: "Restart {{ keycloak.service_name }}"
|
||||
include_tasks: tasks/restart_keycloak.yml
|
||||
ansible.builtin.include_tasks: tasks/restart_keycloak.yml
|
||||
- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
---
|
||||
- name: Validate admin console password
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- keycloak_admin_password | length > 12
|
||||
quiet: True
|
||||
fail_msg: "The console administrator password is empty or invalid. Please set the keycloak_admin_password variable to a 16+ char long string"
|
||||
success_msg: "{{ 'Console administrator password OK' }}"
|
||||
|
||||
- name: Validate configuration
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (keycloak_ha_enabled and keycloak_db_enabled) or (not keycloak_ha_enabled and keycloak_db_enabled) or (not keycloak_ha_enabled and not keycloak_db_enabled)
|
||||
quiet: True
|
||||
@@ -8,7 +16,7 @@
|
||||
success_msg: "{{ 'Configuring HA' if keycloak_ha_enabled else 'Configuring standalone' }}"
|
||||
|
||||
- name: Validate credentials
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (rhn_username is defined and keycloak_rhsso_enable) or not keycloak_rhsso_enable or keycloak_offline_install
|
||||
- (rhn_password is defined and keycloak_rhsso_enable) or not keycloak_rhsso_enable or keycloak_offline_install
|
||||
@@ -16,15 +24,11 @@
|
||||
fail_msg: "Cannot install Red Hat SSO without RHN credentials. Check rhn_username and rhn_password are defined"
|
||||
success_msg: "{{ 'Installing Red Hat Single Sign-On' if keycloak_rhsso_enable else 'Installing keycloak.org' }}"
|
||||
|
||||
- name: Set required packages facts
|
||||
set_fact:
|
||||
required_packages:
|
||||
- "{{ jvm_package }}"
|
||||
- unzip
|
||||
- procps-ng
|
||||
- initscripts
|
||||
|
||||
- name: Ensures required packages are installed
|
||||
ansible.builtin.include_tasks: fastpackages/install.yml
|
||||
- name: Ensure required packages are installed
|
||||
ansible.builtin.include_tasks: fastpackages.yml
|
||||
vars:
|
||||
packages_list: "{{ required_packages }}"
|
||||
packages_list:
|
||||
- "{{ keycloak_jvm_package }}"
|
||||
- unzip
|
||||
- procps-ng
|
||||
- initscripts
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: "Restart and enable keycloack service"
|
||||
systemd:
|
||||
- name: "Restart and enable {{ keycloak.service_name }} service"
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
||||
13
roles/keycloak/tasks/rhsso_cli.yml
Normal file
13
roles/keycloak/tasks/rhsso_cli.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: Ensure required params for CLI have been provided
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- query is defined
|
||||
fail_msg: "Missing required parameters to execute CLI."
|
||||
quiet: true
|
||||
|
||||
- name: "Execute CLI query: {{ query }}"
|
||||
ansible.builtin.command: >
|
||||
{{ keycloak.cli_path }} --connect --command='{{ query }}' --controller={{ keycloak_host }}:{{ keycloak_management_http_port }}
|
||||
changed_when: false
|
||||
register: cli_result
|
||||
87
roles/keycloak/tasks/rhsso_patch.yml
Normal file
87
roles/keycloak/tasks/rhsso_patch.yml
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
## check remote patch archive
|
||||
- name: Set download patch archive path
|
||||
ansible.builtin.set_fact:
|
||||
patch_archive: "{{ keycloak_dest }}/{{ keycloak.patch_bundle }}"
|
||||
|
||||
- name: Check download patch archive path
|
||||
ansible.builtin.stat:
|
||||
path: "{{ patch_archive }}"
|
||||
register: patch_archive_path
|
||||
|
||||
- name: Perform download from RHN
|
||||
middleware_automation.redhat_csp_download.redhat_csp_download:
|
||||
url: "{{ keycloak_rhn_url }}{{ rhsso_rhn_ids[keycloak_rhsso_version].latest_cp.id }}"
|
||||
dest: "{{ local_path.stat.path }}/{{ keycloak.patch_bundle }}"
|
||||
username: "{{ rhn_username }}"
|
||||
password: "{{ rhn_password }}"
|
||||
no_log: "{{ omit_rhn_output | default(true) }}"
|
||||
delegate_to: localhost
|
||||
when:
|
||||
- patch_archive_path is defined
|
||||
- patch_archive_path.stat is defined
|
||||
- not patch_archive_path.stat.exists
|
||||
- keycloak_rhsso_enable
|
||||
- not keycloak_offline_install
|
||||
|
||||
## copy and unpack
|
||||
- name: Copy patch archive to target nodes
|
||||
ansible.builtin.copy:
|
||||
src: "{{ local_path.stat.path }}/{{ keycloak.patch_bundle }}"
|
||||
dest: "{{ patch_archive }}"
|
||||
owner: "{{ keycloak_service_user }}"
|
||||
group: "{{ keycloak_service_group }}"
|
||||
mode: 0750
|
||||
register: new_version_downloaded
|
||||
when:
|
||||
- not patch_archive_path.stat.exists
|
||||
- local_archive_path.stat is defined
|
||||
- local_archive_path.stat.exists
|
||||
become: yes
|
||||
|
||||
- name: "Check installed patches"
|
||||
ansible.builtin.include_tasks: rhsso_cli.yml
|
||||
vars:
|
||||
query: "patch info"
|
||||
|
||||
- name: "Perform patching"
|
||||
when:
|
||||
- cli_result is defined
|
||||
- cli_result.stdout is defined
|
||||
- rhsso_rhn_ids[keycloak_rhsso_version].latest_cp.v not in cli_result.stdout
|
||||
block:
|
||||
- name: "Apply patch {{ rhsso_rhn_ids[keycloak_rhsso_version].latest_cp.v }} to server"
|
||||
ansible.builtin.include_tasks: rhsso_cli.yml
|
||||
vars:
|
||||
query: "patch apply {{ patch_archive }}"
|
||||
|
||||
- name: "Restart server to ensure patch content is running"
|
||||
ansible.builtin.include_tasks: rhsso_cli.yml
|
||||
vars:
|
||||
query: "shutdown --restart"
|
||||
when:
|
||||
- cli_result.rc == 0
|
||||
|
||||
- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
retries: 25
|
||||
delay: 10
|
||||
|
||||
- name: "Query installed patch after restart"
|
||||
ansible.builtin.include_tasks: rhsso_cli.yml
|
||||
vars:
|
||||
query: "patch info"
|
||||
|
||||
- name: "Verify installed patch version"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- rhsso_rhn_ids[keycloak_rhsso_version].latest_cp.v not in cli_result.stdout
|
||||
fail_msg: "Patch installation failed"
|
||||
success_msg: "Patch installation successful"
|
||||
|
||||
- name: "Skipping patch"
|
||||
debug:
|
||||
msg: "Latest cumulative patch {{ rhsso_rhn_ids[keycloak_rhsso_version].latest_cp.v }} already installed, skipping patch installation."
|
||||
15
roles/keycloak/tasks/start_keycloak.yml
Normal file
15
roles/keycloak/tasks/start_keycloak.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: "Start {{ keycloak.service_name }} service"
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: yes
|
||||
state: started
|
||||
become: yes
|
||||
|
||||
- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
retries: 25
|
||||
delay: 10
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: "Stop SSO service"
|
||||
systemd:
|
||||
- name: "Stop {{ keycloak.service_name }}"
|
||||
ansible.builtin.systemd:
|
||||
name: keycloak
|
||||
enabled: yes
|
||||
state: stopped
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
- name: configure keycloak service script wrapper
|
||||
- name: "Configure {{ keycloak.service_name }} service script wrapper"
|
||||
become: yes
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: keycloak-service.sh.j2
|
||||
dest: "{{ keycloak_dest }}/keycloak-service.sh"
|
||||
owner: root
|
||||
@@ -9,9 +9,9 @@
|
||||
notify:
|
||||
- restart keycloak
|
||||
|
||||
- name: configure sysconfig file for keycloak service
|
||||
- name: "Configure sysconfig file for {{ keycloak.service_name }} service"
|
||||
become: yes
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: keycloak-sysconfig.j2
|
||||
dest: /etc/sysconfig/keycloak
|
||||
owner: root
|
||||
@@ -20,8 +20,8 @@
|
||||
notify:
|
||||
- restart keycloak
|
||||
|
||||
- name: configure systemd unit file for keycloak service
|
||||
template:
|
||||
- name: "Configure systemd unit file for {{ keycloak.service_name }} service"
|
||||
ansible.builtin.template:
|
||||
src: keycloak.service.j2
|
||||
dest: /etc/systemd/system/keycloak.service
|
||||
owner: root
|
||||
@@ -32,36 +32,30 @@
|
||||
notify:
|
||||
- restart keycloak
|
||||
|
||||
- name: reload systemd
|
||||
- name: Reload systemd
|
||||
become: yes
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: yes
|
||||
when: systemdunit.changed
|
||||
|
||||
- name: start keycloak
|
||||
systemd:
|
||||
name: keycloak
|
||||
enabled: yes
|
||||
state: started
|
||||
become: yes
|
||||
- name: "Start and wait for {{ keycloak.service_name }} service (first node db)"
|
||||
ansible.builtin.include_tasks: start_keycloak.yml
|
||||
run_once: yes
|
||||
when: keycloak_db_enabled
|
||||
|
||||
- name: "Start and wait for {{ keycloak.service_name }} service (remaining nodes)"
|
||||
ansible.builtin.include_tasks: start_keycloak.yml
|
||||
|
||||
- name: Check service status
|
||||
command: "systemctl status keycloak"
|
||||
ansible.builtin.command: "systemctl status keycloak"
|
||||
register: keycloak_service_status
|
||||
changed_when: False
|
||||
|
||||
- name: Verify service status
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- keycloak_service_status is defined
|
||||
- keycloak_service_status.stdout is defined
|
||||
|
||||
- meta: flush_handlers
|
||||
|
||||
- name: "Wait until Keycloak becomes active {{ keycloak.health_url }}"
|
||||
uri:
|
||||
url: "{{ keycloak.health_url }}"
|
||||
register: keycloak_status
|
||||
until: keycloak_status.status == 200
|
||||
retries: 25
|
||||
delay: 10
|
||||
- name: Flush handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# {{ ansible_managed }}
|
||||
[Unit]
|
||||
Description=Keycloak Server
|
||||
Description={{ keycloak.service_name }} Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
|
||||
@@ -633,7 +633,7 @@
|
||||
<subsystem xmlns="urn:wildfly:metrics:1.0" security-enabled="false" exposed-subsystems="*" prefix="${wildfly.metrics.prefix:jboss}"/>
|
||||
{% if keycloak_modcluster.enabled %}
|
||||
<subsystem xmlns="urn:jboss:domain:modcluster:5.0">
|
||||
<proxy name="default" advertise-socket="modcluster" listener="ajp" proxies="proxy1">
|
||||
<proxy name="default" advertise="false" listener="ajp" proxies="proxy1">
|
||||
<dynamic-load-provider>
|
||||
<load-metric type="cpu"/>
|
||||
</dynamic-load-provider>
|
||||
@@ -726,7 +726,7 @@
|
||||
<interface name="management">
|
||||
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
|
||||
</interface>
|
||||
<interface name="jgroups">
|
||||
<interface name="jgroups">
|
||||
{% if ansible_default_ipv4 is defined %}
|
||||
<subnet-match value="{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('net') }}"/>
|
||||
{% else %}
|
||||
@@ -744,7 +744,6 @@
|
||||
<socket-binding name="management-http" interface="management" port="{{ keycloak_management_http_port }}"/>
|
||||
<socket-binding name="management-https" interface="management" port="{{ keycloak_management_https_port }}"/>
|
||||
<socket-binding name="jgroups-tcp" interface="jgroups" port="{{ keycloak_jgroups_port }}"/>
|
||||
<socket-binding name="modcluster" multicast-address="${jboss.modcluster.multicast.address:224.0.1.105}" multicast-port="23364"/>
|
||||
<socket-binding name="txn-recovery-environment" port="4712"/>
|
||||
<socket-binding name="txn-status-manager" port="4713"/>
|
||||
<outbound-socket-binding name="mail-smtp">
|
||||
|
||||
@@ -546,7 +546,7 @@
|
||||
<subsystem xmlns="urn:wildfly:metrics:1.0" security-enabled="false" exposed-subsystems="*" prefix="${wildfly.metrics.prefix:jboss}"/>
|
||||
{% if keycloak_modcluster.enabled %}
|
||||
<subsystem xmlns="urn:jboss:domain:modcluster:5.0">
|
||||
<proxy name="default" advertise-socket="modcluster" listener="ajp" proxies="proxy1">
|
||||
<proxy name="default" advertise="false" listener="ajp" proxies="proxy1">
|
||||
<dynamic-load-provider>
|
||||
<load-metric type="cpu"/>
|
||||
</dynamic-load-provider>
|
||||
@@ -644,7 +644,6 @@
|
||||
<socket-binding name="https" port="{{ keycloak_https_port }}"/>
|
||||
<socket-binding name="management-http" interface="management" port="{{ keycloak_management_http_port }}"/>
|
||||
<socket-binding name="management-https" interface="management" port="{{ keycloak_management_https_port }}"/>
|
||||
<socket-binding name="modcluster" multicast-address="${jboss.modcluster.multicast.address:224.0.1.105}" multicast-port="23364"/>
|
||||
<socket-binding name="txn-recovery-environment" port="4712"/>
|
||||
<socket-binding name="txn-status-manager" port="4713"/>
|
||||
<outbound-socket-binding name="mail-smtp">
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
---
|
||||
# required variables for keycloak
|
||||
# administrator console password
|
||||
keycloak_admin_password:
|
||||
|
||||
# internal variables below
|
||||
rhsso_rhn_ids:
|
||||
'7.5.0': '101971'
|
||||
'7.5.1': '103836'
|
||||
'7.5.0':
|
||||
id: '101971'
|
||||
latest_cp:
|
||||
id: '103836'
|
||||
v: '7.5.1'
|
||||
|
||||
# locations
|
||||
keycloak_url: "http://{{ keycloak_host }}:{{ keycloak_http_port }}"
|
||||
@@ -17,8 +16,10 @@ keycloak:
|
||||
home: "{{ keycloak_jboss_home }}"
|
||||
config_dir: "{{ keycloak_config_dir }}"
|
||||
bundle: "{{ keycloak_rhsso_archive if keycloak_rhsso_enable else keycloak_archive }}"
|
||||
patch_bundle: "rh-sso-{{ rhsso_rhn_ids[keycloak_rhsso_version].latest_cp.v }}-patch.zip"
|
||||
service_name: "{{ 'rhsso' if keycloak_rhsso_enable else 'keycloak' }}"
|
||||
health_url: "{{ keycloak_management_url }}/health"
|
||||
cli_path: "{{ keycloak_jboss_home }}/bin/jboss-cli.sh"
|
||||
|
||||
# database
|
||||
keycloak_jdbc:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
keycloak_realm
|
||||
==============
|
||||
|
||||
Create realms and clients in [keycloak](https://keycloak.org/) or [Red Hat Single Sing-On](https://access.redhat.com/products/red-hat-single-sign-on) services.
|
||||
Create realms and clients in [keycloak](https://keycloak.org/) or [Red Hat Single Sign-On](https://access.redhat.com/products/red-hat-single-sign-on) services.
|
||||
|
||||
|
||||
Role Defaults
|
||||
@@ -9,13 +9,18 @@ Role Defaults
|
||||
|
||||
| Variable | Description | Default |
|
||||
|:---------|:------------|:---------|
|
||||
|`keycloak_admin_user` | Administration console user account | `admin` |
|
||||
|`keycloak_host` | hostname | `localhost` |
|
||||
|`keycloak_http_port` | HTTP port | `8080` |
|
||||
|`keycloak_https_port` | TLS HTTP port | `8443` |
|
||||
|`keycloak_auth_realm` | Name of the main authentication realm | `master` |
|
||||
|`keycloak_rhsso_enable` | Define service is an upstream(Keycloak) or RHSSO | `master` |
|
||||
|
||||
|`keycloak_admin_user`| Administration console user account | `admin` |
|
||||
|`keycloak_host`| hostname | `localhost` |
|
||||
|`keycloak_http_port`| HTTP port | `8080` |
|
||||
|`keycloak_https_port`| TLS HTTP port | `8443` |
|
||||
|`keycloak_auth_realm`| Name of the main authentication realm | `master` |
|
||||
|`keycloak_rhsso_enable`| Define service is an upstream(Keycloak) or RHSSO | `master` |
|
||||
|`keycloak_management_http_port`| Management port | `9990` |
|
||||
|`keycloak_auth_client`| Authentication client for configuration REST calls | `admin-cli` |
|
||||
|`keycloak_client_public`| Configure a public realm client | `True` |
|
||||
|`keycloak_client_web_origins`| Web origins for realm client | `+` |
|
||||
|`keycloak_url`| URL for configuration rest calls | `http://{{ keycloak_host }}:{{ keycloak_http_port }}` |
|
||||
|`keycloak_management_url`| URL for management console rest calls | `http://{{ keycloak_host }}:{{ keycloak_management_http_port }}` |
|
||||
|
||||
|
||||
Role Variables
|
||||
@@ -25,8 +30,8 @@ The following are a set of _required_ variables for the role:
|
||||
|
||||
| Variable | Description |
|
||||
|:---------|:------------|
|
||||
|`keycloak_admin_password`| Password for the administration console user account |
|
||||
|`keycloak_realm` | Name of the realm to be created |
|
||||
|`keycloak_admin_password`| Password for the administration console user account |
|
||||
|
||||
|
||||
The following variables are available for creating clients:
|
||||
@@ -37,6 +42,7 @@ The following variables are available for creating clients:
|
||||
|`keycloak_client_default_roles` | List of default role name for clients | `[]` |
|
||||
|`keycloak_client_users` | List of user/role mappings for a client | `[]` |
|
||||
|
||||
|
||||
The following variable are available for creating user federation:
|
||||
|
||||
| Variable | Description | Default |
|
||||
@@ -52,14 +58,15 @@ Variable formats
|
||||
```yaml
|
||||
- realm: <name of the realm in which user federation should be configured, required>
|
||||
name: <name of the user federation provider, required>
|
||||
provider_id: <Type of the user federation provider, required>
|
||||
provider_type: < Provider Type, default is set to org.keycloak.storage.UserStorageProvider>
|
||||
config: <Dictionary of supported configuration values, required>
|
||||
mappers: <List of supported configuration values, required>
|
||||
provider_id: <type of the user federation provider, required>
|
||||
provider_type: <Provider Type, default is set to org.keycloak.storage.UserStorageProvider>
|
||||
config: <dictionary of supported configuration values, required>
|
||||
mappers: <list of supported configuration values, required>
|
||||
```
|
||||
|
||||
Refer to [docs](https://docs.ansible.com/ansible/latest/collections/community/general/keycloak_user_federation_module.html) for information on supported variables.
|
||||
|
||||
|
||||
* `keycloak_clients`, a list of:
|
||||
|
||||
```yaml
|
||||
@@ -90,7 +97,8 @@ Refer to [docs](https://docs.ansible.com/ansible/latest/collections/community/ge
|
||||
realm: <name of the realm>
|
||||
```
|
||||
|
||||
For a comprehensive example, refer to the [playbook](playbooks/keycloak.yml).
|
||||
For a comprehensive example, refer to the [playbook](../../playbooks/keycloak_realm.yml).
|
||||
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
@@ -3,32 +3,37 @@
|
||||
keycloak_host: localhost
|
||||
keycloak_http_port: 8080
|
||||
keycloak_https_port: 8443
|
||||
keycloak_management_http_port: 9990
|
||||
keycloak_rhsso_enable: False
|
||||
|
||||
### Keycloak administration console user
|
||||
keycloak_admin_user: admin
|
||||
keycloak_auth_realm: master
|
||||
keycloak_auth_client: admin-cli
|
||||
|
||||
### List of Keycloak User Federation
|
||||
keycloak_user_federation: []
|
||||
# administrator console password, this is a required variable
|
||||
keycloak_admin_password: ''
|
||||
|
||||
### Keycloak realm client defaults
|
||||
### Keycloak realms, clients, roles, federation
|
||||
# list of clients to create in the realm
|
||||
#
|
||||
# Refer to the playbook for a comprehensive example.
|
||||
# Also refer to meta/argument_specs.yml for specifications.
|
||||
#
|
||||
# Each client has the form:
|
||||
# { name: '', roles: [], realm: '', public_client: bool, web_origins: '', users: [] }
|
||||
# where roles is a list of default role names for the client
|
||||
# and users is a list of account, see below for the format definition
|
||||
# an empty name will skip the creation of the client
|
||||
keycloak_clients:
|
||||
- name: ''
|
||||
roles: "{{ keycloak_client_default_roles }}"
|
||||
realm: "{{ keycloak_realm }}"
|
||||
public_client: "{{ keycloak_client_public }}"
|
||||
web_origins: "{{ keycloak_client_web_origins }}"
|
||||
users: "{{ keycloak_client_users }}"
|
||||
#
|
||||
#keycloak_clients:
|
||||
# - name: ''
|
||||
# roles: "{{ keycloak_client_default_roles }}"
|
||||
# realm: "{{ keycloak_realm }}"
|
||||
# public_client: "{{ keycloak_client_public }}"
|
||||
# web_origins: "{{ keycloak_client_web_origins }}"
|
||||
# users: "{{ keycloak_client_users }}"
|
||||
keycloak_clients: []
|
||||
|
||||
# list of roles to create in the client
|
||||
keycloak_client_default_roles: []
|
||||
@@ -45,3 +50,6 @@ keycloak_client_web_origins: '+'
|
||||
# where each client_role has the form:
|
||||
# { client: '', role: '', realm: '' }
|
||||
keycloak_client_users: []
|
||||
|
||||
### List of Keycloak User Federation
|
||||
keycloak_user_federation: []
|
||||
|
||||
93
roles/keycloak_realm/meta/argument_specs.yml
Normal file
93
roles/keycloak_realm/meta/argument_specs.yml
Normal file
@@ -0,0 +1,93 @@
|
||||
argument_specs:
|
||||
main:
|
||||
options:
|
||||
keycloak_host:
|
||||
# line 3 of keycloak_realm/defaults/main.yml
|
||||
default: "localhost"
|
||||
description: "hostname for rest calls"
|
||||
type: "str"
|
||||
keycloak_http_port:
|
||||
# line 4 of keycloak_realm/defaults/main.yml
|
||||
default: 8080
|
||||
description: "HTTP port"
|
||||
type: "int"
|
||||
keycloak_https_port:
|
||||
# line 5 of keycloak_realm/defaults/main.yml
|
||||
default: 8443
|
||||
description: "HTTPS port"
|
||||
type: "int"
|
||||
keycloak_management_http_port:
|
||||
# line 6 of keycloak_realm/defaults/main.yml
|
||||
default: 9990
|
||||
description: "Management port"
|
||||
type: "int"
|
||||
keycloak_rhsso_enable:
|
||||
# line 7 of keycloak_realm/defaults/main.yml
|
||||
default: false
|
||||
description: "Enable Red Hat Single Sign-on"
|
||||
type: "bool"
|
||||
keycloak_admin_user:
|
||||
# line 10 of keycloak_realm/defaults/main.yml
|
||||
default: "admin"
|
||||
description: "Administration console user account"
|
||||
type: "str"
|
||||
keycloak_auth_realm:
|
||||
# line 11 of keycloak_realm/defaults/main.yml
|
||||
default: "master"
|
||||
description: "Name of the main authentication realm"
|
||||
type: "str"
|
||||
keycloak_auth_client:
|
||||
# line 12 of keycloak_realm/defaults/main.yml
|
||||
default: "admin-cli"
|
||||
description: "Authentication client for configuration REST calls"
|
||||
type: "str"
|
||||
keycloak_client_default_roles:
|
||||
# line 36 of keycloak_realm/defaults/main.yml
|
||||
default: "[]"
|
||||
description: "List of roles to configure as client default"
|
||||
type: "list"
|
||||
keycloak_client_public:
|
||||
# line 39 of keycloak_realm/defaults/main.yml
|
||||
default: true
|
||||
description: "Configure a public realm client"
|
||||
type: "bool"
|
||||
keycloak_client_web_origins:
|
||||
# line 42 of keycloak_realm/defaults/main.yml
|
||||
default: "+"
|
||||
description: "Web origins for realm client"
|
||||
type: "str"
|
||||
keycloak_client_users:
|
||||
# line 49 of keycloak_realm/defaults/main.yml
|
||||
default: "[]"
|
||||
description: "List of users to configure in the realm client"
|
||||
type: "list"
|
||||
keycloak_user_federation:
|
||||
# line 52 of keycloak_realm/defaults/main.yml
|
||||
default: "[]"
|
||||
description: "List of user federations to configure in the realm"
|
||||
type: "list"
|
||||
keycloak_admin_password:
|
||||
# line 5 of keycloak_realm/vars/main.yml
|
||||
required: true
|
||||
description: "Password for the administration console user account"
|
||||
type: "str"
|
||||
keycloak_realm:
|
||||
# line 8 of keycloak_realm/vars/main.yml
|
||||
required: true
|
||||
description: "Name of the realm to be configured"
|
||||
type: "str"
|
||||
keycloak_clients:
|
||||
# line 11 of keycloak_realm/vars/main.yml
|
||||
default: "[]"
|
||||
description: "List of client declarations for the realm"
|
||||
type: "list"
|
||||
keycloak_url:
|
||||
# line 14 of keycloak_realm/vars/main.yml
|
||||
default: "http://{{ keycloak_host }}:{{ keycloak_http_port }}"
|
||||
description: "URL for configuration rest calls"
|
||||
type: "str"
|
||||
keycloak_management_url:
|
||||
# line 15 of keycloak_realm/vars/main.yml
|
||||
default: "http://{{ keycloak_host }}:{{ keycloak_management_http_port }}"
|
||||
description: "URL for management console rest calls"
|
||||
type: "str"
|
||||
@@ -3,7 +3,7 @@ galaxy_info:
|
||||
role_name: keycloak_realm
|
||||
namespace: middleware_automation
|
||||
author: Romain Pelisse, Guido Grazioli
|
||||
description: Create realms and clients in keycloak or Red Hat Single Sing-On
|
||||
description: Create realms and clients in keycloak or Red Hat Single Sign-On
|
||||
company: Red Hat, Inc.
|
||||
|
||||
license: Apache License 2.0
|
||||
@@ -13,7 +13,6 @@ galaxy_info:
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
- 8
|
||||
|
||||
galaxy_tags:
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
---
|
||||
- name: Generate keycloak auth token
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/realms/master/protocol/openid-connect/token"
|
||||
method: POST
|
||||
body: "client_id={{ keycloak_auth_client }}&username={{ keycloak_admin_user }}&password={{ keycloak_admin_password }}&grant_type=password"
|
||||
validate_certs: no
|
||||
no_log: True
|
||||
register: keycloak_auth_response
|
||||
until: keycloak_auth_response.status == 200
|
||||
retries: 5
|
||||
delay: 2
|
||||
|
||||
- name: "Determine if realm exists"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms/{{ keycloak_realm }}"
|
||||
method: GET
|
||||
status_code:
|
||||
@@ -23,7 +24,7 @@
|
||||
register: keycloak_realm_exists
|
||||
|
||||
- name: Create Realm
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms"
|
||||
method: POST
|
||||
body: "{{ lookup('template','realm.json.j2') }}"
|
||||
@@ -47,6 +48,7 @@
|
||||
provider_type: "{{ item.provider_type | default(org.keycloak.storage.UserStorageProvider) }}"
|
||||
config: "{{ item.config }}"
|
||||
mappers: "{{ item.mappers | default(omit) }}"
|
||||
no_log: True
|
||||
register: create_user_federation_result
|
||||
loop: "{{ keycloak_user_federation | flatten }}"
|
||||
when: keycloak_user_federation is defined
|
||||
@@ -78,19 +80,20 @@
|
||||
public_client: "{{ item.public_client | default(False) }}"
|
||||
protocol: "{{ item.protocol | default(omit) }}"
|
||||
state: present
|
||||
no_log: True
|
||||
register: create_client_result
|
||||
loop: "{{ keycloak_clients | flatten }}"
|
||||
when: (item.name is defined and item.client_id is defined) or (item.name is defined and item.id is defined)
|
||||
|
||||
- name: Create client roles
|
||||
include_tasks: manage_client_roles.yml
|
||||
ansible.builtin.include_tasks: manage_client_roles.yml
|
||||
loop: "{{ keycloak_clients | flatten }}"
|
||||
loop_control:
|
||||
loop_var: client
|
||||
when: "'roles' in client"
|
||||
|
||||
- name: Create client users
|
||||
include_tasks: manage_client_users.yml
|
||||
ansible.builtin.include_tasks: manage_client_users.yml
|
||||
loop: "{{ keycloak_clients | flatten }}"
|
||||
loop_control:
|
||||
loop_var: client
|
||||
|
||||
@@ -10,3 +10,4 @@
|
||||
auth_password: "{{ keycloak_admin_password }}"
|
||||
state: present
|
||||
loop: "{{ client.roles | flatten }}"
|
||||
no_log: True
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
- name: Manage Users
|
||||
include_tasks: manage_user.yml
|
||||
ansible.builtin.include_tasks: manage_user.yml
|
||||
loop: "{{ client.users | flatten }}"
|
||||
loop_control:
|
||||
loop_var: user
|
||||
|
||||
- name: Manage User Roles
|
||||
include_tasks: manage_user_roles.yml
|
||||
ansible.builtin.include_tasks: manage_user_roles.yml
|
||||
loop: "{{ client.users | flatten }}"
|
||||
loop_control:
|
||||
loop_var: user
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: "Check if User Already Exists"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms/{{ keycloak_realm }}/users?username={{ user.username }}"
|
||||
validate_certs: no
|
||||
headers:
|
||||
@@ -8,7 +8,7 @@
|
||||
register: keycloak_user_search_result
|
||||
|
||||
- name: "Create User"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms/{{ keycloak_realm }}/users"
|
||||
method: POST
|
||||
body:
|
||||
@@ -26,7 +26,7 @@
|
||||
when: keycloak_user_search_result.json | length == 0
|
||||
|
||||
- name: "Get User"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms/{{ keycloak_realm }}/users?username={{ user.username }}"
|
||||
validate_certs: no
|
||||
headers:
|
||||
@@ -34,7 +34,7 @@
|
||||
register: keycloak_user
|
||||
|
||||
- name: "Update User Password"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms/{{ keycloak_realm }}/users/{{ (keycloak_user.json | first).id }}/reset-password"
|
||||
method: PUT
|
||||
body:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: "Get Realm for role"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms/{{ client_role.realm }}"
|
||||
method: GET
|
||||
status_code:
|
||||
@@ -11,7 +11,7 @@
|
||||
register: client_role_realm
|
||||
|
||||
- name: Check if Mapping is available
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms/{{ client_role.realm }}/users/{{ (keycloak_user.json | first).id }}/role-mappings/clients/{{ (create_client_result.results | selectattr('end_state.clientId', 'equalto', client_role.client) | list | first).end_state.id }}/available"
|
||||
method: GET
|
||||
status_code:
|
||||
@@ -22,7 +22,7 @@
|
||||
register: client_role_user_available
|
||||
|
||||
- name: "Create Role Mapping"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms/{{ client_role.realm }}/users/{{ (keycloak_user.json | first).id }}/role-mappings/clients/{{ (create_client_result.results | selectattr('end_state.clientId', 'equalto', client_role.client) | list | first).end_state.id }}"
|
||||
method: POST
|
||||
body:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: "Get User {{ user.username }}"
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/admin/realms/{{ keycloak_realm }}/users?username={{ user.username }}"
|
||||
headers:
|
||||
validate_certs: no
|
||||
@@ -8,18 +8,19 @@
|
||||
register: keycloak_user
|
||||
|
||||
- name: Refresh keycloak auth token
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "{{ keycloak_url }}/auth/realms/master/protocol/openid-connect/token"
|
||||
method: POST
|
||||
body: "client_id={{ keycloak_auth_client }}&username={{ keycloak_admin_user }}&password={{ keycloak_admin_password }}&grant_type=password"
|
||||
validate_certs: no
|
||||
register: keycloak_auth_response
|
||||
no_log: True
|
||||
until: keycloak_auth_response.status == 200
|
||||
retries: 5
|
||||
delay: 2
|
||||
|
||||
- name: "Manage Client Role Mapping for {{ user.username }}"
|
||||
include_tasks: manage_user_client_roles.yml
|
||||
ansible.builtin.include_tasks: manage_user_client_roles.yml
|
||||
loop: "{{ user.client_roles | flatten }}"
|
||||
loop_control:
|
||||
loop_var: client_role
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
---
|
||||
# vars file for keycloak_realm
|
||||
|
||||
# administrator console password, this is a required variable
|
||||
keycloak_admin_password:
|
||||
|
||||
# name of the realm to create, this is a required variable
|
||||
keycloak_realm:
|
||||
|
||||
# keycloak realm clients, this is a required variable
|
||||
keycloak_clients:
|
||||
|
||||
# other settings
|
||||
keycloak_url: "http://{{ keycloak_host }}:{{ keycloak_http_port }}"
|
||||
keycloak_management_url: "http://{{ keycloak_host }}:{{ keycloak_management_http_port }}"
|
||||
keycloak_rhsso_enable: False
|
||||
Reference in New Issue
Block a user