Skip to content

Instantly share code, notes, and snippets.

nginx:
pkg.installed:
- name: nginx
nginx_run:
service.running:
- watch:
- pkg: nginx
- file: /etc/nginx/nginx.conf
-require:
[DEBUG ] Reading configuration from /etc/salt/minion
[DEBUG ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG ] Reading configuration from /etc/salt/minion
[DEBUG ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG ] Please install 'virt-what' to improve results of the 'virtual' grain.
[DEBUG ] Initializing new SAuth for ('/etc/salt/pki/minion', 'minion1', 'tcp://10.0.15.10:4506')
sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
fonts-dejavu-core
The following NEW packages will be installed:
fonts-dejavu-core
0 upgraded, 1 newly installed, 0 to remove and 108 not upgraded.
nginx:
Installed: 1.4.6-1ubuntu3.4
Candidate: 1.4.6-1ubuntu3.4
Version table:
*** 1.4.6-1ubuntu3.4 0
500 http://archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
100 /var/lib/dpkg/status
1.4.6-1ubuntu3 0
500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
nginx:
pkg.installed:
- name: nginx-full
nginx_run:
service.running:
- pkg: nginx_run
- enable: True
- watch:
- file: /etc/nginx/nginx.conf
haproxy:
pkg.installed:
- name: haproxy
haproxy_run:
service.running:
- name: haproxy
- enable: True
- reload: True
- watch:
backend nginx_pool
balance roundrobin
mode tcp
{% for server, addr in salt['mine.get']('G@role:webserver and G@env:' ~ env, 'internal_ip', expr_form='compound').items() -%}
server {{ server }} {{ addr }}:80 check
{% endfor -%}
frontend www
bind 10.0.2.15:80
default_backend nginx_pool
backend nginx_pool
balance roundrobin
mode tcp
server web1 10.0.15.21 check port 80
server web2 10.0.15.22 check port 80
server web3 10.0.15.23 check port 80
disable server in haproxy:
cmd.run:
- name: |
minion=$(hostname)
echo "disable server here/$minion" | sudo socat stdio /var/lib/haproxy/stats
disable_server_in_LB:
event:
- wait
- name: salt/states/base/nginx
- data:
id: {{ salt['grains.get']('host') }}
- watch:
- service: nginx