Example #1
0
    server.hostname(
        {'Set the hostname for an agent'},
        'agent.example.com',
    )

if host.fact.linux_name in ['CentOS', 'RedHat']:

    yum.packages(
        {'Install chrony for Network Time Protocol (NTP)'},
        ['chrony'],
    )

    major = host.fact.linux_distribution['major']
    yum.rpm(
        {'Install Puppet Repo'},
        'https://yum.puppet.com/puppet6-release-el-{}.noarch.rpm'.format(
            major),
    )

    files.line(
        {'Ensure SELINUX is disabled'},
        '/etc/sysconfig/selinux',
        r'SELINUX=.*',
        replace='SELINUX=disabled',
    )

    # TODO: should reboot after SELINUX is disabled (how to check/easy way to reboot)
    # TODO: how to determine when reboot is complete
    # TODO: run sestatus

if host in masters:
Example #2
0
        ['vim-enhanced', 'vim', 'wget'],
        update=True,
    )

linux_id = host.fact.linux_distribution['release_meta'].get('ID')
print(linux_id)

if host.fact.linux_name == 'CentOS':
    yum.key(
        {'Add the Docker CentOS gpg key'},
        'https://download.docker.com/linux/{}/gpg'.format(linux_id),
    )

yum.rpm(
    {'Ensure an rpm is not installed'},
    'snappy',
    present=False,
)

if host.fact.linux_name in ['CentOS', 'RedHat']:
    yum.rpm(
        {'Install EPEL rpm to enable EPEL repo'},
        'https://dl.fedoraproject.org/pub/epel/epel-release-latest-'
        '{{  host.fact.linux_distribution.major }}.noarch.rpm',
    )

    yum.packages(
        {'Install Zabbix and htop'},
        ['zabbix', 'htop'],
        update=True,
    )
Example #3
0
    # Limit operations to certain hosts with when=...
    when=distro['name'] in ('Ubuntu', 'Debian'),
)

# Or limit blocks of operations with state.when(...):
with state.when(distro['name'] in ('CentOS', 'Fedora')):
    with state.when(distro['name'] == 'CentOS'):
        # Both missing in the CentOS 7 Vagrant image
        yum.packages(
            ['wget', 'net-tools'],
            sudo=True,
        )

        # Manage remote rpm files
        yum.rpm((
            'https://dl.fedoraproject.org/pub/epel/epel-release-latest-'
            '{{ host.fact.linux_distribution.major }}.noarch.rpm'
        ), sudo=True)

    # yum package manager
    yum.packages(
        ['git', 'python-pip'],
        sudo=True,
    )

    # Edit lines in files
    files.line(
        '/etc/sysconfig/selinux',
        '^SELINUX=.*',
        replace='SELINUX=disabled',
        sudo=True,
    )
Example #4
0
        update=True,
        cache_time=3600,
    )

elif host.fact.linux_name in ('CentOS', 'Fedora'):
    if host.fact.linux_name == 'CentOS':
        # Both missing in the CentOS 7 Vagrant image
        yum.packages(
            {'Install wget & net-tools with yum'},
            ['wget', 'net-tools'],
        )

        # Manage remote rpm files
        yum.rpm(
            {'Install epel RPM'},
            ('https://dl.fedoraproject.org/pub/epel/epel-release-latest-'
             '{{ host.fact.linux_distribution.major }}.noarch.rpm'),
        )

    # yum package manager
    yum.packages(
        {'Install Pip & Git with yum'},
        ['git', 'python-pip'],
    )

# Now that we installed pip, we can use it! Note that this operation will be
# run after all the branches above.
pip.packages(
    {'Install a pip package'},
    'pytask',
)