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

Allow jinja templates while provisioning #23

Open
wants to merge 1 commit into
base: multi-pr
Choose a base branch
from

Conversation

eedgar
Copy link

@eedgar eedgar commented Aug 12, 2020

I used this to dynamically set the hostname based on templates. instead of having to create a file for every vm etc.
This should work for all provisioning cases I found.

you should be able to set additional template args as well .. name is implied.

"provision": [
{
"type": "shell",
"inline": "echo {{name}} > /tmp/out2",
"template": "True"
},
{
"type": "shell",
"path": "./salt-minion.sh",
"template": "True"
},
{
"type": "file",
"source": "./temporary.txt",
"destination": "/tmp/temporary.txt",
"template": "True"
}
]

more temporary.txt
{{name}}

more salt-minion.sh
#!/bin/bash
sudo mkdir -p /etc/salt

Set the minion id

sudo sh -c "echo {{name}} > /etc/salt/minion_id"
sudo wget -O - https://repo.saltstack.com/py3/ubuntu/20.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
sudo sh -c "echo 'deb http://repo.saltstack.com/py3/ubuntu/20.04/amd64/latest focal main' > /etc/apt/sources.list.d/saltstack.list"
sudo apt-get update
sudo apt-get -y install salt-minion

Set the hostname

sudo salt-call --local network.mod_hostname {{name}}

Restart the salt-minion service

sudo service salt-minion restart

@mkinney
Copy link
Owner

mkinney commented Nov 6, 2020

I am so sorry. I thought I had notifications enabled, but I must not have it set correctly or something. I just stumbled on this PR. I'll take a look at this soon. Thanks for the contribution.

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.

None yet

2 participants