Last active
          February 24, 2025 04:59 
        
      - 
      
 - 
        
Save RichardBronosky/fa7d4db13bab3fbb8d9e0fff7ea88aa2 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
RichardBronosky revised this gist
Mar 4, 2018 . 2 changed files with 94 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ Installing cloud-init on a fresh Raspbian Lite image ==================================================== ## This is a work in Progress! # Purpose This mainly demonstrates my goal of preparing a Raspberry Pi to be provisioned prior to its first boot. To do this I have chosen to use the same [cloud-init](https://cloud-init.io/) that is the standard for provisioning servers at Amazon EC2, Microsoft Azure, OpenStack, etc. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,36 +3,107 @@ set -x # Get cloud-init sudo apt update sudo debconf-set-selections -v <<<"cloud-init cloud-init/datasources multiselect NoCloud, None" 2>/dev/null sudo apt install -y cloud-init #sudo debconf-set-selections -v <<<"cloud-init cloud-init/datasources multiselect NoCloud, None" 2>/dev/null; sudo dpkg-reconfigure cloud-init -f noninteractive 2>/dev/null; # Prepare datasource sudo tee /etc/cloud/cloud.cfg <<'YAML' # The top level settings are used as module # and system configuration. datasource: NoCloud: seedfrom: /boot/ # A set of users which may be applied and/or used by various modules # when a 'default' entry is found it will reference the 'default_user' # from the distro configuration specified below users: - default # If this is set, 'root' will not be able to ssh in and they # will get a message to login instead as the above $user (debian) disable_root: true # This will cause the set+update hostname module to not operate (if true) preserve_hostname: false # Example datasource config # datasource: # Ec2: # metadata_urls: [ 'blah.com' ] # timeout: 5 # (defaults to 50 seconds) # max_wait: 10 # (defaults to 120 seconds) # The modules that run in the 'init' stage cloud_init_modules: - migrator - bootcmd - write-files - mounts - rsyslog - users-groups #- ssh # The modules that run in the 'config' stage cloud_config_modules: # Emit the cloud config ready event # this can be used by upstart jobs for 'start on cloud-config'. - ssh-import-id - locale - set-passwords - ntp - timezone - runcmd # The modules that run in the 'final' stage cloud_final_modules: - package-update-upgrade-install - scripts-vendor - scripts-per-once - scripts-per-boot - scripts-per-instance - scripts-user - phone-home - final-message # System and/or distro specific settings # (not accessible to handlers/transforms) system_info: # This will affect which distro class gets used distro: debian # Default user name + that default users groups (if added/used) default_user: name: pi #lock_passwd: True # Other config here will be given to the distro class and/or path classes paths: cloud_dir: /var/lib/cloud/ templates_dir: /etc/cloud/templates/ YAML # Create meta-data sudo tee /boot/meta-data <<'YAML' instance-id: iid-raspberrypi-nocloud YAML # Create user-data sudo tee /boot/user-data <<'YAML' #cloud-config packages: - vim - python3-pip ssh_authorized_keys: - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC5UXba62TkiA6VqlBPxXdronnGDDdZ5Tcv0+wLLbb5k7A4Mn/XBZom/mKxbYhKVLDLHPYjpYub2piHOq//hP0qqqYJWMMvmRMGvyU9SAH7p+TLTLflfv8Th2jXAM+WOFESmWAY0uut2O0D7cCN5ILXcPNoGKqWI2Fyyx237pMHYOHYB82rAqdjbBZCJMd/Gd+fD0rogoCX3KZdDStzzl8u4C5aSB3rD7WvGNaqwDoQr+DakKnFXrgJG/rQSDcYuvMmi99bjyYm93riSNJ3QxnFz4eFQSpG28al54IkU1E9/aYfJLImCFfeMVNmbbHxtq9CpWR/HEoK3J4yExglyqCORTciDuydgqgHyVuqREBuxjGS4pldpcvuacqF2El2p6Saias1uv3JuoVLnLCCva4Us+m8p4Z2AQNm0I0Bl1OgJLLQUoe1dFomREBocnuwMByHoYCDYTjxw5DqehuTpSO7RtBVCa6492JnmKmwy1K9jPqsWrdCfEA9DVcnNSYsvqJmfcTHOJJ0pkC/f6QgfuAD3tWVSIZqYKnqkpCtixOS14+uCVe24Q4n8rBZF/8xNXThcbs9kWVi7k3aLgnLOLIosKZkHl1R3n+ss6TBH8D/Z19vuWJpiUNc1GbOpqsRPPFKwEtCUpZbj/D77zgMaRx3YX8w/dLcDZXUwDlwFdK1AQ== - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTcJk15RmarEQiZ7im3F6i5o0OOvPKCOmKKFwpGPJ3MZmYEXW3FRlsdGwRomNWdH6dTiDROQ9Cut0CMbeRrPvp6Y4H2iTXEnKShLYj5h7H00KLZGRcalC/BlpvNIBgasvaHq1Lu1oLJGQg62RErCWk2cdevQkJMAB9QObxukVp1uVBRWxGVlrVk2JbqZZ7zh8Lf81f6k9Lw9F3d03vHKARLIfXZVFpEY+qnTp0oXAJ1xTjrqY5reKNswiLtjyJwR6y16sOFQ4AE7rZI/q4zIcKgeBj/DHx2kqJxB/FSpnPRE0kDaAdbhljC7G8ulXptbd/OAtDLUIhYwvRr+AQKeZt [email protected] YAML # Initialize cloud-init sudo cloud-init init --local # Create a script to run per boot sudo tee /var/lib/cloud/scripts/per-boot/00_run-parts.sh <<'BASH' #!/bin/bash # Prevent *.sh from returning itself if there are no matches @@ -48,16 +119,15 @@ done # Run every per-boot script run-parts --regex '.*\.sh$' /boot/per-boot BASH sudo chmod +x /var/lib/cloud/scripts/per-boot/00_run-parts.sh # Create sample per-boot and per-once scripts sudo mkdir -p /boot/{per-boot,per-once} sudo tee /boot/per-boot/01_get_ready.sh \ /boot/per-boot/02_do_it.sh \ /boot/per-once/01_prepare.sh \ /boot/per-once/02_install_stuff.sh <<'BASH' #!/bin/bash date="$(date +"%x %X")" @@ -66,7 +136,7 @@ script_name="$(basename ${BASH_SOURCE[0]} .sh)" log_name="$(basename $script_path)" echo "$date - $script_name" >> /home/pi/${log_name}.out BASH echo "Cloud-Init setup is complete." # vim: et sw=4 ts=4 sts=4 syntax=sh  - 
        
