Skip to content

Instantly share code, notes, and snippets.

@anarcat
Last active September 5, 2019 20:21
Show Gist options
  • Select an option

  • Save anarcat/854d64c26a3f2e2ae7d3fd5292245404 to your computer and use it in GitHub Desktop.

Select an option

Save anarcat/854d64c26a3f2e2ae7d3fd5292245404 to your computer and use it in GitHub Desktop.

Revisions

  1. anarcat revised this gist Sep 5, 2019. 3 changed files with 30 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions cdn-backend-sunet-01.torproject.org.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    classes:
    - roles::weblog_source
    - roles::static_mirror_web
    # doesn't know its own IP, supply it here
    # XXX: maybe we want to override ipaddress for this entire host?
    roles::weblog_source::allow_address: 89.45.235.27
    roles::static_master::allow_address: 89.45.235.27
    # behind NAT
    hosts::managed: false
    3 changes: 3 additions & 0 deletions common.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    classes:
    - roles::monitored
    - base
    18 changes: 18 additions & 0 deletions hiera.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    ---
    :backends:
    - yaml

    :hierarchy:
    - "nodes/%{trusted.certname}"
    - "osfamily/%{::osfamily}"
    # forward-compatibility with automated lookups, remove when
    # Puppetmaster is >= 4.9, along with the symlinks in hiera/modules
    - "modules/%{module_name}/data/%{facts.os.name}-%{facts.os.release.major}"
    - "modules/%{module_name}/data/%{facts.os.name}"
    - "modules/%{module_name}/data/%{facts.os.family}"
    - "modules/%{module_name}/data/defaults"
    - "modules/%{module_name}/data/common"
    - common

    :yaml:
    :datadir: /etc/puppet/hiera
  2. anarcat created this gist Sep 5, 2019.
    8 changes: 8 additions & 0 deletions base.pp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    class base(
    Stdlib::IP::Address $public_address = filter_ipv4(getfromhash($nodeinfo, 'ldap', 'ipHostNumber'))[0],
    Stdlib::IP::Address $public_address6 = filter_ipv6(getfromhash($nodeinfo, 'ldap', 'ipHostNumber'))[0],
    ) {
    Notify { 'base_ips':
    message => "base::public_address: ${base::public_address} base::public_address6: ${base::public_address6} ipaddress: ${::ipaddress} ipaddress6: ${::ipaddress6}",
    }
    }
    12 changes: 12 additions & 0 deletions output.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # puppet agent -t
    Info: Using configured environment 'production'
    Info: Retrieving pluginfacts
    Info: Retrieving plugin
    Info: Loading facts
    Info: Caching catalog for cdn-backend-sunet-01.torproject.org
    Info: Applying configuration version '1567714440'
    Notice: base::public_address: base::public_address6: ipaddress: 89.45.235.27 ipaddress6: 2001:6b0:5a:5000::b allow_address 89.45.235.27 allow_address6 2001:6b0:5a:5000::b
    Notice: /Stage[main]/Roles::Weblog_source/Notify[weblog_source_ips]/message: defined 'message' as 'base::public_address: base::public_address6: ipaddress: 89.45.235.27 ipaddress6: 2001:6b0:5a:5000::b allow_address 89.45.235.27 allow_address6 2001:6b0:5a:5000::b'
    Notice: base::public_address: 89.45.235.27 base::public_address6: 2001:6b0:5a:5000::b ipaddress: 89.45.235.27 ipaddress6: 2001:6b0:5a:5000::b
    Notice: /Stage[main]/Base/Notify[base_ips]/message: defined 'message' as 'base::public_address: 89.45.235.27 base::public_address6: 2001:6b0:5a:5000::b ipaddress: 89.45.235.27 ipaddress6: 2001:6b0:5a:5000::b'
    Notice: Applied catalog in 5.12 seconds
    8 changes: 8 additions & 0 deletions weblog_source.pp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    class roles::weblog_source(
    $allow_address = $::ipaddress,
    $allow_address6 = $::ipaddress6,
    ) {
    Notify { 'weblog_source_ips':
    message => "base::public_address: ${base::public_address} base::public_address6: ${base::public_address6} ipaddress: ${::ipaddress} ipaddress6: ${::ipaddress6} allow_address ${allow_address} allow_address6 ${allow_address6}",
    }
    }