bright-motherboard-93404
09/21/2018, 5:56 PMuser_data
that I'm supplying to my ec2 instances isn't getting run. When I log in with ssh and run the same command (python -m SimpleHTTPServer), everything works as expected. Is there any way to debug this situation?group = ec2.SecurityGroup('web-secgrp',
description='Enable HTTP access',
ingress=[
{ 'protocol': 'tcp', 'from_port': 22, 'to_port': 22, 'cidr_blocks': ['0.0.0.0/0'] },
{ 'protocol': 'tcp', 'from_port': 8888, 'to_port': 8888, 'cidr_blocks': ['0.0.0.0/0'] }
])
user_data = """
#!/bin/bash
echo "Hello, World!" > index.html
nohup python -m SimpleHTTPServer 8888 &
"""
server = ec2.Instance('web-server-www',
instance_type=instance_type,
key_name=key_pair.key_name,
security_groups=[group.name],
user_data=user_data,
ami=ami)
key_pair
is a local .pem key that I use to be able to log inmicroscopic-florist-22719
incalculable-sundown-82514
09/21/2018, 6:00 PM/var/log/cloud-init-output.log
on your VM? If the user_data script ran, there should be some logs there.bright-motherboard-93404
09/21/2018, 6:01 PMincalculable-sundown-82514
09/21/2018, 6:01 PMbright-motherboard-93404
09/21/2018, 6:01 PMCloud-init v. 18.3-9-g2e62cb8a-0ubuntu1~16.04.2 running 'modules:final' at Fri, 21 Sep 2018 18:01:08 +0000. Up 14.37 seconds.
2018-09-21 18:01:09,080 - util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [-]
2018-09-21 18:01:09,088 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2018-09-21 18:01:09,088 - util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_user.py'>) failed
Cloud-init v. 18.3-9-g2e62cb8a-0ubuntu1~16.04.2 finished at Fri, 21 Sep 2018 18:01:09 +0000. Datasource DataSourceEc2Local. Up 14.49 seconds
incalculable-sundown-82514
09/21/2018, 6:20 PMbright-motherboard-93404
09/21/2018, 6:21 PMincalculable-sundown-82514
09/21/2018, 6:22 PM/var/lib/cloud/instance/scripts/scripts-user
?bright-motherboard-93404
09/21/2018, 6:23 PM2018-09-21 18:01:09,088 - util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_user.py'>) failed
2018-09-21 18:01:09,088 - util.py[DEBUG]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_user.py'>) failed
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 806, in _run_modules
freq=freq)
File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 54, in run
return self._runners.run(name, functor, args, freq, clear_on_fail)
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 188, in run
return (True, results)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 76, in lock
yield self._acquire(name, freq)
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 187, in run
results = functor(*args)
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_user.py", line 45, in handle
util.runparts(runparts_path)
File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 850, in runparts
% (len(failed), len(attempted)))
cloud-init.log
root@ip-172-31-41-50:~# cat /var/lib/cloud/instance/scripts/scripts-user
cat: /var/lib/cloud/instance/scripts/scripts-user: No such file or directory
incalculable-sundown-82514
09/21/2018, 6:23 PMpulumi stack export
on your stack and look for a json field named “user_data”?bright-motherboard-93404
09/21/2018, 6:28 PMuser_data
?incalculable-sundown-82514
09/21/2018, 6:29 PMpulumi stack export
basically dumps the entire state of your stackbright-motherboard-93404
09/21/2018, 6:29 PM"userData": "\n#!/bin/bash\necho \"Hello, World!\" \u003e index.html\nnohup python -m SimpleHTTPServer 8888 \u003e /tmp/server 2\u003e\u00261 \u0026\nsleep 60\n"
incalculable-sundown-82514
09/21/2018, 6:29 PMbright-motherboard-93404
09/21/2018, 6:31 PMincalculable-sundown-82514
09/21/2018, 6:32 PMbright-motherboard-93404
09/21/2018, 6:33 PMincalculable-sundown-82514
09/21/2018, 6:36 PMbright-motherboard-93404
09/21/2018, 6:36 PMincalculable-sundown-82514
09/21/2018, 6:39 PMbright-motherboard-93404
09/21/2018, 6:42 PMincalculable-sundown-82514
09/21/2018, 6:45 PMbright-motherboard-93404
09/21/2018, 6:46 PMincalculable-sundown-82514
09/21/2018, 6:50 PM"userData": "\n#!/bin/bash\necho \"Hello, World!\" > index.html\nnohup python -m SimpleHTTPServer 80 &\n"
bright-motherboard-93404
09/21/2018, 6:52 PMincalculable-sundown-82514
09/21/2018, 6:53 PMbright-motherboard-93404
09/21/2018, 6:54 PMincalculable-sundown-82514
09/21/2018, 6:55 PMbright-motherboard-93404
09/21/2018, 6:57 PMincalculable-sundown-82514
09/21/2018, 7:07 PMbright-motherboard-93404
09/21/2018, 7:14 PMincalculable-sundown-82514
09/21/2018, 7:15 PMbright-motherboard-93404
09/21/2018, 7:15 PM2018-09-21 19:20:37,586 - __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart) userdata: 'b'echo ok > ok'...'
incalculable-sundown-82514
09/21/2018, 7:39 PMbright-motherboard-93404
09/21/2018, 7:42 PMincalculable-sundown-82514
09/21/2018, 8:43 PMtext/plain