RichardBronosky revised this gist
Feb 22, 2018 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,13 @@ Installing cloud-init on a fresh Raspbian Lite image ==================================================== # Purpose This mainly demonstrates my goal of preparing a Raspberry Pi to be provisioned prior to its first boot. To do this I have chosen to use the same [cloud-init](https://cloud-init.io/) that is the standard for provisioning servers at Amazon EC2, Microsoft Azure, OpenStack, etc. I found this to be quite challenging because there is little information available for using cloud-init without a cloud. So, this project also servers as a demonstration for anyone on any version of Linux who may want to install from source, and/or use without a cloud. If you fall into that later group, you probably just want to read the code. It's `bash` so everything I do, you could also do at the command line. (Even the `for` loop.) # Usage 1. Download the [lastest Raspbian Lite](https://downloads.raspberrypi.org/raspbian_lite_latest) release and write it to a microSD card. (This can be done from Mac, Windows, or of course Linux.) 1. On the microSD card, create an empty file named `ssh` and one named `wpa_supplicant.conf` (If you are on a Linux machine, you'll have to make sure this is going into the boot partition. On any other OS, the boot partition is the only one that can be mounted.) 1. Put your wifi settings into the `wpa_supplicant.conf` file. (There is a [pretty handy online generator](https://steveedson.co.uk/tools/wpa/) you can use.) 1. Save [this script](https://gist.github.com/RichardBronosky/fa7d4db13bab3fbb8d9e0fff7ea88aa2/raw/cloud-init-setup.sh) onto the microSD card.  - 
        
