HashNuke / ansible-elixir-stack

Ansible role to setup server with Elixir & Postgres to deploy apps
295 stars 52 forks source link

Deployment errors out if adding dependencies w/o updating mix.lock #9

Closed jwarlander closed 9 years ago

jwarlander commented 9 years ago

If a new dependency is added to mix.exs, eg:

diff --git a/mix.exs b/mix.exs
index 7f8fb0c..df627cd 100644
--- a/mix.exs
+++ b/mix.exs
@@ -35,6 +35,7 @@ defmodule HelloPhoenix.Mixfile do
      {:phoenix_html, "~> 1.4"},
      {:phoenix_live_reload, "~> 0.5", only: :dev},
      {:cowboy, "~> 1.0"},
-     {:exrm, "~> 0.18.1"}]
+     {:exrm, "~> 0.18.1"},
+     {:exprotobuf, "~> 0.11.0"}]
   end
 end

..and then the project is deployed without updating mix.lock, then the NEXT deploy after that will fail:

TASK: [HashNuke.elixir-stack | clone project] ********************************* 
failed: [178.62.201.149] => {"failed": true}
msg: Local modifications exist in repository (force=no).

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/johwar/deploy.retry

178.62.201.149             : ok=9    changed=0    unreachable=0    failed=1   

This is due to the Ansible 'git' task not forcing overwrites of modified files in the working tree by default. At the first deploy, mix.lock in the working tree on the server was updated with the new dependency, meaning it's now modified compared to what's in the Git repo.. so when we deploy a second time, the 'git' task fails as above.

jwarlander commented 9 years ago

Yes.. this happened while writing the blog post yesterday ;)