Created
July 25, 2018 17:45
-
-
Save ipv6freely/e308c4bff415e826ef41702fa5bbad71 to your computer and use it in GitHub Desktop.
Install Saltstack
This file contains hidden or 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
| #!/bin/bash | |
| echo "!!!!!!!!!! STARTING SALTSTACK INSTALLATION !!!!!!!!!!" | |
| echo "********** Updating Repos **********" | |
| apt-get update | |
| echo "********** Upgrading Installed Packages **********" | |
| apt-get -y upgrade | |
| echo "********** Installing SaltStack **********" | |
| #apt-get -y install salt-api salt-cloud salt-master salt-minion salt-ssh salt-syndic salt-proxy | |
| wget -O bootstrap-salt.sh https://bootstrap.saltstack.com | |
| sh bootstrap-salt.sh -M | |
| echo "********** Installing pip **********" | |
| apt-get -y install python-pip | |
| echo "********** Installing NAPALM **********" | |
| pip install napalm | |
| echo "********** Fixing pyOpenSSL **********" | |
| python -m easy_install --upgrade pyOpenSSL | |
| echo "********** Creating SaltStack Directories Under /etc/salt **********" | |
| mkdir -p /etc/salt/states/base /etc/salt/pillars/base /etc/salt/formulas | |
| echo "********** Making backups of original master/minion files **********" | |
| mv /etc/salt/master /etc/salt/master.bak | |
| mv /etc/salt/minion /etc/salt/minion.bak | |
| echo "********** Writing /etc/salt/master file **********" | |
| cat >/etc/salt/master <<EOL | |
| file_roots: | |
| base: | |
| - /etc/salt/states/base | |
| pillar_roots: | |
| base: | |
| - /etc/salt/pillars/base | |
| EOL | |
| echo "********** Writing /etc/salt/minion file **********" | |
| cat >/etc/salt/minion <<EOL | |
| master: localhost | |
| EOL | |
| echo "********** Adding Salt Proxy Minion Service **********" | |
| cat >/etc/systemd/system/[email protected] <<EOL | |
| [Unit] | |
| Description=Salt proxy minion | |
| After=network.target | |
| [Service] | |
| Type=simple | |
| ExecStart=/usr/bin/salt-proxy -l debug --proxyid=%i | |
| User=root | |
| Group=root | |
| Restart=always | |
| RestartPreventExitStatus=SIGHUP | |
| RestartSec=5 | |
| [Install] | |
| WantedBy=default.target | |
| EOL | |
| echo "********** Writing /etc/salt/proxy file **********" | |
| cat >/etc/salt/proxy <<EOL | |
| master: localhost | |
| multiprocessing: false | |
| mine_enabled: true | |
| pki_dir: /etc/salt/pki/proxy | |
| EOL | |
| echo "********** Adding test python script **********" | |
| cat >/etc/salt/test.py <<EOL | |
| from __future__ import print_function | |
| import napalm | |
| driver = napalm.get_network_driver('junos') | |
| with driver(hostname='192.168.255.101', username='cjones', password='Juniper123!') as client: | |
| facts = client.get_facts() | |
| print(facts['os_version']) | |
| EOL | |
| echo "********** Writing /etc/salt/pillars/base/top.sls **********" | |
| cat >/etc/salt/pillars/base/top.sls <<EOL | |
| base: | |
| r1: | |
| - r1 | |
| EOL | |
| echo "********** Writing /etc/salt/pillars/base/r1.sls **********" | |
| cat >/etc/salt/pillars/base/r1.sls <<EOL | |
| proxy: | |
| proxytype: napalm | |
| driver: junos | |
| host: 192.168.255.101 | |
| username: cjones | |
| passwd: Juniper123! | |
| EOL | |
| echo "********** Restarting master and minion services **********" | |
| service salt-master restart | |
| service salt-minion restart | |
| # echo "********** Generating SSH Keys **********" | |
| # ssh-keygen -f id_rsa -t rsa -N '' | |
| echo "!!!!!!!!!! SALTSTACK INSTALLATION COMPLETE !!!!!!!!!!" | |
| salt --version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment