Skip to content

Commit

Permalink
fixup: several fixes, playbook, workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjeffman committed May 19, 2023
1 parent af66fc9 commit ff8207d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/multihost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ jobs:
- name: Run vagrant up
run: vagrant up

- name: Get vagrant ssh config and IP addresses
- name: Get vagrant ssh config
run: |
vagrant ssh-config | tee "vagrant-ssh" | ./get_ip.sh > inventory/group_vars/all.yml
vagrant ssh-config | tee "vagrant-ssh"
- name: Get nodes IP addresses
run: |
./get_ip.sh server replica client | tee "inventory/group_vars/all.yml"
- name: Test host connection
run: |
Expand All @@ -72,15 +76,15 @@ jobs:
if: failure()
working-directory: .
run: |
ssh -F tests/multihost/vagrant-ssh server.ipa.test "sudo chmod a+r /var/log/*.log"
ssh -F tests/multihost/vagrant-ssh server "sudo chmod a+r /var/log/*.log"
mkdir -p logs/server-logs
scp -F tests/multihost/vagrant-ssh vagrant@server.ipa.test:/var/log/{ipaserver,ipaclient}-install.log logs/server-logs || true
ssh -F tests/multihost/vagrant-ssh rep-01.ipa.test "sudo chmod a+r /var/log/*.log"
scp -F tests/multihost/vagrant-ssh vagrant@server:/var/log/{ipaserver,ipaclient}-install.log logs/server-logs || true
ssh -F tests/multihost/vagrant-ssh replica "sudo chmod a+r /var/log/*.log"
mkdir -p logs/replica-logs
scp -F tests/multihost/vagrant-ssh vagrant@rep-01.ipa.test:/var/log/{ipareplica,ipaclient}-install.log logs/replica-logs || true
ssh -F tests/multihost/vagrant-ssh cli-01.ipa.test "sudo chmod a+r /var/log/*.log"
scp -F tests/multihost/vagrant-ssh vagrant@replica:/var/log/{ipareplica,ipaclient}-install.log logs/replica-logs || true
ssh -F tests/multihost/vagrant-ssh clente.ipa.test "sudo chmod a+r /var/log/*.log"
mkdir -p logs/client-logs
scp -F tests/multihost/vagrant-ssh vagrant@cli-01.ipa.test:/var/log/ipaclient-install.log logs/client-logs || true
scp -F tests/multihost/vagrant-ssh vagrant@client:/var/log/ipaclient-install.log logs/client-logs || true
# tar czvf multihost-logs.tar.gz logs
- name: Save artifacts
Expand Down
10 changes: 5 additions & 5 deletions tests/multihost/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Vagrant.configure("2") do |config|
# boot timeout (in seconds).
config.vm.boot_timeout = 25 * 60

config.vm.define "server.ipa.test" do |server|
config.vm.define "server" do |server|
server.vm.hostname = "server.ipa.test"
server.vm.provision "shell",
inline: "hostnamectl set-hostname server.ipa.test"
Expand All @@ -27,8 +27,8 @@ Vagrant.configure("2") do |config|
inline: "dnf install --downloadonly -y freeipa-server python3-libselinux freeipa-server-dns freeipa-server-trust-ad firewalld"
end

config.vm.define "rep-01.ipa.test" do |replica|
replica.vm.hostname="rep-01.ipa.test"
config.vm.define "replica" do |replica|
replica.vm.hostname="replica"
replica.vm.provision "shell",
inline: "hostnamectl set-hostname rep-01.ipa.test"
replica.vm.provision "shell",
Expand All @@ -37,8 +37,8 @@ Vagrant.configure("2") do |config|
inline: "dnf install --downloadonly -y freeipa-server python3-libselinux freeipa-server-dns freeipa-server-trust-ad firewalld"
end

config.vm.define "cli-01.ipa.test" do |client|
client.vm.hostname="cli-01.ipa.test"
config.vm.define "client" do |client|
client.vm.hostname="client"
client.vm.provision "shell",
inline: "hostnamectl set-hostname cli-01.ipa.test"
client.vm.provision "shell",
Expand Down
16 changes: 6 additions & 10 deletions tests/multihost/get_ip.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/bin/sh

INPUT=${1:--}

echo "---"
# shellcheck disable=SC2002
cat "${INPUT}" | \
grep HostName -B1 | \
sed -e "/^--/d" \
-e "/^Host/N;s/\n/:/;s/Host \([a-zA-Z0-9.]*\)/\1/;s/ *HostName \(.*\)/ \1/" \
-e "s/server.*:/server_ip:/" \
-e "s/cli-.*:/client_ip:/" \
-e "s/rep-.*:/replica_ip:/"

