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

--user-data-file not used? #106

Closed
zubfatal opened this issue Jul 19, 2016 · 5 comments
Closed

--user-data-file not used? #106

zubfatal opened this issue Jul 19, 2016 · 5 comments

Comments

@zubfatal
Copy link

Created a droplet with the --user-data-file argument with a local file containing a few lines of shell code, which normally works when used from the control panel. The data doesn't seem to be used.

@bryanl
Copy link
Contributor

bryanl commented Jul 19, 2016

This is a feature I see used a bunch in doctl. Curious to what the first line of the file pointed to by --user-data-file looks like.

@zubfatal
Copy link
Author

Sure thing, this is the entire script, except for the IP addresses :)

#!/bin/sh
for X in 1.2.3.4 2.3.4.5 do ; ufw allow from $X to any proto tcp port 22 ; done
sed -r -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc
echo '' >> /root/.bashrc
echo '# Force prompt in other colors for root' >> /root/.bashrc
echo "PS1='\${debian_chroot:+(\$debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '" >> /root/.bashrc

All it does is open SSH for a couple of IPs, enable color prompts for all users created later, and a specific colored prompt for root, not a big secret :)

@bryanl
Copy link
Contributor

bryanl commented Jul 19, 2016

I ran a test of doctl compute droplet create with the --user-data-file with success. Curious if there is any clues in /var/log/cloud-init-output.log?

@zubfatal
Copy link
Author

zubfatal commented Jul 19, 2016

@bryanl argh! sorry for the inconvenience man :( it seems there actually was an error in my stupid script

/var/log/cloud-init-output-log:

Cloud-init v. 0.7.5 running 'modules:final' at Tue, 19 Jul 2016 18:51:24 +0000. Up 21.83 seconds.
/var/lib/cloud/instance/scripts/part-001: 2: /var/lib/cloud/instance/scripts/part-001: Syntax error: word unexpected (expecting "do")
2016-07-19 14:51:24,487 - util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [2]
2016-07-19 14:51:24,490 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2016-07-19 14:51:24,491 - util.py[WARNING]: Running scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_scripts_user.pyc'>) failed
Cloud-init v. 0.7.5 finished at Tue, 19 Jul 2016 18:51:24 +0000. Datasource DataSourceDigitalOcean.  Up 22.04 seconds

The line in my script should have been

for X in 1.2.3.4 2.3.4.5 ; do ufw allow from $X to any proto tcp port 22 ; done

the difference being placement of the semicolon and do
Hopefully i'll remember to check that log file :)

@bryanl
Copy link
Contributor

bryanl commented Jul 19, 2016

No problem. Sometimes the details are the killer!

@bryanl bryanl closed this as completed Jul 19, 2016
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

No branches or pull requests

2 participants