Last active
August 29, 2015 14:15
-
-
Save DanyHenriquez/3f95f26bdf7e330f18fc to your computer and use it in GitHub Desktop.
Puppet installation | CentOS 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from fabric.api import * | |
import time, sys, ast | |
env.hosts = list() | |
env.warn_only = True | |
env.user = '' | |
env.password = '' | |
with open('<hosts file>', 'r') as host_file: | |
for line in host_file.readlines(): | |
env.hosts.append(line.split(' ')[0]) | |
def copy_host_file(host_file): | |
put(host_file, '/etc/hosts', use_sudo=True) | |
def install_puppet_repo(): | |
sudo('yum update -y') | |
sudo('rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm') | |
def install_puppet_master(): | |
install_puppet_repo() | |
sudo('yum install puppet-server ntp -y') | |
sudo('puppet resource package puppet-server ensure=latest') | |
sudo('puppet master --verbose --no-daemonize') | |
time.sleep(5) | |
pid = sudo('pgrep puppet') | |
sudo('kill ' + pid) | |
hostname = run('hostname -f') | |
prompt("What is the puppet server name ()?", default=hostname) | |
sudo('echo echo PUPPET_SERVER=' + hostname + ' > /etc/sysconfig/puppet') | |
print('The puppet master has been installed') | |
def install_puppet_agent(): | |
install_puppet_repo() | |
sudo('yum install puppet ntp -y') | |
pid = sudo('pgrep puppet') | |
sudo('kill ' + pid) | |
sudo('puppet resource package puppet ensure=latest') | |
print('The puppet asgent has been installed') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment