boolman
(boolman)
May 2, 2016, 8:31am
1
I’m not sure if I’m doing this the correct way.
I want to use cloud-init to configure my template’s…
my problem is that I can’t use variables in USER_DATA, I want to set hostname but the variable is empty.
CONTEXT=[HOSTNAME="$NAME",NETWORK=“YES”,USER_DATA="#cloud-config
bootcmd:
ifdown -a
hostname: $HOSTNAME
fqdn: $HOSTNAME.se-ix.delta.prod
manage_etc_hosts: true
packages:
a
b
c
users:
name: foobar
sudo: ALL=(ALL) NOPASSWD:ALL
…
…
…
…
ruben
(Rubén S. Montero)
May 2, 2016, 8:43am
2
HOSTNAME has to be defined in the template at first level, you can use a
user input (template creation form) to let the user set it:
NAME="myfqdn"
...
CONTEXT = [ HOSTNAME="$NAME" ...
Cheers
boolman
(boolman)
May 2, 2016, 9:32am
3
thanks, seems to work! !
another related issue I guess, is that I’m trying to create a default user…
and it dont like my passwd line, which is generated with ‘printf installer | mkpasswd --method=SHA-512 --rounds=4096’
eg:
[USER_DATA="#cloud-config
…
…
…
users:
name: installer
sudo: ALL=(ALL) NOPASSWD:ALL
passwd: $6$rounds=4096$JSIZNYut$nYB/3TXqSK8u7lSiEvmW7ate2Zbu5hIhT3tAKxS/3jqwylX2Olzl4uh2qDzaEdJ9.7z8EvB3cgBMicVE1Xn6y.
…
…
…"]
boolman
(boolman)
May 2, 2016, 2:18pm
4
it works if I move the hash to a user input variable…
PW=“M|text|password hash” ]
and use
passwd: ‘$PW’