while [ -n "${1}" ]
do
echo "${1}_ip: $(vagrant ssh -c "hostname -I" "${1}")"
shift
done
26 changes: 13 additions & 13 deletions tests/multihost/inventory/vagrant-inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ all:
# IPA First (CA Renewal) Server
ipaserver:
hosts:
"server.ipa.test":
"server":
# Ansible connection configuration
ansible_ssh_user: vagrant
ansible_ssh_private_key_file: ".vagrant/machines/server/libvirt/private_key"
Expand All @@ -30,23 +30,23 @@ all:
ipaserver_setup_dns: "{{ lookup('env', 'ipaserver_setup_dns') | default(true, True) | bool }}"
ipaserver_auto_forwarders: "{{ lookup('env', 'ipaserver_auto_forwarders') | default(true, True) | bool }}"
ipaserver_no_forwarders: "{{ lookup('env', 'ipaserver_no_forwarders') | default(false, True) | bool }}"
ipaserver_forwarders: "{{ lookup('env', 'ipaserver_forwarders') | default([], True) }}"
ipaserver_forwarders: "{{ lookup('env', 'ipaserver_forwarders') | default(omit, True) }}"
ipaserver_auto_reverse: "{{ lookup('env', 'ipaserver_auto_reverse') | default(true, True) | bool }}"
# For easier setup of DNS keep it set to 'true'
ipaserver_allow_zone_overlap: true
# DNSSEC must be set to 'false' for AD trust
ipaserver_no_dnssec_validation: true
# trust vars
ipaserver_setup_adtrust: "{{ lookup('env', 'ipaserver_setup_adtrust') | default(false) | bool }}"
ipaserver_netbios_name: "{{ lookup('env', 'ipaserver_netbios_name') | default('IPA') }}"
ipaserver_setup_adtrust: "{{ lookup('env', 'ipaserver_setup_adtrust') | default(false, True) | bool }}"
ipaserver_netbios_name: "{{ lookup('env', 'ipaserver_netbios_name') | default('IPA', True) }}"
# disable 'allow all' HBAC rule
ipaserver_no_hbac_allow: true
# other vars
ipaserver_random_serial_numbers: "{{ lookup('env', 'ipaserver_random_serial_numbers:') | default(true, True) | bool }}"
# IPA Replica Servers
ipareplicas:
hosts:
"rep-01.ipa.test":
"repplica":
# Ansible connection configuration
ansible_ssh_user: vagrant
ansible_ssh_private_key_file: ".vagrant/machines/replica/libvirt/private_key"
Expand All @@ -60,20 +60,20 @@ all:
ipareplica_setup_dns: "{{ lookup('env', 'ipareplica_setup_dns') | default(false, True) | bool }}"
ipareplica_auto_forwarders: "{{ lookup('env', 'ipareplica_auto_forwarders') | default(true, True) | bool }}"
ipareplica_no_forwarders: "{{ lookup('env', 'ipareplica_no_forwarders') | default(false, True) | bool }}"
ipareplica_forwarders: "{{ lookup('env', 'ipareplica_forwarders') | default([], True) }}"
ipareplica_forwarders: "{{ lookup('env', 'ipareplica_forwarders') | default(omit, True) }}"
ipareplica_auto_reverse: "{{ lookup('env', 'ipareplica_auto_reverse') | default(true, True) | bool }}"
# Trust backup
ipareplica_setup_adtrust: "{{ lookup('env', 'ipaserver_setup_adtrust') | default(false) | bool }}"
ipareplica_netbios_name: "{{ lookup('env', 'ipaserver_netbios_name') | default('IPA') }}"
ipareplica_setup_adtrust: "{{ lookup('env', 'ipaserver_setup_adtrust') | default(false, True) | bool }}"
ipareplica_netbios_name: "{{ lookup('env', 'ipaserver_netbios_name') | default('IPA', True) }}"
# Update IP addressess
ipasssd_enable_dns_updates: true
# Automatically handle DNS nameservers (ansible-freeipa v1.9.0+)
ipaclient_configure_dns_resolver: "{{ ipaserver_setup_dns | default(false) }}"
ipaclient_dns_servers: ["{{ server_ip if (ipaserver_setup_dns | default(false)) else omit}}"]
ipaclient_configure_dns_resolver: "{{ lookup('env', 'ipareplica_setup_dns') | default(false, True) | bool }}"
ipaclient_dns_servers: "{{ server_ip if (lookup('env', 'ipareplica_setup_dns') | default(false, True) | bool) else default(omit) }}"
# IPA Client hosts
ipaclients:
hosts:
"cli-01.ipa.test":
"client":
# Ansible connection configuration
ansible_ssh_user: vagrant
ansible_ssh_private_key_file: ".vagrant/machines/client/libvirt/private_key"
Expand All @@ -83,5 +83,5 @@ all:
# Add client DNS entries
ipasssd_enable_dns_updates: true
# Automatically handle DNS nameservers (ansible-freeipa v1.9.0+)
ipaclient_configure_dns_resolver: "{{ ipaserver_setup_dns | default(false) }}"
ipaclient_dns_servers: ["{{ server_ip if (ipaserver_setup_dns | default(false)) else omit}}"]
ipaclient_configure_dns_resolver: "{{ lookup('env', 'ipareplica_setup_dns') | default(false, True) | bool }}"
ipaclient_dns_servers: "{{ server_ip if (lookup('env', 'ipareplica_setup_dns') | default(false, True) | bool) else default(omit) }}"

0 comments on commit ff8207d

Please sign in to comment.