forked from bennojoy/kerberos_server
-
Notifications
You must be signed in to change notification settings - Fork 2
support deployment of replica KDCs incl. kprop sync script and new molecule test scenario #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lhoss
wants to merge
34
commits into
ultratendency:master
Choose a base branch
from
scigility:support_multiple_kdcs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
f141197
Fix yamlint warning
NadOby d2acafc
Replace categories by galaxy tags
NadOby 03110f9
Fix shell set pipefail lines
NadOby 4422c3a
Fix for molecule inconsistency
NadOby aabb172
Fix molecule version
NadOby a926b1a
Add flake8 installation
NadOby e45af56
Travis CI moved to python 3.6
NadOby cde5ca2
FIx ansible deprecation warning
NadOby 9983b13
fix octal file mode checks (to work in both ansible v2.7.x and v2.8.x)
lhoss 4418f4d
update to latest molecule 2.22rc3 (that fixes flake8 and cerberus dep…
lhoss 49caf11
update to recent molecule 2.22 stable version
lhoss cc5d8a2
WIP: support for multiple KDCs (untested)
lhoss 8532c75
fix lint issues (trailing spaces)
lhoss 4f07361
proper kdc replication deployment (todo fix issue in kprop_kdc_replic…
lhoss 39fb6a5
fixed: keytab distribution to the replicas now done using 2 tasks (fe…
lhoss 51a7155
configurable krb5.conf 'rdns' parameter (which must be disabled for t…
lhoss 4cee94e
lint cleanups
lhoss 9a0e38a
new molecule scenario kdc-with-replica to run a 2 docker nodes test (…
lhoss 395bc5b
travis to run the new molecule scenario kdc-with-replica
lhoss a0f5042
also the replica kprop logic moved into the kprop include
lhoss 3975e44
created new include tasks to idempotently create a host principal and…
lhoss c93a91c
add extra check for missing keytab file (to avoid failing klist | grep)
lhoss 8a3dbdb
run the script kprop_kdc_replica_sync.sh once during deployment
lhoss 93fa25f
initial molecule tests for kdc-with-replica, incl. test if the sync s…
lhoss 8296d5f
fixed new lint warnings
lhoss edc2ec2
fix idempotence of the task running the kprop script
lhoss 9235119
fix molecule mode checks to be compatible for python 3.6
lhoss e2d39a7
review fixes part1
lhoss e8df6ad
fix octal file mode checks (now working in both ansible v2.7.x and v2…
lhoss 16b34a3
revert disabling the 'default' test scenario (so that now 2 test scen…
lhoss fa04caf
use geerlingguy's image also in default scenario and set pre_build_im…
lhoss 1a09899
principal and keytab tasks now selfcontained; keytab creation optiona…
lhoss a52949b
enable lint checks
lhoss 33d032f
fix molecule test check (due to change in container/host name)
lhoss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,17 @@ | ||
| --- | ||
| - name: restart kerberos | ||
| - name: restart kdc | ||
| service: | ||
| name: "{{ item }}" | ||
| name: "{{ kerberos_kdc_service }}" | ||
| state: restarted | ||
| with_items: "{{ kerberos_service }}" | ||
|
|
||
| - name: restart kadmin | ||
| service: | ||
| name: "{{ kerberos_kadmin_service }}" | ||
| state: restarted | ||
| when: is_master_host | ||
|
|
||
| - name: restart kprop | ||
| service: | ||
| name: "{{ kerberos_kprop_service }}" | ||
| state: restarted | ||
| when: is_replica_host |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| --- | ||
| galaxy_info: | ||
| author: "Matthias Baumann & Jan Hentschel" | ||
| description: "Role to install kerberos server(s)" | ||
| company: Ultra Tendency GmbH | ||
| license: BSD 3-Clause | ||
| min_ansible_version: 1.4 | ||
| platforms: | ||
| - name: EL | ||
| versions: | ||
| - 7 | ||
| categories: | ||
| galaxy_tags: | ||
| - kerberos | ||
| - kdc | ||
| dependencies: [] | ||
| dependencies: [ ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Molecule managed | ||
|
|
||
| {% if item.registry is defined %} | ||
| FROM {{ item.registry.url }}/{{ item.image }} | ||
| {% else %} | ||
| FROM {{ item.image }} | ||
| {% endif %} | ||
|
|
||
| RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ | ||
| elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \ | ||
| elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ | ||
| elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ | ||
| elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ | ||
| elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| ******* | ||
| Docker driver installation guide | ||
| ******* | ||
|
|
||
| Requirements | ||
| ============ | ||
|
|
||
| * Docker Engine | ||
|
|
||
| Install | ||
| ======= | ||
|
|
||
| Please refer to the `Virtual environment`_ documentation for installation best | ||
| practices. If not using a virtual environment, please consider passing the | ||
| widely recommended `'--user' flag`_ when invoking ``pip``. | ||
|
|
||
| .. _Virtual environment: https://virtualenv.pypa.io/en/latest/ | ||
| .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| $ pip install 'molecule[docker]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| --- | ||
| dependency: | ||
| name: galaxy | ||
| driver: | ||
| name: docker | ||
| lint: | ||
| name: yamllint | ||
| # Using geerlingguy's image that provides centos7 with ansible AND systemd | ||
| platforms: | ||
| - name: "${MOLECULE_DISTRO:-centos7}-01.local" | ||
| image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" | ||
| pre_build_image: True | ||
| privileged: True | ||
| volume_mounts: | ||
| - "/sys/fs/cgroup:/sys/fs/cgroup:rw" | ||
| command: "/usr/sbin/init" | ||
| groups: | ||
| - kdc_master | ||
| - kdcs | ||
| networks: | ||
| - name: molecule | ||
| network_mode: bridge | ||
|
|
||
| - name: "${MOLECULE_DISTRO:-centos7}-02.local" | ||
| image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" | ||
|
lhoss marked this conversation as resolved.
|
||
| pre_build_image: True | ||
| privileged: True | ||
| volume_mounts: | ||
| - "/sys/fs/cgroup:/sys/fs/cgroup:rw" | ||
| command: "/usr/sbin/init" | ||
| groups: | ||
| - kdc_replica | ||
| - kdcs | ||
| networks: | ||
| - name: molecule | ||
| network_mode: bridge | ||
|
|
||
| provisioner: | ||
| name: ansible | ||
| options: | ||
| diff: true | ||
| v: True | ||
| inventory: | ||
| group_vars: | ||
| kdcs: | ||
| # Ensure that the master node is the first in the list (not guaranteed in 'groups.kdcs') | ||
| kerberos_server_kdcs: "{{ groups.kdc_master + groups.kdc_replica }}" | ||
| kerberos_server_kadmin_host: "{{ groups.kdc_master[0] }}" | ||
| kerberos_server_realm_name: EXAMPLE.COM | ||
| kerberos_server_domain: "local" | ||
| # To make molecule tests work, need to disable keberos reverse DNS, because docker builtin DNS is inconsistent | ||
| # Details: Returned PTR were suffixed with the network name, except for the own host (resolved by /etc/hosts) | ||
| kerberos_server_rdns: "false" | ||
| lint: | ||
| name: ansible-lint | ||
| scenario: | ||
| name: kdc-with-replica | ||
| test_sequence: | ||
| - lint | ||
| - destroy | ||
| - dependency | ||
| - syntax | ||
| - create | ||
| - prepare | ||
| - converge | ||
| - idempotence | ||
| - side_effect | ||
| - verify | ||
| - destroy | ||
| verifier: | ||
| name: testinfra | ||
| lint: | ||
| name: flake8 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| - name: Converge | ||
| hosts: all | ||
| roles: | ||
| - role: kerberos_server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import os | ||
|
|
||
| import testinfra.utils.ansible_runner | ||
|
|
||
| testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
| os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') | ||
|
|
||
|
|
||
| # tests on each kdc | ||
| def test_kdc_conf(host): | ||
| kdc_conf = host.file("/var/kerberos/krb5kdc/kdc.conf") | ||
|
|
||
| assert kdc_conf.exists | ||
| assert kdc_conf.is_file | ||
| assert kdc_conf.user == 'root' | ||
| assert kdc_conf.group == 'root' | ||
| assert kdc_conf.mode == 0o600 | ||
|
|
||
|
|
||
| def test_krb5_conf(host): | ||
| krb5_conf = host.file("/etc/krb5.conf") | ||
|
|
||
| assert krb5_conf.exists | ||
| assert krb5_conf.is_file | ||
| assert krb5_conf.user == 'root' | ||
| assert krb5_conf.group == 'root' | ||
| assert krb5_conf.mode == 0o644 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import os | ||
| import pytest | ||
|
|
||
| import testinfra.utils.ansible_runner | ||
|
|
||
| testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
| os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('kdc_master') | ||
|
|
||
| kdc_replica_1 = testinfra.utils.ansible_runner.AnsibleRunner( | ||
| os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('kdc_replica')[0] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('svc', [ | ||
| 'krb5kdc', | ||
| 'kadmin' | ||
| ]) | ||
| def test_services(host, svc): | ||
| service = host.service(svc) | ||
|
|
||
| assert service.is_running | ||
| assert service.is_enabled | ||
|
|
||
|
|
||
| def test_kprop_kdump_file_written(host): | ||
| kprop_kdump_file = host.file("/var/kerberos/krb5kdc/slave_datatrans") | ||
|
|
||
| assert kprop_kdump_file.exists | ||
| assert kprop_kdump_file.user == 'root' | ||
| assert kprop_kdump_file.group == 'root' | ||
| assert kprop_kdump_file.mode == 0o600 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('content', [ | ||
| "Database propagation to "+kdc_replica_1+": SUCCEEDED", | ||
| ]) | ||
| def test_kprop_kdc_replica_sync_successful(host, content): | ||
| kprop_kdc_replica_sync_log = host.file("/var/log/kprop_kdc_replica_sync.log") | ||
|
|
||
| assert kprop_kdc_replica_sync_log.exists | ||
| assert kprop_kdc_replica_sync_log.contains(content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import os | ||
| import pytest | ||
|
|
||
| import testinfra.utils.ansible_runner | ||
|
|
||
| testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
| os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('kdc_replica') | ||
|
|
||
| kdc_master_1 = testinfra.utils.ansible_runner.AnsibleRunner( | ||
| os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('kdc_master')[0] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('svc', [ | ||
| 'krb5kdc', | ||
| 'kprop' | ||
| ]) | ||
| def test_services(host, svc): | ||
| service = host.service(svc) | ||
|
|
||
| assert service.is_running | ||
| assert service.is_enabled | ||
|
|
||
|
|
||
| def test_kpropd_acl(host): | ||
| kpropd_acl = host.file("/var/kerberos/krb5kdc/kpropd.acl") | ||
|
|
||
| assert kpropd_acl.exists | ||
| assert kpropd_acl.is_file | ||
| assert kpropd_acl.user == 'root' | ||
| assert kpropd_acl.group == 'root' | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('content', [ | ||
| "host/"+kdc_master_1+"@", | ||
| ]) | ||
| def test_kpropd_acl_content(host, content): | ||
| kpropd_acl = host.file("/var/kerberos/krb5kdc/kpropd.acl") | ||
|
|
||
| assert kpropd_acl.contains(content) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.