Puppet Class: homer
- Defined in:
- modules/homer/manifests/init.pp
Overview
SPDX-License-Identifier: Apache-2.0
Class: homer
This class installs & manages Homer, a network configuration management tool
Parameters:
-
$private_git_peer: FQDN or IP of the private repo peer to sync to at each commit.
-
$nb_token: Token to use to authenticate to Netbox
-
$nb_api: Netbox URL
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'modules/homer/manifests/init.pp', line 11
class homer(
Stdlib::Host $private_git_peer,
String $nb_token,
Stdlib::HTTPSUrl $nb_api,
) {
$public_repo = '/srv/homer/public'
$private_repo = '/srv/homer/private'
$output_dir = '/srv/homer/output'
file { '/srv/homer':
ensure => directory,
owner => 'root',
group => 'ops',
mode => '0550',
}
file { $output_dir:
ensure => directory,
owner => 'root',
group => 'ops',
mode => '0770',
require => File['/srv/homer'],
}
# Clone the public data
git::clone { 'operations/homer/public':
ensure => 'latest',
directory => $public_repo,
owner => 'root',
group => 'ops',
mode => '0440',
require => File['/srv/homer'],
}
# Clone the private data from the $private_git_peer host
# The data must be present on the other peer, the current puppetization doesn't
# cover the case of a fresh start without data in either peer hosts.
git::clone { 'homer_private_repo':
ensure => 'present',
origin => "ssh://${private_git_peer}/srv/homer/private",
remote_name => 'peer',
directory => $private_repo,
environment_variables => ['SSH_AUTH_SOCK=/run/keyholder/proxy.sock'],
owner => 'root',
group => 'ops',
mode => '0440',
require => File['/srv/homer'],
}
file { '/etc/homer':
ensure => directory,
owner => 'root',
group => 'ops',
mode => '0550',
}
file { '/etc/homer/config.yaml':
ensure => present,
content => template('homer/config.yaml.erb'),
owner => 'root',
group => 'ops',
mode => '0440',
require => File['/etc/homer'],
}
file { '/usr/local/bin/homer':
ensure => present,
owner => 'root',
group => 'ops',
mode => '0550',
source => 'puppet:///modules/homer/homer.sh',
}
# Set git config and hooks for the private repo
$private_repo_git_dir = "${private_repo}/.git"
file { "${private_repo_git_dir}/config":
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template('homer/private-git/config.erb'),
require => Git::Clone['homer_private_repo'],
}
file { "${private_repo_git_dir}/hooks":
ensure => directory,
recurse => 'remote',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/homer/private-git/hooks',
require => Git::Clone['homer_private_repo'],
}
}
|