day_of_week=0, hour=1, minute=0, ) server.group( {'Create docker group'}, 'docker', ) # if we are not running inside a docker container if not host.fact.file('/.dockerenv'): # Cannot change hostname if running in a docker container server.hostname( {'Set the hostname'}, 'server1.example.com', ) # Cannot change value on read-only filesystem # use "/sbin/sysctl -a | grep file-max" to check value server.sysctl( {'Change the fs.file-max value'}, 'fs.file-max', '100000', persist=True, ) if host.fact.linux_name in ['CentOS', 'RedHat']: server.modprobe( {'Silly example for modprobe'}, 'floppy',
files.line( name='Add hosts to /etc/hosts', path='/etc/hosts', line=r' {}.example.com '.format(name), replace='{} {}.example.com {}'.format(ip, name, name), ) # ensure all hosts are added to each /etc/hosts file inv = inventory.get_group('@vagrant') for item in inv: update_hosts_file(item.name, item.fact.ipv4_addresses['eth0']) if host.name == '@vagrant/two': server.hostname( name='Set the hostname for two', hostname='two.example.com', ) if host.name == '@vagrant/one': server.hostname( name='Set the hostname for one', hostname='one.example.com', ) server.shell( name='Generate vagrant ssh key', commands=('sudo -u vagrant ssh-keygen -t rsa -C [email protected] ' '-b 4096 -N "" -q -f /home/vagrant/.ssh/id_rsa'), )
day_of_week=0, hour=1, minute=0, ) server.group( name='Create docker group', group='docker', ) # if we are not running inside a docker container if not host.fact.file('/.dockerenv'): # Cannot change hostname if running in a docker container server.hostname( name='Set the hostname', hostname='server1.example.com', ) # Cannot change value on read-only filesystem # use "/sbin/sysctl -a | grep file-max" to check value server.sysctl( name='Change the fs.file-max value', key='fs.file-max', value='100000', persist=True, ) if host.fact.linux_name in ['CentOS', 'RedHat']: server.modprobe( name='Silly example for modprobe', module='floppy',
line=r' {}.example.com '.format(name), replace='{} {}.example.com {}'.format(ip, name, name), ) # ensure all hosts are added to each /etc/hosts file masters = inventory.get_group('master_servers') for item in masters: update_hosts_file('master', item.fact.ipv4_addresses['eth0']) agents = inventory.get_group('agent_servers') for item in agents: update_hosts_file('agent', item.fact.ipv4_addresses['eth0']) if host in masters: server.hostname( name='Set the hostname for the Puppet Master', hostname='master.example.com', ) if host in agents: server.hostname( name='Set the hostname for an agent', hostname='agent.example.com', ) if host.fact.linux_name in ['CentOS', 'RedHat']: yum.packages( name='Install chrony for Network Time Protocol (NTP)', packages=['chrony'], )
day_of_week=0, hour=1, minute=0, ) server.group( name="Create docker group", group="docker", ) # if we are not running inside a docker container if not host.get_fact(File, path="/.dockerenv"): # Cannot change hostname if running in a docker container server.hostname( name="Set the hostname", hostname="server1.example.com", ) # Cannot change value on read-only filesystem # use "/sbin/sysctl -a | grep file-max" to check value server.sysctl( name="Change the fs.file-max value", key="fs.file-max", value="100000", persist=True, ) if host.get_fact(LinuxName) in ["CentOS", "RedHat"]: server.modprobe( name="Silly example for modprobe", module="floppy",
replace="{} {}.example.com {}".format(ip, name, name), ) # ensure all hosts are added to each /etc/hosts file masters = inventory.get_group("master_servers") for group_host in masters: update_hosts_file("master", group_host.get_fact(Ipv4Addresses)["eth0"]) agents = inventory.get_group("agent_servers") for group_host in agents: update_hosts_file("agent", group_host.get_fact(Ipv4Addresses)["eth0"]) if host in masters: server.hostname( name="Set the hostname for the Puppet Master", hostname="master.example.com", ) if host in agents: server.hostname( name="Set the hostname for an agent", hostname="agent.example.com", ) if host.get_fact(LinuxName) in ["CentOS", "RedHat"]: yum.packages( name="Install chrony for Network Time Protocol (NTP)", packages=["chrony"], )
r' {}.example.com '.format(name), replace='{} {}.example.com {}'.format(ip, name, name), ) # ensure all hosts are added to each /etc/hosts file masters = inventory.get_group('master_servers') for item in masters: update_hosts_file('master', item.fact.ipv4_addresses['eth0']) agents = inventory.get_group('agent_servers') for item in agents: update_hosts_file('agent', item.fact.ipv4_addresses['eth0']) 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'], )
files.line( {'Add hosts to /etc/hosts'}, '/etc/hosts', r' {}.example.com '.format(name), replace='{} {}.example.com {}'.format(ip, name, name), ) # ensure all hosts are added to each /etc/hosts file inv = inventory.get_group('@vagrant') for item in inv: update_hosts_file(item.name, item.fact.ipv4_addresses['eth0']) if host.name == '@vagrant/two': server.hostname( {'Set the hostname for two'}, 'two.example.com', ) if host.name == '@vagrant/one': server.hostname( {'Set the hostname for one'}, 'one.example.com', ) server.shell( {'Generate vagrant ssh key'}, 'sudo -u vagrant ssh-keygen -t rsa -C [email protected] ' '-b 4096 -N "" -q -f /home/vagrant/.ssh/id_rsa', )
files.line( name="Add hosts to /etc/hosts", path="/etc/hosts", line=r" {}.example.com ".format(name), replace="{} {}.example.com {}".format(ip, name, name), ) # ensure all hosts are added to each /etc/hosts file inv = inventory.get_group("@vagrant") for item in inv: update_hosts_file(item.name, item.get_fact(Ipv4Addresses)["eth0"]) if host.name == "@vagrant/two": server.hostname( name="Set the hostname for two", hostname="two.example.com", ) if host.name == "@vagrant/one": server.hostname( name="Set the hostname for one", hostname="one.example.com", ) server.shell( name="Generate vagrant ssh key", commands=("sudo -u vagrant ssh-keygen -t rsa -C [email protected] " '-b 4096 -N "" -q -f /home/vagrant/.ssh/id_rsa'), )