-
-
Save wangwenchao/401b0c4810e0aafd81d7c18cb98e26d2 to your computer and use it in GitHub Desktop.
Saltstack formula setup and updating
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
#!/bin/bash | |
formulas="sudoers timezone ntp openssh resolver iptables salt systemd users vim rsyslog logrotate vsftpd apt locale epel firewalld golang snmp iscsi lvm rsyncd sysctl zabbix dnsmasq haproxy keepalived docker nginx php postfix chrony letsencrypt libvirt nfs powerdns varnish redmine zookeeper postgres mysql kibana openvpn collectd apache tomcat etcd consul memcached django openvswitch bind ufw mongodb elasticsearch fail2ban vault prometheus node" | |
BASE_DIR=/srv | |
formula_root=$BASE_DIR/formulas | |
state_root=$BASE_DIR/states | |
pillar_root=$BASE_DIR/pillars | |
# git use git/https | |
git_url=git@github.com:saltstack-formulas | |
http_url=https://github.com/saltstack-formulas | |
[ ! -d $formula_root ] && mkdir $formula_root | |
[ ! -d $state_root ] && mkdir $state_root | |
[ ! -d $pillar_root ] && mkdir $pillar_root | |
cd $formula_root | |
for formula in $formulas;do | |
ff=$formula-formula | |
if [ ! -d $formula_root/$ff ]; then | |
cd $formula_root | |
git clone ${http_url}/$ff.git | |
else | |
cd $formula_root/$ff | |
echo -n "Pulling $ff into $PWD " | |
git pull | |
fi | |
rsync -a $formula_root/$ff/$formula/ $state_root/$formula/ | |
[ ! -d $pillar_root/$formula ] && mkdir $pillar_root/$formula | |
rsync -a $formula_root/$ff/pillar.example $pillar_root/$formula/ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment