Commit 2b9adc79 by Guba Sándor

add manager state

parent f0b0e874
include:
- common
agentgit:
git.latest:
- name: {{ pillar['agent']['repo_name'] }}
- rev: {{ pillar['agent']['repo_revision'] }}
- target: /home/{{ pillar['user'] }}/agent/agent-linux
- runas: {{ pillar['user'] }}
- require:
- pkg: git
postactivate:
file.managed:
- name: /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
- source: salt://manager/files/postactivate
- template: jinja
- user: {{ pillar['user'] }}
- mode: 700
/etc/init/portal.conf:
file.copy:
- user: root
- group: root
- source: /home/{{ pillar['user'] }}/circle/miscellaneous/portal.conf
/etc/init/manager.conf:
file.copy:
- user: root
- group: root
- source: /home/{{ pillar['user'] }}/circle/miscellaneous/manager.conf
/etc/init/mancelery.conf:
file.copy:
- user: root
- group: root
- source: /home/{{ pillar['user'] }}/circle/miscellaneous/mancelery.conf
/etc/init/moncelery.conf:
file.copy:
- user: root
- group: root
- source: /home/{{ pillar['user'] }}/circle/miscellaneous/moncelery.conf
/etc/init/slowcelery.conf:
file.copy:
- user: root
- group: root
- source: /home/{{ pillar['user'] }}/circle/miscellaneous/slowcelery.conf
#!/bin/bash
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
python /home/{{ pillar['user'] }}/circle/circle/manage.py collectstatic --noinput
python /home/{{ pillar['user'] }}/circle/circle/manage.py compilemessages
ignore_invalid_headers on;
server {
listen 443 ssl default;
ssl on;
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
{% if pillar['deployment_type'] == "production" %}
location /media {
alias /home/{{ pillar['user'] }}/circle/circle/media; # your Django project's media files
}
location /static {
alias /home/{{ pillar['user'] }}/circle/circle/static_collected; # your Django project's static files
}
{% endif %}
location /doc {
alias /home/cloud/circle-website/_build/html;
}
location / {
{% if pillar['deployment_type'] == "production" %}
uwsgi_pass unix:///tmp/uwsgi.sock;
include /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
{% else %}
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_Host;
proxy_set_header X-Forwarded-Protocol https;
{% endif %}
}
location /vnc/ {
proxy_pass http://localhost:9999;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 80 default;
rewrite ^ https://$host/; # permanent;
}
# DO NOT EDIT THIS FILE
export AMQP_URI='amqp://{{ pillar['amqp']['user'] }}:{{ pillar['amqp']['password'] }}@{{ pillar['amqp']['host'] }}:{{ pillar['amqp']['port'] }}/{{ pillar['amqp']['vhost'] }}'
export CACHE_URI='{{ pillar['cache'] }}'
export DJANGO_SETTINGS_MODULE='circle.settings.{{ pillar['deployment_type'] }}'
export DJANGO_DB_HOST='localhost'
export DJANGO_DB_PASSWORD='{{ pillar['database']['password'] }}'
export DJANGO_FIREWALL_SETTINGS='{"dns_ip": "8.8.8.8", "dns_hostname":
"localhost", "dns_ttl": "300", "reload_sleep": "10",
"rdns_ip": "8.8.8.8", "default_vlangroup": "portforward"}'
export DJANGO_ALLOWED_HOSTS='*'
export DJANGO_MEMCACHED='localhost:11211'
#export DJANGO_SAML=TRUE
#export DJANGO_URL='<%= @django_url %>'
#export DJANGO_SAML_ATTRIBUTE_MAPPING='{"mail": ["email"], "sn": ["last_name"], "eduPersonPrincipalName": ["username"], "givenName": ["first_name"]}'
#export DJANGO_SAML_GROUP_OWNER_ATTRIBUTES='eduPersonScopedAffiliation'
#export DJANGO_SAML_GROUP_ATTRIBUTES='eduPersonScopedAffiliation'
export GRAPHITE_HOST='{{ pillar['graphite']['host'] }}'
export GRAPHITE_PORT='{{ pillar['graphite']['port'] }}'
export GRAPHITE_AMQP_USER='{{ pillar['graphite']['user'] }}'
export GRAPHITE_AMQP_PASSWORD='{{ pillar['graphite']['password'] }}'
export GRAPHITE_AMQP_QUEUE='{{ pillar['graphite']['queue'] }}'
export GRAPHITE_AMQP_VHOST='{{ pillar['graphite']['vhost'] }}'
export SECRET_KEY='{{ pillar['graphite']['secret_key'] }}'
export PROXY_SECRET='{{ pillar['proxy_secret'] }}'
export DEFAULT_FROM_EMAIL='root@localhost'
#LOCAL="/home//.virtualenvs/circle/bin/postactivate.local"
#test -f "$LOCAL" && . "$LOCAL"
#!/bin/bash
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
python /home/{{ pillar['user'] }}/circle/circle/manage.py syncdb --all --noinput
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate acl
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate firewall
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate storage
python /home/{{ pillar['user'] }}/circle/circle/manage.py syncdb --migrate --noinput
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate vm --merge
include:
- common
gitrepo:
git.latest:
- name: {{ pillar['manager']['repo_name'] }}
- rev: {{ pillar['manager']['repo_revision'] }}
- target: /home/{{ pillar['user'] }}/circle
- runas: {{ pillar['user'] }}
- require:
- pkg: git
include:
- manager.gitrepo
- manager.agentgit
- manager.postgres
- manager.rabbitmq
- manager.virtualenv
- manager.configuration
- manager.nginx
manager:
pkg.installed:
- pkgs:
- virtualenvwrapper
- postgresql
- git
- python-pip
- python-dev
- libpq-dev
- ntp
- rabbitmq-server
- memcached
- gettext
- wget
- libxml2-dev
- libxslt1-dev
- libmemcached-dev
- require_in:
- service: postgres_service
user:
- present
- name: {{ pillar['user'] }}
- gid_from_name: True
service:
- running
portal:
service:
- running
nginx:
pkg:
- installed
pkgrepo.managed:
- ppa: nginx/stable
- require_in:
- pkg: nginx
file.managed:
- name: /etc/nginx/conf.d/default.conf
- template: jinja
- source: salt://manager/files/nginx.conf
- user: root
- group: root
- require:
- pkg: nginx
postgres_service:
service.running:
- name: postgresql
dbuser:
postgres_user.present:
- name: {{ pillar['database']['user'] }}
- password: {{ pillar['database']['password'] }}
- runas: postgres
- require:
- service: postgresql
database:
postgres_database.present:
- name: {{ pillar['database']['name'] }}
- encoding: UTF8
- lc_ctype: en_US.UTF8
- lc_collate: en_US.UTF8
- template: template0
- owner: {{ pillar['database']['user'] }}
- runas: postgres
- require:
- service: postgresql
- postgres_user: dbuser
rabbitmq-server:
pkg.installed:
- name: rabbitmq-server
service:
- running
rabbitmq_user:
rabbitmq_user.present:
- name: {{ pillar['amqp']['user'] }}
- password: {{ pillar['amqp']['password'] }}
virtual_host:
rabbitmq_vhost.present:
- name: {{ pillar['amqp']['vhost']}}
- user: {{ pillar['amqp']['user'] }}
- conf: .*
- write: .*
- read: .*
include:
- common
virtualenv_manager:
virtualenv.managed:
- name: /home/{{ pillar['user'] }}/.virtualenvs/circle
- requirements: /home/{{ pillar['user'] }}/circle/requirements/test.txt
- runas: {{ pillar['user'] }}
- cwd: /home/{{ pillar['user'] }}/circle/
- no_chown: true
- require:
- git: gitrepo
salt://manager/files/syncdb.sh:
cmd.script:
- template: jinja
- user: {{ pillar['user'] }}
- require:
- virtualenv: virtualenv_manager
- file: /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
- user: {{ pillar['user'] }}
salt://manager/files/compile.sh:
cmd.script:
- template: jinja
- user: {{ pillar['user'] }}
- require:
- virtualenv: virtualenv_manager
- file: /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
- user: {{ pillar['user'] }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment