saltstack-formulas / lxd-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
21 stars 18 forks source link

Saltify? #3

Closed hackel closed 6 years ago

hackel commented 7 years ago

Does this formula support automatically saltifying a container? It seems like I would have to manually install salt in the container to set it up as a minion. Or would it be better to figure out how to do this using salt-cloud?

bobslee commented 6 years ago

@pcdummy @keesbos Please could you answer this question?

keesbos commented 6 years ago

Nope. It doesn't. Right now you'll have to install the salt packages in the container too (to have salt configure the os/apps in the container).

It would be nice to have a roster like ssh but doing stuff via lxc. In that case we would just need the host to be salted.

morgana2313 commented 6 years ago

I'm quite new to Saltstack, but I'm trying to script this saltifying with a pre-mounted bootstrap_minion.sh script:

salt-call lxd.container_execute container_name '["/premounted/bootstrap_minion.sh"]'

works ok and saltifies the minion succesfully. Now I'm trying to figure out how to do this from a state.sls file:

{% salt.lxd.container_execute('container_name',"/premounted/bootstrap_minion.sh") %}

gives failed: Jinja syntax error: Encountered unknown tag 'salt'.; line 21

Can somebody point me in the right direction?

jochumdev commented 6 years ago

Hi @morgana2313

Use the module state: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.module.html

And sorry for the late reply.

kfix commented 6 years ago

@morgana2313 your state.sls would resemble:

run-lxd-module-exec:
   module.run:
      - name: lxd.container_execute
      - m_name: container_name
      - cmd: [ "/premounted/bootstrap_minion.sh" ]
jochumdev commented 6 years ago

I've added support for bootstraping/salitfying Containers, see: https://github.com/saltstack-formulas/lxd-formula/blob/master/pillar.example.yaml#L13

rmader commented 6 years ago

@pcdummy thanks for implementing this. I'm currently trying it out, but if I understand everything correctly, the salt master still needs to accepts the corresponding minion key (currently the newly created minion just times out).

Any ideas how that could be fixed?

Edit: created a new issue #13