forked from goshlanguage/ansible-kvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.yml
107 lines (78 loc) · 2.99 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
- hosts: kvm
vars:
app_path: /var/www/webvirtmgr
tasks:
- name: yum update
yum: name=* state=latest update_cache=yes
- name: Install kvm, python libs, libs, supervisor, nginx
yum: pkg={{item}} state=installed
with_items:
- epel-release
- qemu-kvm
- git
- libvirt
- virt-manager
- bridge-utils
- python-pip
- libvirt-python
- libxml2-python
- python-websockify
- supervisor
- nginx
- net-tools
- name: enable and start libvirt
service: name=libvirtd state=restarted enabled=yes
- name: setup port forwarding
sysctl: name="net.ipv4.ip_forward" value=1 sysctl_set=yes
- name: check for web folder
file: name=/var/www state=directory
- name: clone webvirtmgr
git: repo=git://github.com/retspen/webvirtmgr.git
dest={{ app_path }}
accept_hostkey=yes
- name: set perms
file: path="{{ app_path }}" owner=nginx group=nginx recurse=yes
- name: pip install webvirtmgr libs
pip: requirements={{ app_path }}/requirements.txt
notify: add_admin
# This is a django project
# http://docs.ansible.com/ansible/django_manage_module.html
- name: syncdb
django_manage: >
command=syncdb
app_path={{ app_path }}
- name: collectstatic
django_manage: command=collectstatic app_path={{ app_path }}
- name: webvirtmgr nginx conf
copy: src=files/webvirtmgr.conf dest=/etc/nginx/conf.d/ owner=nginx group=nginx
- name: nginx conf
copy: src=files/nginx.conf dest=/etc/nginx/ owner=nginx group=nginx
- name: nginx restart and enable
service: name=nginx state=restarted enabled=yes
# FirewallD
# http://docs.ansible.com/ansible/firewalld_module.html
- name: open 80
firewalld: port=80/tcp permanent=true state=enabled immediate=yes
- name: supervisor conf
template: src=templates/supervisord.conf.j2 dest=/etc/supervisord.conf
- name: supervisord restart and enable
service: name=supervisord state=restarted enabled=yes
# Now setting up the server as seen here:
# https://github.com/retspen/webvirtmgr/wiki/Setup-Host-Server
- name: libvirt-bootstrap
sudo: true
shell: wget -O - http://retspen.github.io/libvirt-bootstrap.sh | sudo sh
- name: better bootsstrap
shell: /bin/bash {{ app_path }}/conf/libvirt-bootstrap.sh
- name: open 16509
firewalld: port=16509/tcp permanent=true state=enabled zone=public immediate=yes
# Uncomment desired ISOs
#
# - name: CoreOS
# get_url: url=http://stable.release.core-os.net/amd64-usr/current/coreos_production_iso_image.iso dest={{ app_path }}/images/ owner=nginx group=nginx
- name: CoreOS
get_url: url=http://stable.release.core-os.net/amd64-usr/current/coreos_production_iso_image.iso dest={{ app_path }}/images/ owner=nginx group=nginx
handlers:
- name: add_admin
django_manage: app_path="{{ app_path }}" command="createsuperuser --noinput --username=admin [email protected] password=testtest"