Add ansible tasks

This commit is contained in:
Anton Vakhrushev 2016-08-27 10:37:49 +03:00
parent dc3d92a792
commit 582ee4342b
14 changed files with 127 additions and 0 deletions

1
ansible/ansible.cfg Normal file
View File

@ -0,0 +1 @@
[defaults]

1
ansible/deploy.retry Normal file
View File

@ -0,0 +1 @@
192.168.33.20

10
ansible/deploy.yml Normal file
View File

@ -0,0 +1,10 @@
---
- name: Deploy homepage
hosts: all
become: true
vars_files:
- vars/all.yml
roles:
- { role: carlosbuenosvinos.ansistrano-deploy }

2
ansible/hosts-eos Normal file
View File

@ -0,0 +1,2 @@
[vagrant]
82.196.12.157 ansible_connection=ssh ansible_user=av

2
ansible/hosts-vagrant Normal file
View File

@ -0,0 +1,2 @@
[vagrant]
192.168.33.20 ansible_connection=ssh ansible_user=vagrant

View File

@ -0,0 +1,3 @@
---
- name: restart nginx
service: name=nginx enabled=yes state=restarted

View File

@ -0,0 +1,33 @@
---
- name: Install Nginx
become: yes
apt: pkg=nginx state=latest
- name: Create nginx congig
become: yes
template:
src: homepage.tpl
dest: /etc/nginx/sites-available/{{ site.domain }}
notify: restart nginx
- name: Create symlink to site
become: yes
file:
src: /etc/nginx/sites-available/{{ site.domain }}
dest: /etc/nginx/sites-enabled/{{ site.domain }}
state: link
notify: restart nginx
- name: Delete default site
become: yes
file:
path: /etc/nginx/sites-available/default
state: absent
notify: restart nginx
- name: Delete default site symlink
become: yes
file:
path: /etc/nginx/sites-enabled/default
state: absent
notify: restart nginx

View File

@ -0,0 +1,10 @@
server {
listen 80;
server_name {{ site.domain }} www.{{ site.domain }};
location / {
root /var/www/{{ site.www_dir }}/current/web;
index index.html;
try_files $uri /index.html;
}
}

View File

@ -0,0 +1,25 @@
---
- name: Update apt
sudo: yes
apt: update_cache=yes
- name: Install System Packages
sudo: yes
apt: pkg={{ item }} state=latest
with_items:
- curl
- wget
- python-software-properties
- git
- name: Configure the timezone
sudo: yes
template: src=timezone.tpl dest=/etc/timezone
- name: Configure the timezone
sudo: yes
file: src=/usr/share/zoneinfo/{{ server.timezone }} dest=/etc/localtime state=link force=yes backup=yes
- name: Set default system language pack
shell: locale-gen {{ server.locale }}
sudo: yes

View File

@ -0,0 +1 @@
{{ server.timezone }}

9
ansible/rollback.yml Normal file
View File

@ -0,0 +1,9 @@
---
- name: Rollback example app to my-server.com
hosts: all
vars_files:
- vars/all.yml
roles:
- { role: carlosbuenosvinos.ansistrano-rollback }

1
ansible/setup.retry Normal file
View File

@ -0,0 +1 @@
192.168.33.20

12
ansible/setup.yml Normal file
View File

@ -0,0 +1,12 @@
---
- hosts: all
become: true
become_method: sudo
vars_files:
- vars/all.yml
roles:
- server
- nginx

17
ansible/vars/all.yml Executable file
View File

@ -0,0 +1,17 @@
---
server:
timezone: UTC
locale: en_US.UTF-8
site:
www_dir: anwinged
domain: anwinged.ru
# Vars for ansistrano
ansistrano_deploy_from: "{{ playbook_dir }}/../web"
ansistrano_deploy_to: "/var/www/{{ site.www_dir }}"
ansistrano_keep_releases: 3
ansistrano_deploy_via: copy