Prevent restart with no server credentials which causes exit code 1 #9

Closed
wants to merge 3 commits into
from

Projects

None yet

3 participants

@zaiddabaeen

This is a solution for someone who wants to install blackfire without setting the server credentials right away, such as in public vagrant boxes. Prior to this, on server restart, chef-solo would exit due to exit code 1 from the service restart operation, and the provisioning would fail.

recipes/agent.rb
+ action [:enable]
+ subscribes :restart, 'template[/etc/blackfire/agent]', node[cookbook_name]['agent']['restart_mode']
+ end
+end
@lyrixx
lyrixx Feb 3, 2017 Member

Could you fix the missing new line?

recipes/agent.rb
- action [:enable]
- subscribes :restart, 'template[/etc/blackfire/agent]', node[cookbook_name]['agent']['restart_mode']
-end
+if node[cookbook_name]['agent']['server_id'].empty? == false && node[cookbook_name]['agent']['server_token'].empty? == false
@tucksaun
tucksaun Feb 3, 2017 Member

To me, using only_if or not_if looks more a chef way to do it

@zaiddabaeen

Using not_if guards now.

recipes/agent.rb
supports status: true, start: true, stop: true, restart: true
action [:enable]
subscribes :restart, 'template[/etc/blackfire/agent]', node[cookbook_name]['agent']['restart_mode']
-end
+end
@lyrixx
lyrixx Feb 6, 2017 Member

Could you fix this missing return line ? thanks.

@tucksaun
tucksaun Feb 6, 2017 Member

Could you also remove the .DS_Store file ? Thanks

@zaiddabaeen

Fixed and merged all commits.

@zaiddabaeen

Done.

@lyrixx
lyrixx approved these changes Feb 6, 2017 View changes
recipes/agent.rb
@@ -31,6 +31,8 @@
end
service 'blackfire-agent' do
+ not_if { node[cookbook_name]['agent']['server_id'].empty? }
+ not_if { node[cookbook_name]['agent']['server_token'].empty? }
@tucksaun
tucksaun Feb 6, 2017 Member

one last thing: you also need to check for nil? before empty? as defaults are nil and not empty strings.

Zaid Daba'een added some commits Feb 7, 2017
@tucksaun
Member
tucksaun commented Feb 7, 2017

Thanks @zaiddabaeen.

@tucksaun tucksaun added a commit that referenced this pull request Feb 7, 2017
@tucksaun tucksaun minor #9 Prevent restart with no server credentials which causes exit…
… code 1 (Zaid Daba'een)

This PR was squashed before being merged into the master branch (closes #9).

Discussion
----------

Prevent restart with no server credentials which causes exit code 1

This is a solution for someone who wants to install blackfire without setting the server credentials right away, such as in public vagrant boxes. Prior to this, on server restart, chef-solo would exit due to exit code 1 from the service restart operation, and the provisioning would fail.

Commits
-------

b899e46 Prevent restart with no server credentials which causes exit code 1
5383628
@tucksaun tucksaun added a commit that closed this pull request Feb 7, 2017
@tucksaun tucksaun minor #9 Prevent restart with no server credentials which causes exit…
… code 1 (Zaid Daba'een)

This PR was squashed before being merged into the master branch (closes #9).

Discussion
----------

Prevent restart with no server credentials which causes exit code 1

This is a solution for someone who wants to install blackfire without setting the server credentials right away, such as in public vagrant boxes. Prior to this, on server restart, chef-solo would exit due to exit code 1 from the service restart operation, and the provisioning would fail.

Commits
-------

b899e46 Prevent restart with no server credentials which causes exit code 1
5383628
@tucksaun tucksaun closed this in 5383628 Feb 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment