Puppet Class: external_clouds_vendors

Defined in:
modules/external_clouds_vendors/manifests/init.pp

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')

    ensurable

  • user (String[1]) (defaults to: 'external-clouds-fetcher')

    user to use for downloading file

  • group (String[1]) (defaults to: 'root')

    to use for file permissions

  • manage_user (Boolean) (defaults to: true)

    set to false if the user is managed elsewhere

  • conftool (Boolean) (defaults to: false)

    set to true if you want to upload data to etcd.

  • outfile (Stdlib::Unixpath) (defaults to: '/srv/external_clouds_vendors/public_clouds.json')

    location to write the results

  • private_repo (Stdlib::Unixpath) (defaults to: '/srv/private')

    location of the private_repo

  • http_proxy (Optional[Stdlib::HTTPUrl]) (defaults to: undef)

    http proxy server to use will be used for both http and https



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
# File 'modules/external_clouds_vendors/manifests/init.pp', line 11

class external_clouds_vendors (
    Wmflib::Ensure            $ensure       = 'present',
    String[1]                 $user         = 'external-clouds-fetcher',
    String[1]                 $group        = 'root',
    Boolean                   $manage_user  = true,
    Boolean                   $conftool     = false,
    Stdlib::Unixpath          $outfile      = '/srv/external_clouds_vendors/public_clouds.json',
    Stdlib::Unixpath          $private_repo = '/srv/private',
    Optional[Stdlib::HTTPUrl] $http_proxy   = undef,
) {
    ensure_packages(['python3-lxml', 'python3-netaddr', 'python3-requests', 'python3-wmflib', 'python3-conftool', 'python3-git'])
    if $manage_user {
        systemd::sysuser { $user:
            description => 'User used for downloading external cloud vendor networks',
            before      => [
                File[$outfile.dirname(), $outfile, '/usr/local/bin/fetch-external-clouds-vendors-nets'],
                Systemd::Timer::Job['dump_cloud_ip_ranges']
            ],
        }
    }
    $environment = $http_proxy ? {
        undef   => {},
        default => Hash( ['http_proxy', 'https_proxy' ].map |$env| {[$env, $http_proxy, $env.upcase, $http_proxy]}.flatten)
    }
    if !defined($outfile.dirname) {
        file { $outfile.dirname():
            ensure => stdlib::ensure($ensure, 'directory'),
            owner  => $user,
            group  => $group,
        }
    }
    file { '/usr/local/bin/fetch-external-clouds-vendors-nets':
        ensure => stdlib::ensure($ensure, 'file'),
        mode   => '0554',
        owner  => $user,
        group  => $group,
        source => 'puppet:///modules/external_clouds_vendors/fetch_external_clouds_vendors_nets.py',

    }
    file { $outfile:
        ensure  => stdlib::ensure($ensure, 'file'),
        mode    => '0644',
        owner   => $user,
        group   => $group,
        # set replace false to ensure we only create content if no file already exists
        replace => false,
        content => '{}',
    }
    $opts = $conftool.bool2str('-c', '')
    $command = "/usr/local/bin/fetch-external-clouds-vendors-nets --repo ${private_repo} ${opts} -vvv ${outfile}"
    systemd::timer::job { 'dump_cloud_ip_ranges':
        ensure            => $ensure,
        command           => $command,
        description       => 'Job to update list of cloud ip ranges',
        user              => $user,
        logging_enabled   => true,
        syslog_identifier => 'fetch-external-clouds-vendors-nets',
        environment       => $environment,
        interval          => {'start' => 'OnCalendar', 'interval' => 'daily'},
    }
}