Script to user_data not working

Hello,

I’m trying to run the following script during the deployment but it seems that my script isn’t executed:
#!/bin/bash
mkdir /tmp/TMP
cd /tmp/TMP
sleep 2m
wget http://mirrors.kernel.org/ubuntu/pool/universe/i/ipmitool/ipmitool_1.8.18-5build1_amd64.deb -P /opt/TMP/

  • The sleep 2m is only to stop the installation to see if my script is executed but nothing.
  • I’m using the following command to start the deployment:
    maas $PROFILE machine deploy $SYSTEM_ID user_data@=/opt/test.sh

Can someone help me please !

user_data must be base64 encoded, try

maas $PROFILE machine deploy $SYSTEM_ID user_data=$(base64 /opt/test.sh)

I would also suggest installing ipmitool from the archive to ensure your install has the latest security and bug fixes.

#cloud-config
packages:
 - ipmitool

Hi Ltrager and thank you for the reply,

I already tried to convert the script with base64 but i got the following error:
'bXAvVE1QCmNkIC90bXAvVE1QCgplY2hvICI9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09' is not a name=value or name@=filename pair
In my previous thread i got a reply that i can pass the script directly to user_data
user_data@=/opt/test.sh
It’s working only for packages installation but a script with files and folders creation i’m getting the error above !

Hi !
It could also be a part of your curtin preseed file like I do :

20_install_packages: [“curtin”, “in-target”, “–”, “sh”, “-c”, “sudo apt-get -y install vlan ipmitool make libelf-dev gcc”]

Thanks Ltrager,
I will try with :
20_create_folder: [“curtin”, “in-target”, “–”, “sh”, “-c”, “sudo mkdir /tmp/TMP”] and get back to you.

You should use /var/tmp instead of /tmp which seems to be cleaned at every reboot on Ubuntu

I’m able to run scripts using curtin, it looks like cloud-init isn’t working. I will post an examples on how to use curtin.

Its probably because it has multiple lines and makes it not valid. Try this:

maas $PROFILE machine deploy $SYSTEM_ID user_data=$(base64 -w 0 /opt/test.sh)
1 Like

I confirm that the custom script is working with both curtin and user_data:
1- curtin: a file for Ubuntu versiob should be created and may specify the target id needed.
2- user_data: with the option base64 -w 0 path_to_script the installation should be working.

Thanks to everyone.

Hi @abdelkader-1 can you put more clue how figure out this curtin/cloud-init approach . I mean examples.

Thanks,
Stefan