forked from madorn/cloud-init-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04-shell_script.txt
More file actions
36 lines (26 loc) · 835 Bytes
/
04-shell_script.txt
File metadata and controls
36 lines (26 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Create a userdata script
cat > ~/userdata.txt <<EOF
#!/bin/sh
echo "Hello World. The time is now \$(date -R)!" | tee /home/cirros/output.txt
EOF
# Boot an instance using userdata script
nova boot --image cirros --flavor m1.summit --user-data userdata.txt myuserdatainstance
# List instances, notice status of instance
nova list
# View console log of instance
nova console-log myuserdatainstance
# Get VNC console
nova get-vnc-console myuserdatainstance novnc
# Open the URL in your browser.
# username: cirros
# password: cubswin:)
# View file
sudo cat output.txt
# From the instance, query the Metadata service.
# You should be able to see the user data
curl 169.254.169.254/openstack/latest/user_data
# Log out of instance
exit
######!!!From Your SSH Session!!!######
# Delete the instance
nova delete myuserdatainstance