RichardBronosky revised this gist
Feb 22, 2018 . 5 changed files with 1324 additions and 2098 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,8 +13,6 @@ I found this to be quite challenging because there is little information availab 1. On the microSD card, create an empty file named `ssh` and one named `wpa_supplicant.conf` (If you are on a Linux machine, you'll have to make sure this is going into the boot partition. On any other OS, the boot partition is the only one that can be mounted.) 1. Put your wifi settings into the `wpa_supplicant.conf` file. (There is a [pretty handy online generator](https://steveedson.co.uk/tools/wpa/) you can use.) 1. Save [this script](https://gist.github.com/RichardBronosky/fa7d4db13bab3fbb8d9e0fff7ea88aa2/raw/cloud-init-setup.sh) onto the microSD card. 1. Eject the card. Place it in your Raspberry Pi. Boot it up. 1. Locate your Raspberry Pi on your network. - Most modern routers will allow you to reach it via the hostname it declares, like so: `raspberrypi.local` @@ -38,9 +36,6 @@ pi@raspberrypi:~ $ find /boot/per* /boot/per-once /boot/per-once/01_prepare.sh /boot/per-once/02_install_stuff.sh ``` After 1 reboot you will find this: @@ -52,9 +47,7 @@ pi@raspberrypi:~ $ find /boot/per* /boot/per-once /boot/per-once/[email protected] /boot/per-once/[email protected] pi@raspberrypi:~ $ ls -l -rw-r--r-- 1 root root 62 Feb 21 10:04 per-boot.out -rw-r--r-- 1 root root 68 Feb 21 10:04 per-once.out pi@raspberrypi:~ $ for f in per*; do echo $f; cat $f; done This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,32 +1,21 @@ #!/bin/bash -e set -x # Get cloud-init sudo apt update sudo apt install -y cloud-init # Prepare datasource cat | sudo tee /etc/cloud/cloud.cfg.d/datasource.cfg > /dev/null <<'EOF' datasource: NoCloud: seedfrom: /boot/ EOF # Initialize cloud-init sudo ln -s /usr/local/bin/cloud-init /usr/bin/cloud-init sudo cloud-init init --local # Create meta-data cat | sudo tee /boot/meta-data > /dev/null <<'EOF' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,192 +1,103 @@ Cloud-init v. 0.7.9 running 'init-local' at Thu, 22 Feb 2018 04:03:23 +0000. Up 2626.88 seconds. Cloud-init v. 0.7.9 running 'init-local' at Thu, 22 Feb 2018 04:07:31 +0000. Up 9.60 seconds. Cloud-init v. 0.7.9 running 'init' at Thu, 22 Feb 2018 04:07:39 +0000. Up 17.22 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ 2018-02-22 04:07:42,134 - cc_resizefs.py[WARNING]: Device '/dev/PARTUUID=a00bdab5-02' did not exist. cannot resize: dev=/dev/root mnt_point=/ path=/ Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: SHA256:CZSzYvr7cD1/bLtIiAbrzBvgFrRQ91wA2gsGfSmgTnw root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ |oo. oooo. | |ooo+o+o. | |oo=E. +o | |o+.oo... . | | .+oo. S | | ..o o o . | | o.+ + + .. | | . +.= + .+ | | *+. oooo | +----[SHA256]-----+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: SHA256:APHOBmdFICSPHyFvxgUSArF4xzGIWuKMy8aDqhfXEzQ root@raspberrypi The key's randomart image is: +---[DSA 1024]----+ |=o=+Xoooo | |+ooX OE. | |Boo @.=. | |o+ = B.. | |+. ..+.S | |o=. ..o | |o .o . | |. . | |o. | +----[SHA256]-----+ Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. The key fingerprint is: SHA256:OqnNkoOn0VusMHqUZ3L0uiNQ0jp0aiVAosy3hM0GnPM root@raspberrypi The key's randomart image is: +---[ECDSA 256]---+ |+o. | |*+= | |o=o* | |.o*Eo | |.+=+ . S | |+o+.+..o | |.++*.o* | | .++BB . | |...+==o | +----[SHA256]-----+ Generating public/private ed25519 key pair. Your identification has been saved in /etc/ssh/ssh_host_ed25519_key. Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub. The key fingerprint is: SHA256:K/+JFIOeJwpmaiLogGrj6oXP5sVh0PY9RaxYFU345qc root@raspberrypi The key's randomart image is: +--[ED25519 256]--+ | o+=. | | . ..o . | | . o o ... | | o .o... o | | o..So o | |. . o... +. . . | |+.+. o= + o | |*B+o.. * . . E | |&+++. o.o | +----[SHA256]-----+ Generating locales (this might take a while)... en_GB.UTF-8... done Generation complete. Cloud-init v. 0.7.9 running 'modules:config' at Thu, 22 Feb 2018 04:08:04 +0000. Up 35.80 seconds. Cloud-init v. 0.7.9 running 'modules:final' at Thu, 22 Feb 2018 04:08:15 +0000. Up 46.44 seconds. ci-info: no authorized ssh keys fingerprints found for user debian. Cloud-init v. 0.7.9 finished at Thu, 22 Feb 2018 04:08:16 +0000. Datasource DataSourceNoCloud [seed=ds_config_seedfrom,/boot/][dsmode=net]. Up 47.36 seconds Cloud-init v. 0.7.9 running 'init-local' at Thu, 22 Feb 2018 04:10:31 +0000. Up 9.63 seconds. Cloud-init v. 0.7.9 running 'init' at Thu, 22 Feb 2018 04:10:38 +0000. Up 17.29 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ 2018-02-22 04:10:40,904 - cc_resizefs.py[WARNING]: Device '/dev/PARTUUID=a00bdab5-02' did not exist. cannot resize: dev=/dev/root mnt_point=/ path=/ Cloud-init v. 0.7.9 running 'modules:config' at Thu, 22 Feb 2018 04:10:50 +0000. Up 28.95 seconds. Cloud-init v. 0.7.9 running 'modules:final' at Thu, 22 Feb 2018 04:10:54 +0000. Up 32.77 seconds. Cloud-init v. 0.7.9 finished at Thu, 22 Feb 2018 04:10:55 +0000. Datasource DataSourceNoCloud [seed=ds_config_seedfrom,/boot/][dsmode=net]. Up 33.45 seconds  - 
        
RichardBronosky revised this gist
Feb 21, 2018 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,13 @@ Installing cloud-init on a fresh Raspbian Lite image ==================================================== # Purpose This mainly demonstrates my goal of preparing a Raspberry Pi to be provisioned prior to its first boot. To do this I have chosen to use the same [cloud-init](https://cloud-init.io/) that is the standard for provisioning servers at Amazon EC2, Microsoft Azure, OpenStack, etc. I found this to be quite challenging because there is little information available for using cloud-init without a cloud. So, this project also servers as a demonstration for anyone on any version of Linux who may want to install from source, and/or use without a cloud. If you fall into that later group, you probably just want to read the code. It's `bash` so everything I do, you could also do at the command line. (Even the `for` loop.) # Usage 1. Download the [lastest Raspbian Lite](https://downloads.raspberrypi.org/raspbian_lite_latest) release and write it to a microSD card. (This can be done from Mac, Windows, or of course Linux.) 1. On the microSD card, create an empty file named `ssh` and one named `wpa_supplicant.conf` (If you are on a Linux machine, you'll have to make sure this is going into the boot partition. On any other OS, the boot partition is the only one that can be mounted.) 1. Put your wifi settings into the `wpa_supplicant.conf` file. (There is a [pretty handy online generator](https://steveedson.co.uk/tools/wpa/) you can use.) 1. Save [this script](https://gist.github.com/RichardBronosky/fa7d4db13bab3fbb8d9e0fff7ea88aa2/raw/cloud-init-setup.sh) onto the microSD card.  - 
        
RichardBronosky revised this gist
Feb 21, 2018 . 2 changed files with 2072 additions and 713 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,84 +1,192 @@ Cloud-init v. 17.2 running 'init-local' at Wed, 21 Feb 2018 10:02:04 +0000. Up 687.61 seconds. 2018-02-21 10:02:04,654 - util.py[WARNING]: Getting data from <class 'cloudinit.sources.DataSourceNoCloud.DataSourceNoCloud'> failed Cloud-init v. 17.2 running 'init-local' at Wed, 21 Feb 2018 10:02:10 +0000. Up 694.28 seconds. 2018-02-21 10:02:11,098 - util.py[WARNING]: Getting data from <class 'cloudinit.sources.DataSourceNoCloud.DataSourceNoCloud'> failed Cloud-init v. 17.2 running 'init' at Wed, 21 Feb 2018 10:02:14 +0000. Up 698.52 seconds. ci-info: +++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++ ci-info: +--------+------+---------------+---------------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+------+---------------+---------------+-------+-------------------+ ci-info: | eth0: | True | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | True | 192.168.0.105 | 255.255.255.0 | . | b8:27:eb:00:e2:03 | ci-info: | wlan0: | True | . | . | d | b8:27:eb:00:e2:03 | ci-info: +--------+------+---------------+---------------+-------+-------------------+ ci-info: +++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++ ci-info: +-------+-------------+-------------+---------------+-----------+-------+ ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags | ci-info: +-------+-------------+-------------+---------------+-----------+-------+ ci-info: | 0 | 0.0.0.0 | 192.168.0.1 | 0.0.0.0 | wlan0 | UG | ci-info: | 1 | 192.168.0.0 | 0.0.0.0 | 255.255.255.0 | wlan0 | U | ci-info: +-------+-------------+-------------+---------------+-----------+-------+ Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: SHA256:83gqjGyrs/xafajoXfbzHOOqgBF2tTm719N9ddo1ZZM root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ | . | | . o .| | o . + Eo| | . o o .o| | . . S .+| | o . o = . . o=| | ..oo* + B . o o| | ..++=o+.= + . | | .BB=..o+++ | +----[SHA256]-----+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: SHA256:Ce9pi6LDF2hMaBq+q1hZxqQjGUGTmVIIACpJ1vQGjp4 root@raspberrypi The key's randomart image is: +---[DSA 1024]----+ |XBBo | |**+.o | |*o ..o. | |=+o+. o . | |*Eo.+ S | |.o+=. . . | | o+ . + | |.oo o o . | |+.o+ .. . | +----[SHA256]-----+ Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. The key fingerprint is: SHA256:Wx11XQaeNRBfKBf7bEy8xpeSgKFaFXn6RrTpKDTgBJ8 root@raspberrypi The key's randomart image is: +---[ECDSA 256]---+ | .. +o o*=O| | .o. o.oo.o+B+| | oE.o .+.+o+.o| | .oo . =..o=o| | .. S * .o =*| | . + + o..| | o . | | | | | +----[SHA256]-----+ Generating public/private ed25519 key pair. Your identification has been saved in /etc/ssh/ssh_host_ed25519_key. Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub. The key fingerprint is: SHA256:WAzYAI5zwXerfpJUWY2eaaSsB1Pij7U+6KiMm/+cl6k root@raspberrypi The key's randomart image is: +--[ED25519 256]--+ | .o..+. o | | o..+ +o+ . | |o oo = Boo | | o + Bo= | | X.oS | | = + | | o = o | |o. o=.B | |==ooE= . | +----[SHA256]-----+ Cloud-init v. 17.2 running 'modules:config' at Wed, 21 Feb 2018 10:02:24 +0000. Up 708.21 seconds. Cloud-init v. 17.2 running 'modules:final' at Wed, 21 Feb 2018 10:02:36 +0000. Up 719.71 seconds. ci-info: no authorized ssh keys fingerprints found for user ubuntu. Cloud-init v. 17.2 finished at Wed, 21 Feb 2018 10:02:36 +0000. Datasource DataSourceNone. Up 720.46 seconds 2018-02-21 10:02:36,956 - cc_final_message.py[WARNING]: Used fallback datasource Cloud-init v. 17.2 running 'init-local' at Wed, 21 Feb 2018 10:04:03 +0000. Up 9.43 seconds. Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: SHA256:zHgeR1FpQTsOhEU72mPKllE+iwKMBvwGLwXh/+64+3U root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ | o. +=o+o | |o . .. oo. | |.+ . *.o | | .*o + * + . | | .o=o . S B . | | .o .. + O + | | ...BE. | | o .o. | | +=+ | +----[SHA256]-----+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: SHA256:UowVXI9ZQKgjTvC2Vo32Rlx/acLzpSLfY9lIdCH18AM root@raspberrypi The key's randomart image is: +---[DSA 1024]----+ | .o=+..Eo. | | . +o .= ..+.| | o .=o.oo. .o+| | = *.+ = = +| | + =.+S B + | | + .o . . + | | . . o + + | | . * .| | . . | +----[SHA256]-----+ Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. The key fingerprint is: SHA256:EU4HYiSmEyytsuoUbWpuujf8xaMuIZ2C08pMdfJiiQo root@raspberrypi The key's randomart image is: +---[ECDSA 256]---+ | o. o.+ +.. | |. o+ o + o | | oo o | |o .+ . . | |o=o+= S | |EoO+ o | |BX... + | |B+= o . | |*= =+ | +----[SHA256]-----+ Generating public/private ed25519 key pair. Your identification has been saved in /etc/ssh/ssh_host_ed25519_key. Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub. The key fingerprint is: SHA256:DunTv7bCzwkFVqafn+oH6SZpvT0OWNMwun7RSO7+wJM root@raspberrypi The key's randomart image is: +--[ED25519 256]--+ | o | | + | | + o | | o +.= | | o So*+. | | . + **+.. | | o.*=Eoo | | o*+BBo | | ..X%B+. | +----[SHA256]-----+ Cloud-init v. 17.2 running 'init' at Wed, 21 Feb 2018 10:04:34 +0000. Up 40.14 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Cloud-init v. 17.2 running 'modules:config' at Wed, 21 Feb 2018 10:04:44 +0000. Up 50.37 seconds. Cloud-init v. 17.2 running 'modules:final' at Wed, 21 Feb 2018 10:04:51 +0000. Up 57.34 seconds. ci-info: no authorized ssh keys fingerprints found for user ubuntu. Cloud-init v. 17.2 finished at Wed, 21 Feb 2018 10:04:52 +0000. Datasource DataSourceNoCloud [seed=cmdline,/boot/][dsmode=local]. Up 58.35 seconds Cloud-init v. 17.2 running 'init-local' at Wed, 21 Feb 2018 10:05:49 +0000. Up 9.39 seconds. Cloud-init v. 17.2 running 'init' at Wed, 21 Feb 2018 10:05:57 +0000. Up 17.63 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Cloud-init v. 17.2 running 'modules:config' at Wed, 21 Feb 2018 10:06:09 +0000. Up 29.17 seconds. Cloud-init v. 17.2 running 'modules:final' at Wed, 21 Feb 2018 10:06:12 +0000. Up 32.23 seconds. Cloud-init v. 17.2 finished at Wed, 21 Feb 2018 10:06:13 +0000. Datasource DataSourceNoCloud [seed=cmdline,/boot/][dsmode=local]. Up 32.98 seconds  - 
        
RichardBronosky revised this gist
Feb 21, 2018 . 3 changed files with 64 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,8 @@ I found this to be quite challenging because there is little information availab 1. On the microSD card, create an empty file named `ssh` and one named `wpa_supplicant.conf` (If you are on a Linux machine, you'll have to make sure this is going into the boot partition. On any other OS, the boot partition is the only one that can be mounted.) 1. Put your wifi settings into the `wpa_supplicant.conf` file. (There is a [pretty handy online generator](https://steveedson.co.uk/tools/wpa/) you can use.) 1. Save [this script](https://gist.github.com/RichardBronosky/fa7d4db13bab3fbb8d9e0fff7ea88aa2/raw/cloud-init-setup.sh) onto the microSD card. 1. Save [this modified cmdline.txt file](https://gist.github.com/RichardBronosky/fa7d4db13bab3fbb8d9e0fff7ea88aa2/raw/cmdline.txt) onto the microSD card. - Alternatively, you could just put ` ds=nocloud;seedfrom=/boot/;instance-id=iid-raspberrypi-nocloud` at the end of the existing one. That is all I did. 1. Eject the card. Place it in your Raspberry Pi. Boot it up. 1. Locate your Raspberry Pi on your network. - Most modern routers will allow you to reach it via the hostname it declares, like so: `raspberrypi.local` @@ -25,3 +27,56 @@ I found this to be quite challenging because there is little information availab 1. Run the script that we saved in Step 4 above. - `/boot/cloud-init-setup.sh` - You will be prompted for a password. Again, it is **`raspberry`**. # Result Before rebooting you will find this: ``` pi@raspberrypi:~ $ find /boot/per* /boot/per-boot /boot/per-boot/01_get_ready.sh /boot/per-boot/02_do_it.sh /boot/per-once /boot/per-once/01_prepare.sh /boot/per-once/02_install_stuff.sh pi@raspberrypi:~ $ ls -la drwxr-xr-x 16 pi pi 4096 Feb 21 10:02 cloud-init-master -rw-r--r-- 1 pi pi 1180953 Feb 21 10:01 cloud-init-master.zip ``` After 1 reboot you will find this: ``` pi@raspberrypi:~ $ find /boot/per* /boot/per-boot /boot/per-boot/01_get_ready.sh /boot/per-boot/02_do_it.sh /boot/per-once /boot/per-once/[email protected] /boot/per-once/[email protected] pi@raspberrypi:~ $ ls -la drwxr-xr-x 16 pi pi 4096 Feb 21 10:02 cloud-init-master -rw-r--r-- 1 pi pi 1180953 Feb 21 10:01 cloud-init-master.zip -rw-r--r-- 1 root root 62 Feb 21 10:04 per-boot.out -rw-r--r-- 1 root root 68 Feb 21 10:04 per-once.out pi@raspberrypi:~ $ for f in per*; do echo $f; cat $f; done per-boot.out 21/02/18 10:04:52 - 01_get_ready 21/02/18 10:04:52 - 02_do_it per-once.out 21/02/18 10:04:52 - 01_prepare 21/02/18 10:04:52 - 02_install_stuff ``` After a 2nd reboot you will find this: ``` pi@raspberrypi:~ $ for f in per*; do echo $f; cat $f; done per-boot.out 21/02/18 10:04:52 - 01_get_ready 21/02/18 10:04:52 - 02_do_it 21/02/18 10:06:12 - 01_get_ready 21/02/18 10:06:12 - 02_do_it per-once.out 21/02/18 10:04:52 - 01_prepare 21/02/18 10:04:52 - 02_install_stuff ``` As you can see, the scripts in `/boot/per-boot/` run on every boot. The scripts in `/boot/per-once/` ran once and then got renamed. If you were to change their extension back to `.sh` they would run once again.. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,18 +24,22 @@ done # Configure cloud-init Datasource NoCloud # See: http://cloudinit.readthedocs.io/en/17.2/topics/datasources/nocloud.html?highlight=nocloud if grep -q ds=nocloud /boot/cmdline.txt; then sudo sed -i '${s?$? ds=nocloud;seedfrom=/boot/;instance-id=iid-raspberrypi-nocloud?}' /boot/cmdline.txt fi # Create meta-data cat | sudo tee /boot/meta-data > /dev/null <<'EOF' instance-id: iid-raspberrypi-nocloud EOF # Create user-data cat | sudo tee /boot/user-data > /dev/null <<'EOF' #cloud-config password: passw0rd chpasswd: { expire: True } EOF # Create a script to run per boot @@ -55,6 +59,7 @@ done # Run every per-boot script run-parts --regex '.*\.sh$' /boot/per-boot EOF sudo chmod +x /var/lib/cloud/scripts/per-boot/00_run-parts.sh @@ -72,5 +77,7 @@ script_name="$(basename ${BASH_SOURCE[0]} .sh)" log_name="$(basename $script_path)" echo "$date - $script_name" >> /home/pi/${log_name}.out EOF # vim: et sw=4 ts=4 sts=4 syntax=sh This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=37665771-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait ds=nocloud;seedfrom=/boot/;instance-id=iid-raspberrypi-nocloud quiet init=/usr/lib/raspi-config/init_resize.sh  - 
        
RichardBronosky revised this gist
Feb 21, 2018 . 1 changed file with 14 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ #!/bin/bash -e set -x # Get pip3 sudo apt-get update @@ -12,7 +13,7 @@ sudo pip3 install -r requirements.txt sudo python3 setup.py build sudo python3 setup.py install --init-system systemd sudo ln -s /usr/local/bin/cloud-init /usr/bin/cloud-init sudo cloud-init init --local sudo cloud-init status # Activate systemd services @@ -26,19 +27,19 @@ done sudo sed -i '${s?$? ds=nocloud;seedfrom=/boot/;instance-id=iid-raspberrypi-nocloud?}' /boot/cmdline.txt # Create meta-data cat | sudo tee /boot/meta-data > /dev/null <<'EOF' instance-id: iid-raspberrypi-nocloud EOF # Create user-data cat | sudo tee /boot/user-data > /dev/null <<'EOF' #cloud-config password: passw0rd chpasswd: { expire: True } EOF # Create a script to run per boot cat | sudo tee /var/lib/cloud/scripts/per-boot/00_run-parts.sh > /dev/null <<'EOF' #!/bin/bash # Prevent *.sh from returning itself if there are no matches @@ -54,14 +55,15 @@ done # Run every per-boot script run-parts --regex '.*\.sh$' /boot/per-boot EOF sudo chmod +x /var/lib/cloud/scripts/per-boot/00_run-parts.sh # Create sample per-boot and per-once scripts sudo mkdir -p /boot/{per-boot,per-once} cat | sudo tee /boot/per-boot/01_get_ready.sh \ /boot/per-boot/02_do_it.sh \ /boot/per-once/01_prepare.sh \ /boot/per-once/02_install_stuff.sh > /dev/null <<'EOF' #!/bin/bash date="$(date +"%x %X")" @@ -70,4 +72,5 @@ script_name="$(basename ${BASH_SOURCE[0]} .sh)" log_name="$(basename $script_path)" echo "$date - $script_name" >> /home/pi/${log_name}.out EOF  - 
        
RichardBronosky revised this gist
Feb 21, 2018 . 4 changed files with 97 additions and 60 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,63 +1,27 @@ Installing cloud-init on a fresh Raspbian Lite image ==================================================== ## This is a work in Progress! # Purpose This mainly demonstrates my goal of preparing a Raspberry Pi to be provisioned prior to its first boot. To do this I have chosen to use the same [cloud-init](https://cloud-init.io/) that is the standard for provisioning servers at Amazon EC2, Microsoft Azure, OpenStack, etc. I found this to be quite challenging because there is little information available for using cloud-init without a cloud. So, this project also servers as a demonstration for anyone on any version of Linux who may want to install from source, and/or use without a cloud. If you fall into that later group, you probably just want to read the code. It's `bash` so everything I do, you could also do at the command line. (Even the `for` loop.) # Usage 1. Download the [lastest Raspbian](https://downloads.raspberrypi.org/raspbian_lite_latest) release and write it to a microSD card. (This can be done from Mac, Windows, or of course Linux.) 1. On the microSD card, create an empty file named `ssh` and one named `wpa_supplicant.conf` (If you are on a Linux machine, you'll have to make sure this is going into the boot partition. On any other OS, the boot partition is the only one that can be mounted.) 1. Put your wifi settings into the `wpa_supplicant.conf` file. (There is a [pretty handy online generator](https://steveedson.co.uk/tools/wpa/) you can use.) 1. Save [this script](https://gist.github.com/RichardBronosky/fa7d4db13bab3fbb8d9e0fff7ea88aa2/raw/cloud-init-setup.sh) onto the microSD card. 1. Eject the card. Place it in your Raspberry Pi. Boot it up. 1. Locate your Raspberry Pi on your network. - Most modern routers will allow you to reach it via the hostname it declares, like so: `raspberrypi.local` - If that doesn't work in the next step, find the IP address via: - `sudo nmap -sP $(route -n get 8.8.8.8 | awk '$1=="gateway:"{print $2}')/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'` - That works for Mac and Linux. I have no idea how to do that in Windows. 1. SSH into the Raspberry Pi like so: - `ssh [email protected]` - The password is **`raspberry`**. 1. Run the script that we saved in Step 4 above. - `/boot/cloud-init-setup.sh` - You will be prompted for a password. Again, it is **`raspberry`**. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ #!/bin/bash -e # Get pip3 sudo apt-get update sudo apt-get install -y python3-pip # Get, build, and install cloud-init master branch from source curl -Lo cloud-init-master.zip https://github.com/cloud-init/cloud-init/archive/master.zip unzip cloud-init-master.zip cd cloud-init-master sudo pip3 install -r requirements.txt sudo python3 setup.py build sudo python3 setup.py install --init-system systemd sudo ln -s /usr/local/bin/cloud-init /usr/bin/cloud-init sudo cloud-init init sudo cloud-init status # Activate systemd services for svc in cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service; do sudo systemctl enable $svc sudo systemctl start $svc done # Configure cloud-init Datasource NoCloud # See: http://cloudinit.readthedocs.io/en/17.2/topics/datasources/nocloud.html?highlight=nocloud sudo sed -i '${s?$? ds=nocloud;seedfrom=/boot/;instance-id=iid-raspberrypi-nocloud?}' /boot/cmdline.txt # Create meta-data cat | sudo tee /boot/meta-data > /dev/null <<YAML instance-id: iid-raspberrypi-nocloud YAML # Create user-data cat | sudo tee /boot/user-data > /dev/null <<YAML #cloud-config password: passw0rd chpasswd: { expire: True } YAML # Create a script to run per boot cat | sudo tee /var/lib/cloud/scripts/per-boot/00_run-parts.sh > /dev/null <<BASH #!/bin/bash # Prevent *.sh from returning itself if there are no matches shopt -s nullglob # Run every per-once script run-parts --regex '.*\.sh$' /boot/per-once # Rename every per-once script for f in /boot/per-once/*.sh; do mv $f $(dirname $f)/$(basename $f .sh).$(date +%F@%H.%M.%S) done # Run every per-boot script run-parts --regex '.*\.sh$' /boot/per-boot BASH # Create sample per-boot and per-once scripts mkdir /boot/{per-boot,per-once} cat | sudo tee /boot/per-boot/01_get_ready.sh \ /boot/per-boot/02_do_it.sh \ /boot/per-once/01_prepare.sh \ /boot/per-once/02_install_stuff.sh > /dev/null <<BASH #!/bin/bash date="$(date +"%x %X")" script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" script_name="$(basename ${BASH_SOURCE[0]} .sh)" log_name="$(basename $script_path)" echo "$date - $script_name" >> /home/pi/${log_name}.out BASH File renamed without changes.File renamed without changes. - 
        
RichardBronosky revised this gist
Feb 20, 2018 . 2 changed files with 705 additions and 5534 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,98 +1,5 @@ Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 19:57:51 +0000. Up 23.20 seconds. Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 19:57:57 +0000. Up 29.09 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | @@ -106,407 +13,72 @@ Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: SHA256:TohkkH7IECRCPYRNx2LJfO8e0d8yKRV0Eb4e8qmN80g root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ |*+X+o. .. +o | |[email protected] .o | | +..* . . .. | | +o.. + . . . | | .. o S o.oo | | = . =+.o | | . o .Eo+ | | . ..= | | +oo | +----[SHA256]-----+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: SHA256:JKiHvsMG5CjCv/IIS8MyBma2/Bxmr6wlizdmGi/9uc0 root@raspberrypi The key's randomart image is: +---[DSA 1024]----+ | | | . | | . . . | | . o o | |*+o . S | |%+.. | |B%o= | |B*^oo+ | |+@*@*oE | +----[SHA256]-----+ Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. The key fingerprint is: SHA256:z73ZFXAjVKnV1eRpnemE2kOMAeQMK2BBj97KX7jX5Gw root@raspberrypi The key's randomart image is: +---[ECDSA 256]---+ | .=. ..o.. ..oB| | . + = = .+B| | . o . o . *oOo| | . . . +.B .| | . . S . o o | | . . . + . . .| | o . .= o . .| | . o. E + . | | o. . o . | +----[SHA256]-----+ Generating public/private ed25519 key pair. Your identification has been saved in /etc/ssh/ssh_host_ed25519_key. Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub. The key fingerprint is: SHA256:ElzHS9m4l59fvjkqry1cR5itsqb+YTIGkRlM131Gnpc root@raspberrypi The key's randomart image is: +--[ED25519 256]--+ | oo.oo+. .. | | . o=.=....oo| | o+ . o .*E.| | .. o oo o.| | ..S . .o. | | .. . oo..| | +.o+ .o.| | . +*o .+| | .o+o=+.oo| +----[SHA256]-----+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 19:58:27 +0000. Up 50.77 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 19:58:33 +0000. Up 56.67 seconds. ci-info: no authorized ssh keys fingerprints found for user ubuntu. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 19:58:33 +0000. Datasource DataSourceNone. Up 57.45 seconds 2018-02-20 19:58:34,007 - cc_final_message.py[WARNING]: Used fallback datasource  - 
        
RichardBronosky revised this gist
Feb 20, 2018 . 1 changed file with 17 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,10 +16,10 @@ sudo cloud-init init --local sudo cloud-init status # Activate systemd services sudo ln -s /usr/local/bin/cloud-init /usr/bin/cloud-init for svc in cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service; do sudo systemctl enable $svc sudo systemctl start $svc done # Check systemd services @@ -31,12 +31,12 @@ done cat | sudo tee /var/lib/cloud/scripts/per-boot/test.sh > /dev/null <<EOF #!/bin/bash date >> /home/pi/per-boot.out EOF # Configure cloud-init Datasource NoCloud # See: http://cloudinit.readthedocs.io/en/17.2/topics/datasources/nocloud.html?highlight=nocloud sudo sed -i '${s?$? ds=nocloud[;seedfrom=/boot/;instance-id=iid-raspberrypi-nocloud]?}' /boot/cmdline.txt # Create meta-data cat | sudo tee /boot/meta-data > /dev/null <<EOF @@ -45,10 +45,18 @@ EOF # Create user-data cat | sudo tee /boot/user-data > /dev/null <<EOF #!/bin/bash if [[ -f /boot/run_once.sh ]]; then /boot/run_once.sh mv /boot/run_once.sh /boot/run_once.$(date +%F@%H.%M.%S) fi if [[ -f /boot/on_boot.sh ]]; then /boot/on_boot.sh fi date >> /home/pi/user-data.out EOF  - 
        
RichardBronosky revised this gist
Feb 20, 2018 . 2 changed files with 5572 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,512 @@ Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 06:09:50 +0000. Up 937.51 seconds. Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 06:11:45 +0000. Up 1052.42 seconds. Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 06:11:48 +0000. Up 1055.56 seconds. ci-info: +++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++ ci-info: +--------+------+---------------+---------------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+------+---------------+---------------+-------+-------------------+ ci-info: | eth0: | True | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | True | 192.168.0.105 | 255.255.255.0 | . | b8:27:eb:00:e2:03 | ci-info: | wlan0: | True | . | . | d | b8:27:eb:00:e2:03 | ci-info: +--------+------+---------------+---------------+-------+-------------------+ ci-info: +++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++ ci-info: +-------+-------------+-------------+---------------+-----------+-------+ ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags | ci-info: +-------+-------------+-------------+---------------+-----------+-------+ ci-info: | 0 | 0.0.0.0 | 192.168.0.1 | 0.0.0.0 | wlan0 | UG | ci-info: | 1 | 192.168.0.0 | 0.0.0.0 | 255.255.255.0 | wlan0 | U | ci-info: +-------+-------------+-------------+---------------+-----------+-------+ Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: SHA256:j25ffoRXoKAHPL6x47SFjJ6gBhR7brYovMEfxx4VkYI root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ | . o. | | . E . .= . . | | o .o + . . . | | o . = . . .| |. o +S* . . | |o +o o Bo. . o | |.++o.* +.+. .o | |.o=.+ +.+ o . | |.o.. . .... .. | +----[SHA256]-----+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: SHA256:PVspaNFQmOoH3Si+3IQISdjyt6jLlpTWuvRbwyM/blI root@raspberrypi The key's randomart image is: +---[DSA 1024]----+ | o .+. | |o o oo | | + . o.o. | | + . + o+. . | | o+ = +S + o | | +..+E+.o = | |ooo..* = . | |++..+o= . | |o+.o=o. | +----[SHA256]-----+ Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. The key fingerprint is: SHA256:xpAcMUK7yJXpJRALQ13LBPqCB84MmVWDkf1qQuMx9X0 root@raspberrypi The key's randomart image is: +---[ECDSA 256]---+ |+.*XBo+. | | *++=B.+ | |=...*==. | |*o*+ +oo. E | |.B+=o. S. | | .+ o . | | o | | | | | +----[SHA256]-----+ Generating public/private ed25519 key pair. Your identification has been saved in /etc/ssh/ssh_host_ed25519_key. Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub. The key fingerprint is: SHA256:OYIOrdUZ6RU0AnA8ImiL8m9Ho+ooxHISa2dceJWV0SM root@raspberrypi The key's randomart image is: +--[ED25519 256]--+ |. .oo...*o+ | |o...o = E o | |o.....+ . . . | |+. o * + . | |o+o * = S | |++oO o. . | |+o+..o . | |.. + . | |o.oo . | +----[SHA256]-----+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 06:12:08 +0000. Up 1075.80 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 06:12:16 +0000. Up 1083.10 seconds. ci-info: no authorized ssh keys fingerprints found for user ubuntu. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 06:12:17 +0000. Datasource DataSourceNone. Up 1084.83 seconds 2018-02-20 06:12:17,988 - cc_final_message.py[WARNING]: Used fallback datasource Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 06:21:56 +0000. Up 22.96 seconds. Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 06:22:03 +0000. Up 29.92 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: SHA256:M0lmTQbhFfXAwaGTCXHbjlF8818Ft82CVgp49/PIScU root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ | ==B**ooo.| | ..B.O=*ooE| | =.O.=oo=+| | + . * +.o| | S . .o =o| | o + o| | | | | | | +----[SHA256]-----+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: SHA256:aalo4/BGfanfed+xIt6ojIDu+NjFZIaEM6pKkmz+hq4 root@raspberrypi The key's randomart image is: +---[DSA 1024]----+ | | | . | | + . | |. + . o | |. . = S. | |o. B..oo | |++oo++.o . | |*.=*o.o o. o+. .o| |E==Bo o.o=+.oo..| +----[SHA256]-----+ Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. The key fingerprint is: SHA256:Kdqb/iajNR02tlNsP5FHRqSojffaXiansC3ERSI0q9U root@raspberrypi The key's randomart image is: +---[ECDSA 256]---+ | .o .o | | .+...o | | o.Eo. o | | o * .+ | | o S.*.o . | | o = Boo o | | . + +.. = + | | .o+...* B | | .o+=. oo= | +----[SHA256]-----+ Generating public/private ed25519 key pair. Your identification has been saved in /etc/ssh/ssh_host_ed25519_key. Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub. The key fingerprint is: SHA256:Z4X7zkHcxRarkCbsK6nKCOoxOw+jAVuWsJRS7woUl44 root@raspberrypi The key's randomart image is: +--[ED25519 256]--+ | .... . | | .+o . .. .o| |o+o . o.+. .+| |+E + . o+...o | |+ + . S.+ o.. | |.= . .o.o | |+=. o . o | |+oO . . o . | |++o+.. o | +----[SHA256]-----+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 06:22:28 +0000. Up 48.95 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 06:22:34 +0000. Up 54.47 seconds. ci-info: no authorized ssh keys fingerprints found for user ubuntu. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 06:22:35 +0000. Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]. Up 55.30 seconds Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 06:27:36 +0000. Up 9.47 seconds. 2018-02-20 06:27:36,933 - util.py[WARNING]: failed stage init-local failed run of stage init-local ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 650, in status_wrapper ret = functor(name, args) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 324, in main_init init.fetch(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 349, in fetch return self._get_data_source(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 244, in _get_data_source ds, desc = self._restore_from_checked_cache(existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 230, in _restore_from_checked_cache ds.check_instance_id(self.cfg)): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 199, in check_instance_id quick_id = _quick_read_instance_id(dirs=dirs) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 227, in _quick_read_instance_id if iid_key in md: TypeError: argument of type 'NoneType' is not iterable ------------------------------------------------------------ Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 06:27:42 +0000. Up 15.60 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 06:27:54 +0000. Up 27.93 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 06:27:58 +0000. Up 31.00 seconds. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 06:27:58 +0000. Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]. Up 31.62 seconds Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 07:10:01 +0000. Up 9.44 seconds. Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 07:10:08 +0000. Up 16.00 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: SHA256:vhdpgpntc44eK31Tv5Nz87tcTThQPvHjqePVQv4k1Mc root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ | o | | o o | | . o..| | ..=o| | =S . =oE| | +.o + .+.o+| | ooo o ++o=| | . +== . O*o| | o=*.. ..OB| +----[SHA256]-----+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: SHA256:36fuiN4MldpSfw17ATF241iyVHFbks/KMAzejDznjdo root@raspberrypi The key's randomart image is: +---[DSA 1024]----+ | *oB+| | . o @.=| | o * + = | | =.B . o| | S ++ *.o | | * oo ++.| | + ooo + o| | *..E+ . | | .o +o+ | +----[SHA256]-----+ Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. The key fingerprint is: SHA256:0PapfaX33/v1/lx5BG4z1hsGuic7KxdUU5/dat8qnZs root@raspberrypi The key's randomart image is: +---[ECDSA 256]---+ | .. | | . o =| | . o ..o.+| | o . o...+ | | S +. Xoo| | o ..*.==| | . .o+o.+*| | . +=.o=*| | ooo.E+#| +----[SHA256]-----+ Generating public/private ed25519 key pair. Your identification has been saved in /etc/ssh/ssh_host_ed25519_key. Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub. The key fingerprint is: SHA256:DNd8ocy1Ajf3Z07tFdj0sgNMxZZ41ypR+nK7Bji7WYI root@raspberrypi The key's randomart image is: +--[ED25519 256]--+ | . o ==*+.| | B Bo*=.*| | . . B *+ooB| | + o.o.O.| | S ...= o| | .o .o o | | E .o... | | .+ .. | | o. .. | +----[SHA256]-----+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 07:10:26 +0000. Up 34.14 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 07:10:38 +0000. Up 39.80 seconds. ci-info: no authorized ssh keys fingerprints found for user ubuntu. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 07:10:39 +0000. Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]. Up 40.66 seconds Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 07:11:48 +0000. Up 9.37 seconds. 2018-02-20 07:11:48,848 - util.py[WARNING]: failed stage init-local failed run of stage init-local ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 650, in status_wrapper ret = functor(name, args) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 324, in main_init init.fetch(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 349, in fetch return self._get_data_source(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 244, in _get_data_source ds, desc = self._restore_from_checked_cache(existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 230, in _restore_from_checked_cache ds.check_instance_id(self.cfg)): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 199, in check_instance_id quick_id = _quick_read_instance_id(dirs=dirs) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 227, in _quick_read_instance_id if iid_key in md: TypeError: argument of type 'NoneType' is not iterable ------------------------------------------------------------ Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 07:11:53 +0000. Up 14.96 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 07:12:07 +0000. Up 28.03 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 07:12:10 +0000. Up 31.09 seconds. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 07:12:10 +0000. Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]. Up 31.71 seconds Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 07:20:27 +0000. Up 9.41 seconds. 2018-02-20 07:20:27,870 - util.py[WARNING]: failed stage init-local failed run of stage init-local ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 650, in status_wrapper ret = functor(name, args) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 324, in main_init init.fetch(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 349, in fetch return self._get_data_source(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 244, in _get_data_source ds, desc = self._restore_from_checked_cache(existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 230, in _restore_from_checked_cache ds.check_instance_id(self.cfg)): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 199, in check_instance_id quick_id = _quick_read_instance_id(dirs=dirs) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 227, in _quick_read_instance_id if iid_key in md: TypeError: argument of type 'NoneType' is not iterable ------------------------------------------------------------ Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 07:20:33 +0000. Up 15.02 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 07:20:46 +0000. Up 28.61 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 07:20:53 +0000. Up 35.13 seconds. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 07:21:00 +0000. Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]. Up 35.74 seconds Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 07:28:48 +0000. Up 23.14 seconds. 2018-02-20 07:28:48,549 - util.py[WARNING]: failed stage init-local failed run of stage init-local ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 650, in status_wrapper ret = functor(name, args) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 324, in main_init init.fetch(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 349, in fetch return self._get_data_source(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 244, in _get_data_source ds, desc = self._restore_from_checked_cache(existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 230, in _restore_from_checked_cache ds.check_instance_id(self.cfg)): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 199, in check_instance_id quick_id = _quick_read_instance_id(dirs=dirs) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 227, in _quick_read_instance_id if iid_key in md: TypeError: argument of type 'NoneType' is not iterable ------------------------------------------------------------ Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 07:28:53 +0000. Up 28.69 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 07:29:06 +0000. Up 41.42 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 07:29:09 +0000. Up 44.46 seconds. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 07:29:10 +0000. Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]. Up 45.07 seconds Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 07:31:02 +0000. Up 9.28 seconds. Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 07:31:08 +0000. Up 15.88 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: SHA256:O8XIxXN9o18AQPyZP0GJTXpjeXdBz9QUjRuqMdauI1o root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ | oo..+oB*| | .. .+*+=| | +oo=B+B| | . ++o*o+=+| | S.o= o ..| | o. . + .| | E . o | | ...o | | .. . . | +----[SHA256]-----+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: SHA256:mWWVD7xVSgvGkXdJcW+yflTx2BRleVatAZRCTO3iLdE root@raspberrypi The key's randomart image is: +---[DSA 1024]----+ | +o=B*o*/| | ooOo+XX| | o+ *==B| | =o E o+.| | S. + . .| | o .. . | | . . .| | . | | | +----[SHA256]-----+ Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. The key fingerprint is: SHA256:rtDBLPT5H7hFxJXcHK2vD3vMKdGfgzBAuHhDsR1bnCo root@raspberrypi The key's randomart image is: +---[ECDSA 256]---+ | .o..oo+.o | | ooo++o o .| | . o.oo+ . | | . = E + . | | . B S o .. | | o + o o . ..| | . . + o o +++| | . . + . o.*=| | . . . ooo| +----[SHA256]-----+ Generating public/private ed25519 key pair. Your identification has been saved in /etc/ssh/ssh_host_ed25519_key. Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub. The key fingerprint is: SHA256:tRgugqFN4oDdPhfL6nTe8GcEZEPybT1LKCmURAdTEwU root@raspberrypi The key's randomart image is: +--[ED25519 256]--+ | oB=E+. | |.. . ..=++ o | |+ + . oo=.= + | |o= + . =.* o o | |..o + = S.. . | | = . . | | o o . | | o o + o | | . . oo | +----[SHA256]-----+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 07:31:31 +0000. Up 38.56 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 07:31:37 +0000. Up 44.10 seconds. ci-info: no authorized ssh keys fingerprints found for user ubuntu. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 07:31:37 +0000. Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]. Up 44.95 seconds Cloud-init v. 17.2 running 'init-local' at Tue, 20 Feb 2018 07:33:17 +0000. Up 9.27 seconds. 2018-02-20 07:33:17,845 - util.py[WARNING]: failed stage init-local failed run of stage init-local ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 650, in status_wrapper ret = functor(name, args) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/cmd/main.py", line 324, in main_init init.fetch(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 349, in fetch return self._get_data_source(existing=existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 244, in _get_data_source ds, desc = self._restore_from_checked_cache(existing) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/stages.py", line 230, in _restore_from_checked_cache ds.check_instance_id(self.cfg)): File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 199, in check_instance_id quick_id = _quick_read_instance_id(dirs=dirs) File "/usr/local/lib/python3.5/dist-packages/cloud_init-17.2-py3.5.egg/cloudinit/sources/DataSourceNoCloud.py", line 227, in _quick_read_instance_id if iid_key in md: TypeError: argument of type 'NoneType' is not iterable ------------------------------------------------------------ Cloud-init v. 17.2 running 'init' at Tue, 20 Feb 2018 07:33:22 +0000. Up 14.82 seconds. ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++ ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ ci-info: | eth0: | False | . | . | . | b8:27:eb:55:b7:56 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | wlan0: | False | . | . | . | b8:27:eb:00:e2:03 | ci-info: +--------+-------+-----------+-----------+-------+-------------------+ Cloud-init v. 17.2 running 'modules:config' at Tue, 20 Feb 2018 07:33:36 +0000. Up 28.59 seconds. Cloud-init v. 17.2 running 'modules:final' at Tue, 20 Feb 2018 07:33:39 +0000. Up 31.66 seconds. Cloud-init v. 17.2 finished at Tue, 20 Feb 2018 07:33:40 +0000. Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]. Up 32.27 seconds  - 
        
RichardBronosky revised this gist
Feb 19, 2018 . 1 changed file with 33 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ Installing cloud-init on a fresh Raspbian Lite image ## Work in Progress! ```bash sudo apt-get update sudo apt-get install -y vim tmux git python3-pip @@ -15,9 +15,41 @@ sudo python3 setup.py install --init-system systemd sudo cloud-init init --local sudo cloud-init status # Activate systemd services ln -s /usr/local/bin/cloud-init /usr/bin/cloud-init for svc in cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service; do systemctl enable $svc systemctl start $svc done # Check systemd services for svc in cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service; do systemctl status $svc done # Create a test script to run per boot cat | sudo tee /var/lib/cloud/scripts/per-boot/test.sh > /dev/null <<EOF #!/bin/bash date | tee -a /home/pi/ci-test.txt EOF # Configure cloud-init Datasource NoCloud # See: http://cloudinit.readthedocs.io/en/17.2/topics/datasources/nocloud.html?highlight=nocloud sudo sed -i '${s?$? ds=nocloud[;seedfrom=/boot/;instance-id=raspberrypi]?}' /boot/cmdline.txt # Create meta-data cat | sudo tee /boot/meta-data > /dev/null <<EOF instance-id: iid-raspberrypi-nocloud EOF # Create user-data cat | sudo tee /boot/user-data > /dev/null <<EOF #cloud-config password: passw0rd chpasswd: { expire: False } ssh_pwauth: True EOF ```  - 
        
RichardBronosky created this gist
Feb 19, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ Installing cloud-init on a fresh Raspbian Lite image ==================================================== ## Work in Progress! ``` sudo apt-get update sudo apt-get install -y vim tmux git python3-pip git clone https://github.com/cloud-init/cloud-init.git cd cloud-init sudo pip3 install -r requirements.txt sudo python3 setup.py build sudo python3 setup.py install --init-system systemd sudo cloud-init init --local sudo cloud-init status cat | sudo tee /var/lib/cloud/scripts/per-boot/test.sh > /dev/null <<EOF #!/bin/bash date | tee -a /home/pi/ci-test.txt EOF ```