Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 734fcb8cf4 | |||
| f933660d3b | |||
| 3370aff38f | |||
| 1a907467e9 | |||
| cf25a20a92 |
@@ -77,6 +77,7 @@ profiles::yum::global::repos:
|
|||||||
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-internal/
|
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-internal/
|
||||||
gpgcheck: false
|
gpgcheck: false
|
||||||
mirrorlist: absent
|
mirrorlist: absent
|
||||||
|
metadata_expire: '60'
|
||||||
rpm-vendor:
|
rpm-vendor:
|
||||||
name: rpm-vendor
|
name: rpm-vendor
|
||||||
descr: rpm-vendor repository
|
descr: rpm-vendor repository
|
||||||
@@ -84,6 +85,7 @@ profiles::yum::global::repos:
|
|||||||
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-vendor/
|
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-vendor/
|
||||||
gpgcheck: false
|
gpgcheck: false
|
||||||
mirrorlist: absent
|
mirrorlist: absent
|
||||||
|
metadata_expire: '60'
|
||||||
# Per-release variants, resolved from the host's EL major version so el8
|
# Per-release variants, resolved from the host's EL major version so el8
|
||||||
# hosts pull rpm-internal-el8/rpm-vendor-el8, el9 hosts el9, etc.
|
# hosts pull rpm-internal-el8/rpm-vendor-el8, el9 hosts el9, etc.
|
||||||
rpm-internal-release:
|
rpm-internal-release:
|
||||||
@@ -93,6 +95,7 @@ profiles::yum::global::repos:
|
|||||||
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-internal-el%{facts.os.release.major}/
|
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-internal-el%{facts.os.release.major}/
|
||||||
gpgcheck: false
|
gpgcheck: false
|
||||||
mirrorlist: absent
|
mirrorlist: absent
|
||||||
|
metadata_expire: '60'
|
||||||
rpm-vendor-release:
|
rpm-vendor-release:
|
||||||
name: rpm-vendor-el%{facts.os.release.major}
|
name: rpm-vendor-el%{facts.os.release.major}
|
||||||
descr: rpm-vendor-el%{facts.os.release.major} repository
|
descr: rpm-vendor-el%{facts.os.release.major} repository
|
||||||
@@ -100,6 +103,7 @@ profiles::yum::global::repos:
|
|||||||
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-vendor-el%{facts.os.release.major}/
|
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-vendor-el%{facts.os.release.major}/
|
||||||
gpgcheck: false
|
gpgcheck: false
|
||||||
mirrorlist: absent
|
mirrorlist: absent
|
||||||
|
metadata_expire: '60'
|
||||||
|
|
||||||
# Additional repositories - default to absent, roles can override with ensure: present
|
# Additional repositories - default to absent, roles can override with ensure: present
|
||||||
# FRRouting repositories
|
# FRRouting repositories
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ profiles::yum::global::repos:
|
|||||||
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-internal-f%{facts.os.release.major}/
|
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-internal-f%{facts.os.release.major}/
|
||||||
gpgcheck: false
|
gpgcheck: false
|
||||||
mirrorlist: absent
|
mirrorlist: absent
|
||||||
|
metadata_expire: '60'
|
||||||
rpm-vendor:
|
rpm-vendor:
|
||||||
name: rpm-vendor-f%{facts.os.release.major}
|
name: rpm-vendor-f%{facts.os.release.major}
|
||||||
descr: rpm-vendor-f%{facts.os.release.major} repository
|
descr: rpm-vendor-f%{facts.os.release.major} repository
|
||||||
@@ -67,3 +68,4 @@ profiles::yum::global::repos:
|
|||||||
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-vendor-f%{facts.os.release.major}/
|
baseurl: https://artifactapi.k8s.syd1.au.unkin.net/api/v1/local/rpm-vendor-f%{facts.os.release.major}/
|
||||||
gpgcheck: false
|
gpgcheck: false
|
||||||
mirrorlist: absent
|
mirrorlist: absent
|
||||||
|
metadata_expire: '60'
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ profiles::puppet::cobbler_enc::packages:
|
|||||||
- 'requests'
|
- 'requests'
|
||||||
- 'PyYAML'
|
- 'PyYAML'
|
||||||
profiles::puppet::enc::repo: https://git.service.au-syd1.consul/unkinben/puppet-enc.git
|
profiles::puppet::enc::repo: https://git.service.au-syd1.consul/unkinben/puppet-enc.git
|
||||||
|
|
||||||
|
# Deep-merged with the entries in roles/infra/puppet.yaml.
|
||||||
|
profiles::packages::include:
|
||||||
|
encapic:
|
||||||
|
ensure: '0.2.0'
|
||||||
|
|
||||||
|
profiles::puppet::encapic::encapi_url: https://encapi.k8s.syd1.au.unkin.net
|
||||||
|
profiles::puppet::server::external_nodes: '/usr/bin/encapic-enc'
|
||||||
|
|
||||||
profiles::puppet::r10k::r10k_repo: https://git.unkin.net/unkin/puppet-r10k.git
|
profiles::puppet::r10k::r10k_repo: https://git.unkin.net/unkin/puppet-r10k.git
|
||||||
profiles::puppet::g10k::bin_path: '/usr/bin/g10k'
|
profiles::puppet::g10k::bin_path: '/usr/bin/g10k'
|
||||||
profiles::puppet::g10k::cfg_path: '/etc/puppetlabs/r10k/r10k.yaml'
|
profiles::puppet::g10k::cfg_path: '/etc/puppetlabs/r10k/r10k.yaml'
|
||||||
|
|||||||
@@ -3,13 +3,21 @@
|
|||||||
require 'facter'
|
require 'facter'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
|
require 'openssl'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
# CobblerENC module: Fetches ENC data from Cobbler, caches it, and provides structured facts.
|
# EncapiENC module: Fetches ENC data from encapi, caches it, and provides structured facts.
|
||||||
module CobblerENC
|
module EncapiENC
|
||||||
CACHE_FILE = '/var/cache/puppet_enc.yaml'
|
CACHE_FILE = '/var/cache/puppet_enc.yaml'
|
||||||
CACHE_TTL = 7 * 24 * 60 * 60 # 7 days in seconds
|
CACHE_TTL = 7 * 24 * 60 * 60 # 7 days in seconds
|
||||||
|
# Facter runs under Puppet's vendored ruby, whose OpenSSL trusts only
|
||||||
|
# /opt/puppetlabs/puppet/ssl/cert.pem and never the system trust store, so the
|
||||||
|
# estate CA anchor profiles::pki::vaultca installs has to be named explicitly.
|
||||||
|
CA_BUNDLE_PATHS = [
|
||||||
|
'/etc/pki/ca-trust/source/anchors/vaultcaroot.pem',
|
||||||
|
'/usr/local/share/ca-certificates/vaultcaroot.pem'
|
||||||
|
].freeze
|
||||||
@enc_data = nil # In-memory cache for the ENC response
|
@enc_data = nil # In-memory cache for the ENC response
|
||||||
|
|
||||||
def self.read_cache
|
def self.read_cache
|
||||||
@@ -29,9 +37,22 @@ module CobblerENC
|
|||||||
File.write(CACHE_FILE, cache_data.to_yaml)
|
File.write(CACHE_FILE, cache_data.to_yaml)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.fetch_from_cobbler
|
def self.ca_bundle
|
||||||
uri = URI("http://cobbler.main.unkin.net/cblr/svc/op/puppet/hostname/#{Facter.value(:fqdn) || Facter.value(:hostname)}")
|
CA_BUNDLE_PATHS.find { |path| File.exist?(path) }
|
||||||
response = Net::HTTP.get_response(uri)
|
end
|
||||||
|
|
||||||
|
def self.http_client(uri)
|
||||||
|
client = Net::HTTP.new(uri.host, uri.port)
|
||||||
|
client.use_ssl = true
|
||||||
|
client.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
||||||
|
bundle = ca_bundle
|
||||||
|
client.ca_file = bundle if bundle
|
||||||
|
client
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.fetch_from_encapi
|
||||||
|
uri = URI("https://encapi.k8s.syd1.au.unkin.net/cblr/svc/op/puppet/hostname/#{Facter.value(:fqdn) || Facter.value(:hostname)}")
|
||||||
|
response = http_client(uri).request(Net::HTTP::Get.new(uri))
|
||||||
|
|
||||||
raise "Failed to fetch ENC data. HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
|
raise "Failed to fetch ENC data. HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
|
||||||
|
|
||||||
@@ -41,7 +62,7 @@ module CobblerENC
|
|||||||
def self.retrieve_enc_data
|
def self.retrieve_enc_data
|
||||||
return @enc_data if @enc_data
|
return @enc_data if @enc_data
|
||||||
|
|
||||||
@enc_data = fetch_from_cobbler
|
@enc_data = fetch_from_encapi
|
||||||
write_cache(@enc_data)
|
write_cache(@enc_data)
|
||||||
@enc_data
|
@enc_data
|
||||||
end
|
end
|
||||||
@@ -49,26 +70,26 @@ module CobblerENC
|
|||||||
def self.fetch_enc_data
|
def self.fetch_enc_data
|
||||||
retrieve_enc_data
|
retrieve_enc_data
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Facter.warn("Error retrieving Cobbler ENC data: #{e.message}")
|
Facter.warn("Error retrieving encapi ENC data: #{e.message}")
|
||||||
@enc_data = read_cache
|
@enc_data = read_cache
|
||||||
return @enc_data unless @enc_data.empty?
|
return @enc_data unless @enc_data.empty?
|
||||||
|
|
||||||
raise 'No cached ENC data available and Cobbler is down.'
|
raise 'No cached ENC data available and encapi is unreachable.'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.enc_role
|
def self.enc_role
|
||||||
fetch_enc_data.fetch('classes', {}).keys.first || raise('ENC Role not found in Cobbler ENC response')
|
fetch_enc_data.fetch('classes', {}).keys.first || raise('ENC Role not found in encapi ENC response')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.enc_env
|
def self.enc_env
|
||||||
fetch_enc_data.fetch('environment', nil) || raise('ENC Environment not found in Cobbler ENC response')
|
fetch_enc_data.fetch('environment', nil) || raise('ENC Environment not found in encapi ENC response')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Facter.add('enc_role') do
|
Facter.add('enc_role') do
|
||||||
setcode { CobblerENC.enc_role }
|
setcode { EncapiENC.enc_role }
|
||||||
end
|
end
|
||||||
|
|
||||||
Facter.add('enc_env') do
|
Facter.add('enc_env') do
|
||||||
setcode { CobblerENC.enc_env }
|
setcode { EncapiENC.enc_env }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ class profiles::dns::updater (
|
|||||||
Stdlib::AbsolutePath $config_dir = '/etc/dns-updater',
|
Stdlib::AbsolutePath $config_dir = '/etc/dns-updater',
|
||||||
Stdlib::AbsolutePath $master_basedir = lookup('profiles::dns::master::basedir'),
|
Stdlib::AbsolutePath $master_basedir = lookup('profiles::dns::master::basedir'),
|
||||||
# dns-updater daemon (replaces the dns-update shell script). 'latest' so hosts
|
# dns-updater daemon (replaces the dns-update shell script). 'latest' so hosts
|
||||||
# pick up new releases (e.g. the record filter); rpm-internal metadata_expire
|
# pick up new releases (e.g. the record filter).
|
||||||
# is 1h so this does not thrash.
|
|
||||||
String $package_ensure = 'latest',
|
String $package_ensure = 'latest',
|
||||||
Stdlib::AbsolutePath $api_socket = '/run/dns-updater/api.sock',
|
Stdlib::AbsolutePath $api_socket = '/run/dns-updater/api.sock',
|
||||||
String $resync = '10m',
|
String $resync = '10m',
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Class: profiles::puppet::encapic
|
||||||
|
#
|
||||||
|
# Manages the configuration for the encapic ENC client. The package itself is
|
||||||
|
# installed through profiles::packages (pinned in hiera); this class owns the
|
||||||
|
# config so the encapi endpoint can change without repackaging.
|
||||||
|
class profiles::puppet::encapic (
|
||||||
|
Stdlib::HTTPUrl $encapi_url,
|
||||||
|
Stdlib::AbsolutePath $config_dir = '/etc/encapic',
|
||||||
|
String $config_name = 'encapic.conf',
|
||||||
|
String $owner = 'root',
|
||||||
|
String $group = 'root',
|
||||||
|
) {
|
||||||
|
|
||||||
|
# The RPM ships this file as %config(noreplace), so puppet must write it only
|
||||||
|
# once the package is present or the install overwrites it.
|
||||||
|
file { $config_dir:
|
||||||
|
ensure => directory,
|
||||||
|
mode => '0755',
|
||||||
|
owner => $owner,
|
||||||
|
group => $group,
|
||||||
|
require => Package['encapic'],
|
||||||
|
}
|
||||||
|
|
||||||
|
file { "${config_dir}/${config_name}":
|
||||||
|
ensure => file,
|
||||||
|
mode => '0644',
|
||||||
|
owner => $owner,
|
||||||
|
group => $group,
|
||||||
|
content => "ENCAPI_URL=${encapi_url}\n",
|
||||||
|
require => File[$config_dir],
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ class profiles::puppet::puppetmaster (
|
|||||||
include profiles::puppet::g10k
|
include profiles::puppet::g10k
|
||||||
include profiles::puppet::enc
|
include profiles::puppet::enc
|
||||||
include profiles::puppet::cobbler_enc
|
include profiles::puppet::cobbler_enc
|
||||||
|
include profiles::puppet::encapic
|
||||||
include profiles::puppet::autosign
|
include profiles::puppet::autosign
|
||||||
include profiles::puppet::gems
|
include profiles::puppet::gems
|
||||||
include profiles::helpers::certmanager
|
include profiles::helpers::certmanager
|
||||||
|
|||||||
Reference in New Issue
Block a user