Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control from pillar if the service is running and enabled #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dnABic
Copy link

@dnABic dnABic commented Sep 13, 2017

Making it possible to control from pillars if service is running and / or enabled. The idea is identical to the one in rabbitmq formula: https://github.com/saltstack-formulas/rabbitmq-formula

In my use case, I create an AWS image where I use this saltstack formula to install elasticsearch. Still, at this point I don't know final configuration and therefore I don't want that elasticsearch runs.

In latter steps, I create aws ec2 instance of previously created image. Then salt stack will do the final configuration of elasticsearch and finally start the service.

@dnABic dnABic changed the title Control from pillar if the service is running and elabled Control from pillar if the service is running and enabled Sep 14, 2017
@myoung34
Copy link
Contributor

@dnABic can you rebase against master to see if that changes the tests pass/fail?

@dnABic
Copy link
Author

dnABic commented Sep 19, 2017

@myoung34 the changes made test to pass.

@blbradley
Copy link
Contributor

I recommend using elasticsearch.pkg state during your AMI creation step and elasticsearch state on your running instances.

@myoung34
Copy link
Contributor

myoung34 commented Sep 19, 2017

@blbradley Im torn on that, because I can actually see the value if he doesnt run salt post-AMI (as I do not). I use it purely to build, not to manage, so on AMI creation my last steps are to remove salt to save some memory.

@dnABic fwiw Im using this formula as is with a very very generic placeholder /etc/elasticsearch/elasticsearch.yml to get it through, then in packer after salt has run i use:

sudo service elasticsearch stop && sudo rm -rf /var/log/elasticsearch/* /var/lib/elasticsearch/*

To clean up node data so that when I spin it up elasticsearch is fresh.

@blbradley
Copy link
Contributor

@myoung34 If you used just elasticsearch.pkg during your Packer build, your extra steps would not be required (sans SaltStack removal).

rabbitmq-formula seems to have used this pattern because their pkg.installed and service.running states are in the same file. So, you can't do what I've described with that formula without refactoring.

I'm not against this change. Just providing an alternative. I see lots of feature flags popping up in formulas in situations where a subset of the formula's states can be used instead. This feature flag creep comes from users that want to edit their pillar not under source control vs editing states under version control: ✋ (hand raise as one of those users).

@myoung34
Copy link
Contributor

It definitely is a smell, the workaround I have would be more viable. I agree, importing a service state should have a consistent behavior, and should both enable and start a service. Not sure Id merge this but instead use my workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants