示例#1
0
def _yum_install(state, host):
    if host.fact.linux_name == 'CentOS':
        if host.fact.linux_distribution["major"] == 7:
            yum.repo(
                state, host,
                {'Add the Docker CE Stable yum repo'},
                'docker-ce-stable',
                'https://download.docker.com/linux/centos/{{ host.fact.linux_distribution.major }}/$basearch/stable',
                description='Docker CE Stable - $basearch',
                gpgkey='https://download.docker.com/linux/centos/gpg',
            )
        # Note: Could not get docker-ce working on CentOS 8 at this time. (version conflict with containerd.io)
        if host.fact.linux_distribution["major"] == 8:
            yum.repo(
                state, host,
                {'Add the Docker CE yum repo'},
                'docker-ce',
                'https://download.docker.com/linux/centos/docker-ce.repo',
                description='Docker CE',
                gpgkey='https://download.docker.com/linux/centos/gpg',
            )

    yum.packages(
        state, host,
        {'Install Docker via yum'},
        'docker-ce',
    )
示例#2
0
# apt package manager
apt.packages(
    ['git', 'python-pip'],
    sudo=True,
    update=True,
    cache_time=3600,
    # 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
示例#3
0
if host in masters:
    server.hostname(
        {'Set the hostname for the Puppet Master'},
        'master.example.com',
    )

if host in agents:
    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',
    )
示例#4
0
文件: git.py 项目: ryanwersal/pyinfra
from pyinfra import host
from pyinfra.modules import apk, apt, files, git, yum

SUDO = True

if host.fact.linux_name in ['Alpine']:
    apk.packages(
        {'Install git'},
        'git',
    )

if host.fact.linux_name in ['CentOS']:
    yum.packages(
        {'Install git'},
        'git',
        update=True,
    )

if host.fact.linux_name in ['Ubuntu']:
    apt.packages(
        {'Install git'},
        'git',
        update=True,
    )

src_dir = '/usr/local/src'
dest = src_dir + '/pyinfra'

files.directory(
    {'Ensure the src_dir directory exists'},
    src_dir,
示例#5
0
文件: yum.py 项目: ryanwersal/pyinfra
from pyinfra import host
from pyinfra.modules import yum

SUDO = True

# Note: This "if" below is not really required.
# For instance, if you run this deploy on an
# Ubuntu instance (which does not use yum)
# the yum.packages() will simply be skipped
if host.fact.linux_name in ['CentOS', 'RedHat']:

    yum.packages(
        {'Install some packages'},
        ['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,
)
示例#6
0
文件: deploy.py 项目: xcitic/pyinfra
if distro['name'] in ('Debian', 'Ubuntu'):
    # apt package manager
    apt.packages(['git', 'python-pip'],
                 sudo=True,
                 update=True,
                 cache_time=3600)

elif distro['name'] in ('CentOS', 'Fedora'):
    if distro['name'] == 'CentOS':
        # 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)

# Ensure the state of git repositories
git.repo(
    'https://github.com/Fizzadar/pyinfra',
    host.data.app_dir,
    branch='develop',
    sudo=True
    # Do the git clone/pull as the SSH user when using forwarding
    # use_ssh_user=True
示例#7
0
    )

# Work with facts about the remote host
if host.fact.linux_name in ('Ubuntu', 'Debian'):
    apt.packages(
        {'Install Pip & Git with apt'},
        ['git', 'python-pip'],
        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'],
    )
示例#8
0
from pyinfra import host
from pyinfra.modules import apt, server, yum

SUDO = True

if host.fact.linux_name in ['CentOS', 'RedHat']:
    yum.packages(
        {'Install some packages'},
        ['cronie'],
        update=True,
    )

if host.fact.linux_name in ['Ubuntu']:
    apt.packages(
        {'Install some packages'},
        ['cron'],
        update=True,
    )

# simple example for a crontab
server.crontab(
    {'Backup /etc weekly'},
    '/bin/tar cf /tmp/etc_bup.tar /etc',
    name='backup_etc',
    day_of_week=0,
    hour=1,
    minute=0,
)

server.group(
    {'Create docker group'},