From 4fd60cd6b6bd16a253b25cf5a2830b8d65f9b1f9 Mon Sep 17 00:00:00 2001
From: Anton Vakhrushev <anwinged@ya.ru>
Date: Sat, 31 Dec 2016 11:17:25 +0300
Subject: [PATCH] Reconfigure deploy

---
 Makefile                                           | 14 +++-----------
 Vagrantfile                                        |  5 +++--
 ansible.cfg                                        |  2 ++
 ansible/deploy.yml                                 |  2 +-
 ansible/hosts-eos                                  |  1 -
 ansible/hosts-vagrant                              |  2 --
 ansible/{provision.yml => vagrant-provision.yml}   |  0
 .../{requirements.yml => vagrant-requirements.yml} |  5 +++++
 ansible/vars/all.yml                               |  2 +-
 9 files changed, 15 insertions(+), 18 deletions(-)
 create mode 100644 ansible.cfg
 delete mode 100644 ansible/hosts-eos
 delete mode 100644 ansible/hosts-vagrant
 rename ansible/{provision.yml => vagrant-provision.yml} (100%)
 rename ansible/{requirements.yml => vagrant-requirements.yml} (58%)

diff --git a/Makefile b/Makefile
index 501adc1..d83f7ee 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,3 @@
-deploy-test:
-	ansible-playbook --inventory ansible/hosts-vagrant ansible/deploy.yml
-
-deploy-prod:
-	ansible-playbook --inventory ansible/hosts-eos --ask-become-pass ansible/deploy.yml
-
-setup-test:
-	ansible-playbook --inventory ansible/hosts-vagrant ansible/setup.yml
-
-setup-prod:
-	ansible-playbook --inventory ansible/hosts-eos --ask-become-pass ansible/setup.yml
+deploy:
+	vendor/bin/sculpin generate --env=prod
+	ansible-playbook --inventory 'anwinged.ru,' --user=av --ask-become-pass ansible/deploy.yml
diff --git a/Vagrantfile b/Vagrantfile
index 349a669..47c29e6 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -13,10 +13,11 @@ Vagrant.configure("2") do |config|
   config.vm.network "forwarded_port", guest: 80, host: 8080
 
   config.vm.provision "ansible_local" do |ansible|
-    ansible.playbook = "ansible/provision.yml"
-    ansible.galaxy_role_file = "ansible/requirements.yml"
+    ansible.playbook = "ansible/vagrant-provision.yml"
+    ansible.galaxy_role_file = "ansible/vagrant-requirements.yml"
     ansible.galaxy_roles_path = "ansible/galaxy.roles"
     ansible.sudo = true
   end
 
+  config.ssh.forward_agent = true
 end
diff --git a/ansible.cfg b/ansible.cfg
new file mode 100644
index 0000000..308e8a1
--- /dev/null
+++ b/ansible.cfg
@@ -0,0 +1,2 @@
+[defaults]
+roles_path = /vagrant/ansible/galaxy.roles:/vagrant/ansible/roles:/etc/ansible/roles:/vagrant/ansible
diff --git a/ansible/deploy.yml b/ansible/deploy.yml
index f1379ff..5fc8279 100644
--- a/ansible/deploy.yml
+++ b/ansible/deploy.yml
@@ -7,4 +7,4 @@
     - vars/all.yml
 
   roles:
-    - { role: carlosbuenosvinos.ansistrano-deploy }
+    - carlosbuenosvinos.ansistrano-deploy
diff --git a/ansible/hosts-eos b/ansible/hosts-eos
deleted file mode 100644
index 2bec0cf..0000000
--- a/ansible/hosts-eos
+++ /dev/null
@@ -1 +0,0 @@
-82.196.12.157
diff --git a/ansible/hosts-vagrant b/ansible/hosts-vagrant
deleted file mode 100644
index d75642f..0000000
--- a/ansible/hosts-vagrant
+++ /dev/null
@@ -1,2 +0,0 @@
-[vagrant]
-192.168.33.20   ansible_connection=ssh  ansible_user=vagrant
diff --git a/ansible/provision.yml b/ansible/vagrant-provision.yml
similarity index 100%
rename from ansible/provision.yml
rename to ansible/vagrant-provision.yml
diff --git a/ansible/requirements.yml b/ansible/vagrant-requirements.yml
similarity index 58%
rename from ansible/requirements.yml
rename to ansible/vagrant-requirements.yml
index 0773e50..9aa9c4a 100644
--- a/ansible/requirements.yml
+++ b/ansible/vagrant-requirements.yml
@@ -11,3 +11,8 @@
 - src: geerlingguy.composer
   version: 1.5.0
 
+- src: carlosbuenosvinos.ansistrano-deploy
+  version: 1.12.0
+
+- src: carlosbuenosvinos.ansistrano-rollback
+  version: 1.5.0
diff --git a/ansible/vars/all.yml b/ansible/vars/all.yml
index 060269d..b0aaf57 100755
--- a/ansible/vars/all.yml
+++ b/ansible/vars/all.yml
@@ -24,7 +24,7 @@ php_packages:
 
 # Vars for ansistrano
 
-ansistrano_deploy_from: "{{ playbook_dir }}/../output_prod"
+ansistrano_deploy_from: "{{ playbook_dir }}/../output_prod/"
 ansistrano_deploy_to: "/var/www/{{ site.www_dir }}"
 ansistrano_keep_releases: 3
 ansistrano_deploy_via: copy