{"action":"created","comment":{"url":"https://api.github.com/repos/caktus/margarita/pulls/comments/92013358","pull_request_review_id":12500097,"id":92013358,"diff_hunk":"@@ -1,7 +1,9 @@\n {% set root_dir = \"/var/www/\" + pillar['project_name'] + \"/\" %}\n \n-{% macro get_primary_ip(ifaces) -%}\n-  {{ ifaces.get(salt['pillar.get']('primary_iface', 'eth0'), {}).get('inet', [{}])[0].get('address') }}\n+{% macro get_primary_ip(host, ifaces) -%}\n+  {# use `primary_iface` from pillar, then fall back to getting the iface from the default route #}\n+  {%- set minion_iface = salt['pillar.get']('primary_iface', salt['mine.get'](host, 'network.default_route')[host][0]['interface']) -%}","path":"project/_vars.sls","position":7,"original_position":7,"commit_id":"c4f1b3180748c93d59e774080edfa87eff73e6d8","original_commit_id":"c4f1b3180748c93d59e774080edfa87eff73e6d8","user":{"login":"dpoirier","id":2788679,"avatar_url":"https://avatars.githubusercontent.com/u/2788679?v=3","gravatar_id":"","url":"https://api.github.com/users/dpoirier","html_url":"https://github.com/dpoirier","followers_url":"https://api.github.com/users/dpoirier/followers","following_url":"https://api.github.com/users/dpoirier/following{/other_user}","gists_url":"https://api.github.com/users/dpoirier/gists{/gist_id}","starred_url":"https://api.github.com/users/dpoirier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpoirier/subscriptions","organizations_url":"https://api.github.com/users/dpoirier/orgs","repos_url":"https://api.github.com/users/dpoirier/repos","events_url":"https://api.github.com/users/dpoirier/events{/privacy}","received_events_url":"https://api.github.com/users/dpoirier/received_events","type":"User","site_admin":false},"body":"I think (?) that because we import _vars.sls `with context`, that setting a variable here will set it globally?  It looks like we don't really need a temporary variable here, so it might be safer not to use `{% set %}` here.\r\n\r\n","created_at":"2016-12-12T18:53:17Z","updated_at":"2016-12-12T18:56:25Z","html_url":"https://github.com/caktus/margarita/pull/147#discussion_r92013358","pull_request_url":"https://api.github.com/repos/caktus/margarita/pulls/147","_links":{"self":{"href":"https://api.github.com/repos/caktus/margarita/pulls/comments/92013358"},"html":{"href":"https://github.com/caktus/margarita/pull/147#discussion_r92013358"},"pull_request":{"href":"https://api.github.com/repos/caktus/margarita/pulls/147"}}},"pull_request":{"url":"https://api.github.com/repos/caktus/margarita/pulls/147","id":97368695,"html_url":"https://github.com/caktus/margarita/pull/147","diff_url":"https://github.com/caktus/margarita/pull/147.diff","patch_url":"https://github.com/caktus/margarita/pull/147.patch","issue_url":"https://api.github.com/repos/caktus/margarita/issues/147","number":147,"state":"open","locked":false,"title":"Updated Xenial Support PR","user":{"login":"vkurup","id":4413,"avatar_url":"https://avatars.githubusercontent.com/u/4413?v=3","gravatar_id":"","url":"https://api.github.com/users/vkurup","html_url":"https://github.com/vkurup","followers_url":"https://api.github.com/users/vkurup/followers","following_url":"https://api.github.com/users/vkurup/following{/other_user}","gists_url":"https://api.github.com/users/vkurup/gists{/gist_id}","starred_url":"https://api.github.com/users/vkurup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkurup/subscriptions","organizations_url":"https://api.github.com/users/vkurup/orgs","repos_url":"https://api.github.com/users/vkurup/repos","events_url":"https://api.github.com/users/vkurup/events{/privacy}","received_events_url":"https://api.github.com/users/vkurup/received_events","type":"User","site_admin":false},"body":"This supercedes #138. I didn't want to hijack that one because I think some projects may be using it directly. I did, however, base my work off that PR so hopefully it will be easy for those projects to migrate once this is merged. Please review Victor's initial PR description in #138, and then some of the following comments which explain most of the changes that I made.\r\n\r\nI have tested this branch with multiple deploys (over and over again), including the following scenarios:\r\n- Fresh 16.04 install on a t2.small instance\r\n- Fresh 16.04 install on a m4.large instance (which doesn't have an eth0 interface, but an ens3 one instead)\r\n- Fresh 14.04 install\r\n- Upgrade of a 14.04, margarita 1.7.2, salt 2015.5.5 install\r\n\r\nIssues addressed:\r\n- [Salt 2016.3.2 doesn't work with Ubuntu 14.04](https://github.com/saltstack/salt/issues/36940#issuecomment-260592089). Version 2016.3.4 seems to work with both 14.04 and 16.04, so I'll be specifying that in the accompanying d-p-t PR\r\n- Some (but not all) 16.04 installations come with network interfaces that are not named eth0, eth1, etc. I still haven't figured out the rhyme or reason to when this happens, but I know that m4.large Ubuntu instances have network interfaces named 'ens3', where the '3' can be variable. Thanks to help from @jbradberry , I changed our code to have each minion store its default_route into the salt mine, along with its list of interfaces. From those 2 values, we can get the primary ip for each minion.\r\n- I preserved the code that allows you to specify primary_iface in the pillar. Using a pillar value isn't the best way to do this, though because each individual machine could have a different iface name, so having only 1 pillar variable doesn't really make sense. I could remove the primary_iface code entirely, but wasn't sure if it was being used by current projects.\r\n- As mentioned by @vrocha, current versions of salt don't work with pip 8.1.1, but older versions of salt don't work with pip>8.1.1, so I added a salt-version check to decide which version of pip to use.\r\n- @vrocha also mentioned that 2 deploys were necessary to get everything to work. This is because 16.04 now uses systemd instead of upstart, and systemd needs a 'daemon-reload' anytime an init script changes. Salt is supposed to do this automatically for you, but [it doesn't work in the versions we have](https://github.com/saltstack/salt/issues/34927). So, I added a `onchanges` requisite to watch the init file and call daemon-reload when necessary. I added a conditional around it so that this is a no-op if we're not using systemd.\r\n- Our supervisor init script doesn't have a command to do 'service supervisor status' and salt 2016.3.4 doesn't seem to like that. Old versions of salt didn't seem to care, but, for that reason, I upgraded the init script to one provided in Supervisor's github repo: https://github.com/Supervisor/initscripts/blob/master/ubuntu\r\n\r\nFor the upgrade of 14.04 or 12.04 projects, and for any projects currently using #138 directly, there will need to be minor changes made on the django-project-template side:\r\n- the `install_salt.sh` script needs to be udpated to the latest version.\r\n- In the fabfile, SALT_VERSION will need to be 2016.3.4\r\n- In the fabfile, this change will need to be made to add the default_route to the mine for each minion:\r\n```\r\n         'mine_functions': {\r\n-            'network.interfaces': []\r\n+            'network.interfaces': [],\r\n+            'network.default_route': {\r\n+                'family': 'inet',\r\n+            },\r\n         },\r\n```\r\n\r\nOnce those changes are made, you'll need to run these commands:\r\n```\r\nfab staging setup_master\r\nfab staging setup_minion:<INSERT CURRENT ROLES HERE> -H <MINION_IP>\r\n# repeat the setup_minion call for each minion.\r\nfab staging deploy\r\n```\r\n\r\nLink to the accompanying d-p-t PR: https://github.com/caktus/django-project-template/pull/280\r\n\r\nBecause projects will break if they don't do the steps above, I'd recommend bumping margarita's major version, once we decide that this is the correct approach.","created_at":"2016-12-09T19:46:22Z","updated_at":"2016-12-12T18:56:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f997e78cd6539f3c1addf35a800526cfa06ac29e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/caktus/margarita/pulls/147/commits","review_comments_url":"https://api.github.com/repos/caktus/margarita/pulls/147/comments","review_comment_url":"https://api.github.com/repos/caktus/margarita/pulls/comments{/number}","comments_url":"https://api.github.com/repos/caktus/margarita/issues/147/comments","statuses_url":"https://api.github.com/repos/caktus/margarita/statuses/c4f1b3180748c93d59e774080edfa87eff73e6d8","head":{"label":"caktus:vk-xenial","ref":"vk-xenial","sha":"c4f1b3180748c93d59e774080edfa87eff73e6d8","user":{"login":"caktus","id":242157,"avatar_url":"https://avatars.githubusercontent.com/u/242157?v=3","gravatar_id":"","url":"https://api.github.com/users/caktus","html_url":"https://github.com/caktus","followers_url":"https://api.github.com/users/caktus/followers","following_url":"https://api.github.com/users/caktus/following{/other_user}","gists_url":"https://api.github.com/users/caktus/gists{/gist_id}","starred_url":"https://api.github.com/users/caktus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caktus/subscriptions","organizations_url":"https://api.github.com/users/caktus/orgs","repos_url":"https://api.github.com/users/caktus/repos","events_url":"https://api.github.com/users/caktus/events{/privacy}","received_events_url":"https://api.github.com/users/caktus/received_events","type":"Organization","site_admin":false},"repo":{"id":9696950,"name":"margarita","full_name":"caktus/margarita","owner":{"login":"caktus","id":242157,"avatar_url":"https://avatars.githubusercontent.com/u/242157?v=3","gravatar_id":"","url":"https://api.github.com/users/caktus","html_url":"https://github.com/caktus","followers_url":"https://api.github.com/users/caktus/followers","following_url":"https://api.github.com/users/caktus/following{/other_user}","gists_url":"https://api.github.com/users/caktus/gists{/gist_id}","starred_url":"https://api.github.com/users/caktus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caktus/subscriptions","organizations_url":"https://api.github.com/users/caktus/orgs","repos_url":"https://api.github.com/users/caktus/repos","events_url":"https://api.github.com/users/caktus/events{/privacy}","received_events_url":"https://api.github.com/users/caktus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caktus/margarita","description":"A collection of delicious Salt states for Django project deployments.","fork":false,"url":"https://api.github.com/repos/caktus/margarita","forks_url":"https://api.github.com/repos/caktus/margarita/forks","keys_url":"https://api.github.com/repos/caktus/margarita/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caktus/margarita/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caktus/margarita/teams","hooks_url":"https://api.github.com/repos/caktus/margarita/hooks","issue_events_url":"https://api.github.com/repos/caktus/margarita/issues/events{/number}","events_url":"https://api.github.com/repos/caktus/margarita/events","assignees_url":"https://api.github.com/repos/caktus/margarita/assignees{/user}","branches_url":"https://api.github.com/repos/caktus/margarita/branches{/branch}","tags_url":"https://api.github.com/repos/caktus/margarita/tags","blobs_url":"https://api.github.com/repos/caktus/margarita/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caktus/margarita/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caktus/margarita/git/refs{/sha}","trees_url":"https://api.github.com/repos/caktus/margarita/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caktus/margarita/statuses/{sha}","languages_url":"https://api.github.com/repos/caktus/margarita/languages","stargazers_url":"https://api.github.com/repos/caktus/margarita/stargazers","contributors_url":"https://api.github.com/repos/caktus/margarita/contributors","subscribers_url":"https://api.github.com/repos/caktus/margarita/subscribers","subscription_url":"https://api.github.com/repos/caktus/margarita/subscription","commits_url":"https://api.github.com/repos/caktus/margarita/commits{/sha}","git_commits_url":"https://api.github.com/repos/caktus/margarita/git/commits{/sha}","comments_url":"https://api.github.com/repos/caktus/margarita/comments{/number}","issue_comment_url":"https://api.github.com/repos/caktus/margarita/issues/comments{/number}","contents_url":"https://api.github.com/repos/caktus/margarita/contents/{+path}","compare_url":"https://api.github.com/repos/caktus/margarita/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caktus/margarita/merges","archive_url":"https://api.github.com/repos/caktus/margarita/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caktus/margarita/downloads","issues_url":"https://api.github.com/repos/caktus/margarita/issues{/number}","pulls_url":"https://api.github.com/repos/caktus/margarita/pulls{/number}","milestones_url":"https://api.github.com/repos/caktus/margarita/milestones{/number}","notifications_url":"https://api.github.com/repos/caktus/margarita/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caktus/margarita/labels{/name}","releases_url":"https://api.github.com/repos/caktus/margarita/releases{/id}","deployments_url":"https://api.github.com/repos/caktus/margarita/deployments","created_at":"2013-04-26T14:20:27Z","updated_at":"2016-11-30T18:29:23Z","pushed_at":"2016-12-12T17:43:09Z","git_url":"git://github.com/caktus/margarita.git","ssh_url":"git@github.com:caktus/margarita.git","clone_url":"https://github.com/caktus/margarita.git","svn_url":"https://github.com/caktus/margarita","homepage":null,"size":256,"stargazers_count":31,"watchers_count":31,"language":"SaltStack","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":25,"forks":10,"open_issues":25,"watchers":31,"default_branch":"develop"}},"base":{"label":"caktus:develop","ref":"develop","sha":"81b19d0bd1844222149a95fbbbb9065565c4f204","user":{"login":"caktus","id":242157,"avatar_url":"https://avatars.githubusercontent.com/u/242157?v=3","gravatar_id":"","url":"https://api.github.com/users/caktus","html_url":"https://github.com/caktus","followers_url":"https://api.github.com/users/caktus/followers","following_url":"https://api.github.com/users/caktus/following{/other_user}","gists_url":"https://api.github.com/users/caktus/gists{/gist_id}","starred_url":"https://api.github.com/users/caktus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caktus/subscriptions","organizations_url":"https://api.github.com/users/caktus/orgs","repos_url":"https://api.github.com/users/caktus/repos","events_url":"https://api.github.com/users/caktus/events{/privacy}","received_events_url":"https://api.github.com/users/caktus/received_events","type":"Organization","site_admin":false},"repo":{"id":9696950,"name":"margarita","full_name":"caktus/margarita","owner":{"login":"caktus","id":242157,"avatar_url":"https://avatars.githubusercontent.com/u/242157?v=3","gravatar_id":"","url":"https://api.github.com/users/caktus","html_url":"https://github.com/caktus","followers_url":"https://api.github.com/users/caktus/followers","following_url":"https://api.github.com/users/caktus/following{/other_user}","gists_url":"https://api.github.com/users/caktus/gists{/gist_id}","starred_url":"https://api.github.com/users/caktus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caktus/subscriptions","organizations_url":"https://api.github.com/users/caktus/orgs","repos_url":"https://api.github.com/users/caktus/repos","events_url":"https://api.github.com/users/caktus/events{/privacy}","received_events_url":"https://api.github.com/users/caktus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caktus/margarita","description":"A collection of delicious Salt states for Django project deployments.","fork":false,"url":"https://api.github.com/repos/caktus/margarita","forks_url":"https://api.github.com/repos/caktus/margarita/forks","keys_url":"https://api.github.com/repos/caktus/margarita/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caktus/margarita/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caktus/margarita/teams","hooks_url":"https://api.github.com/repos/caktus/margarita/hooks","issue_events_url":"https://api.github.com/repos/caktus/margarita/issues/events{/number}","events_url":"https://api.github.com/repos/caktus/margarita/events","assignees_url":"https://api.github.com/repos/caktus/margarita/assignees{/user}","branches_url":"https://api.github.com/repos/caktus/margarita/branches{/branch}","tags_url":"https://api.github.com/repos/caktus/margarita/tags","blobs_url":"https://api.github.com/repos/caktus/margarita/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caktus/margarita/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caktus/margarita/git/refs{/sha}","trees_url":"https://api.github.com/repos/caktus/margarita/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caktus/margarita/statuses/{sha}","languages_url":"https://api.github.com/repos/caktus/margarita/languages","stargazers_url":"https://api.github.com/repos/caktus/margarita/stargazers","contributors_url":"https://api.github.com/repos/caktus/margarita/contributors","subscribers_url":"https://api.github.com/repos/caktus/margarita/subscribers","subscription_url":"https://api.github.com/repos/caktus/margarita/subscription","commits_url":"https://api.github.com/repos/caktus/margarita/commits{/sha}","git_commits_url":"https://api.github.com/repos/caktus/margarita/git/commits{/sha}","comments_url":"https://api.github.com/repos/caktus/margarita/comments{/number}","issue_comment_url":"https://api.github.com/repos/caktus/margarita/issues/comments{/number}","contents_url":"https://api.github.com/repos/caktus/margarita/contents/{+path}","compare_url":"https://api.github.com/repos/caktus/margarita/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caktus/margarita/merges","archive_url":"https://api.github.com/repos/caktus/margarita/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caktus/margarita/downloads","issues_url":"https://api.github.com/repos/caktus/margarita/issues{/number}","pulls_url":"https://api.github.com/repos/caktus/margarita/pulls{/number}","milestones_url":"https://api.github.com/repos/caktus/margarita/milestones{/number}","notifications_url":"https://api.github.com/repos/caktus/margarita/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caktus/margarita/labels{/name}","releases_url":"https://api.github.com/repos/caktus/margarita/releases{/id}","deployments_url":"https://api.github.com/repos/caktus/margarita/deployments","created_at":"2013-04-26T14:20:27Z","updated_at":"2016-11-30T18:29:23Z","pushed_at":"2016-12-12T17:43:09Z","git_url":"git://github.com/caktus/margarita.git","ssh_url":"git@github.com:caktus/margarita.git","clone_url":"https://github.com/caktus/margarita.git","svn_url":"https://github.com/caktus/margarita","homepage":null,"size":256,"stargazers_count":31,"watchers_count":31,"language":"SaltStack","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":25,"forks":10,"open_issues":25,"watchers":31,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/caktus/margarita/pulls/147"},"html":{"href":"https://github.com/caktus/margarita/pull/147"},"issue":{"href":"https://api.github.com/repos/caktus/margarita/issues/147"},"comments":{"href":"https://api.github.com/repos/caktus/margarita/issues/147/comments"},"review_comments":{"href":"https://api.github.com/repos/caktus/margarita/pulls/147/comments"},"review_comment":{"href":"https://api.github.com/repos/caktus/margarita/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/caktus/margarita/pulls/147/commits"},"statuses":{"href":"https://api.github.com/repos/caktus/margarita/statuses/c4f1b3180748c93d59e774080edfa87eff73e6d8"}}}}
{"actor":{"display_login":"dpoirier"}}