Skip to content

Commit

Permalink
Fix reverse_proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd-ntrf committed Jul 14, 2023
1 parent 2b040ca commit 8676d76
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ profile::nfs::client::server_ip: "%{alias('terraform.tag_ip.nfs.0')}"
profile::nfs::server::devices: "%{alias('terraform.volumes.nfs')}"

profile::reverse_proxy::domain_name: "%{alias('terraform.data.domain_name')}"

profile::reverse_proxy::subdomains:
ipa: "ipa.int.%{lookup('terraform.data.domain_name')}"
mokey: "%{lookup('terraform.tag_ip.mgmt.0')}:%{lookup('profile::freeipa::mokey::port')}"
Expand Down
32 changes: 16 additions & 16 deletions site/profile/manifests/reverse_proxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
require => Yumrepo['caddy-copr-repo'],
}

$ipa_server_ip = lookup('profile::freeipa::client::server_ip')
$mokey_port = lookup('profile::freeipa::mokey::port')

if $domain_name in $::facts['letsencrypt'] {
$fullchain_exists = $::facts['letsencrypt'][$domain_name]['fullchain']
$privkey_exists = $::facts['letsencrypt'][$domain_name]['privkey']
Expand Down Expand Up @@ -81,20 +78,22 @@
| EOT
}

if $main2sub_redir != '' {
file { '/etc/caddy/conf.d/host.conf':
owner => 'root',
group => 'root',
mode => '0644',
seltype => 'httpd_config_t',
require => File['/etc/caddy/conf.d'],
content => @("END"),
${domain_name} {
import tls
redir https://${main2sub_redir}.${domain_name}
}
END
$host_conf_template = @("END")
${domain_name} {
import tls
<% if ${main2sub_redir} != '' { -%>
redir https://${main2sub_redir}.${domain_name}
<% } -%>
}
|END

file { '/etc/caddy/conf.d/host.conf':
owner => 'root',
group => 'root',
mode => '0644',
seltype => 'httpd_config_t',
require => File['/etc/caddy/conf.d'],
content => inline_epp($host_conf_template),
}

$caddy_conf_template = @(EOT)
Expand Down Expand Up @@ -135,6 +134,7 @@
],
subscribe => [
File['/etc/caddy/Caddyfile'],
File['/etc/caddy/conf.d/host.conf'],
] + $subdomains.map |$key, $value| { File["/etc/caddy/conf.d/${key}.conf"] },
}
}

0 comments on commit 8676d76

Please sign in to comment.