0

I have some salt states that are applied to some specific minions using the minion id. Now I am moving to a cloud provider, and need to apply this states based on tags that salt-cloud can set.

IE. I have an instance runnning in AWS (not provision by salt-stack), I can saltify it with salt-cloud and saltify module, and now I can recognize my minion:

root@instance1:~# salt instance1 test.ping
instance1:
    True


root@instance:~# salt-cloud -f get_tags my-ec2-eu-west-private-ips resource_id=instance1_awsid
my-ips:
    ----------
    ec2:
        |_
          ----------
          key:
              TagName1
          resourceId:
              instance1_awsid
          resourceType:
              instance
          value:
              Value1
        |_
          ----------
          key:
              TagName1
          resourceId:
              instance1_awsid
          resourceType:
              instance
          value:
              Value2

I wish to apply my states based on this values:

IE: instead of the clasic:

salt instance1 state.highstate

or

salt instance1 state.sls configure.service

I wish to do something like:

salt TagName1=Value1 state.highstate

or

salt TagName1=Value1 state.sls configure.service
4
  • salt-cloud is still a hack for EC2 instance provisioning.
    – mootmoot
    Apr 12, 2017 at 16:51
  • @mootmoot Is there a better way to provision the ec2 instances as minion than using salt-cloud ? Or a hack is the best option of salt?
    – bvcelari
    Apr 18, 2017 at 13:49
  • For mean of continuous integration, maybe you should try terraform. In saltstack, to provision a salt-master and subsequent salt-minion is not straightforward. i. salt-cloud can create the instance and identify it by the name it created. It cannot apply tag to it. ii. You can only use salt.states.boto_ec2.instance_present to add/change the tag. OTH, using terraform is cleaner, because you can tag the instance and also pass saltstack bootstrap string during provisioning.
    – mootmoot
    Apr 18, 2017 at 14:28
  • salt cloud is still a hack in 2020
    – nnsense
    Jun 2, 2020 at 13:18

1 Answer 1

1

I will answer myself and maybe save some time to others.

Looks like you cannot use that tags to provide states, however, you can use some of the modules from salt-contrib, to add this tags to the grain items.

https://github.com/saltstack/salt-contrib/tree/master/grains

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.