├── .gitignore ├── README.md ├── nomad-client ├── cloud-data │ ├── meta-data │ └── user-data ├── consul.hcl ├── consul.service ├── nomad.hcl ├── nomad.service └── template.json ├── nomad-server ├── cloud-data │ ├── meta-data │ └── user-data ├── consul.hcl ├── consul.service ├── nomad.hcl ├── nomad.service └── template.json ├── notes.txt └── wip ├── ansible-take1 ├── ansible.json ├── cloud-data │ ├── meta-data │ └── user-data ├── playbook.retry └── playbook.yml ├── base ├── cloud-data │ ├── meta-data │ └── user-data └── template.json └── nomad-dev ├── cloud-data ├── meta-data └── user-data ├── consul.service ├── nomad.service ├── server.hcl └── template.json /.gitignore: -------------------------------------------------------------------------------- 1 | output-qemu 2 | packer_cache 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Custom Multipass Images For a Local Nomad Cluster 2 | My custom [multipass](https://multipass.run/) images for local development and testing use. If you don't want to use the binaries, or you need to customize more, you can build the images yourself using [packer](https://packer.io/). 3 | 4 | Example: 5 | ``` 6 | cd nomad-client 7 | packer build template.json 8 | multipass launch file://$PWD/output-qemu/packer-qemu 9 | ``` 10 | A more detailed procedure can be found [in this post](https://discourse.ubuntu.com/t/building-multipass-images-with-packer/12361) 11 | 12 | 13 | ## Nomad 14 | These two images can be used to create a local nomad cluster. They also include consul. Currently only supports one server and multiple clients. 15 | 16 | Steps to run: 17 | 18 | ``` 19 | multipass launch https://img.taypo.com/nomad-server.img --name NomadServer 20 | ``` 21 | 22 | Get the IP address of the server from `multipass info NomadServer`. Create the following file, and replace the IP with the IP of the server you just created. 23 | 24 | cloudinit.yml: 25 | ```yaml 26 | write_files: 27 | - content: | 28 | retry_join = ["put your nomad server ip between these quotes"] 29 | path: /etc/consul.d/join.hcl 30 | ``` 31 | 32 | Now you can launch as many clients as you want: 33 | ``` 34 | multipass launch https://img.taypo.com/nomad-client.img --name NomadClient1 --cloud-init cloudinit.yml 35 | multipass launch https://img.taypo.com/nomad-client.img --name NomadClient2 --cloud-init cloudinit.yml 36 | multipass launch https://img.taypo.com/nomad-client.img --name NomadClient3 --cloud-init cloudinit.yml 37 | 38 | ``` 39 | Consul UI will be running on port 8500 of the server. And Nomad UI on 4646. 40 | 41 | 42 | -------------------------------------------------------------------------------- /nomad-client/cloud-data/meta-data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taypo/multipass-images/64f1a896b01823ec5012b88fe88114de8cc247d6/nomad-client/cloud-data/meta-data -------------------------------------------------------------------------------- /nomad-client/cloud-data/user-data: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | ssh_pwauth: true 3 | users: 4 | - name: packer 5 | sudo: ALL=(ALL) NOPASSWD:ALL 6 | groups: users, admin 7 | passwd: $6$rounds=4096$XxQGokSw4FI8unZF$lAnQ0ZSMuCvSlv.rFjcxOpyAZr/ZDwtaI/X6BSSH0wtKngvprmgr9nvSMV/dBzE.TJ7Tvd8y0.T50dW5Bi1vf/ 8 | lock_passwd: false 9 | apt: 10 | preserve_sources_list: true 11 | package_update: false 12 | -------------------------------------------------------------------------------- /nomad-client/consul.hcl: -------------------------------------------------------------------------------- 1 | bind_addr = "{{ GetPrivateInterfaces | exclude \"name\" \"docker0\" | attr \"address\" }}" 2 | client_addr = "0.0.0.0" 3 | 4 | # TODO make this external somehow 5 | # retry_join = ["10.215.117.4"] 6 | 7 | data_dir = "/data/consul" 8 | 9 | log_file = "/var/log/consul.log" 10 | -------------------------------------------------------------------------------- /nomad-client/consul.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=consul agent 3 | Requires=network-online.target 4 | After=network-online.target 5 | 6 | [Service] 7 | Restart=on-failure 8 | ExecStart=/usr/bin/consul agent -config-dir=/etc/consul.d 9 | ExecReload=/bin/kill -HUP $MAINPID 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /nomad-client/nomad.hcl: -------------------------------------------------------------------------------- 1 | data_dir = "/data/nomad" 2 | 3 | log_file = "/var/log/nomad.log" 4 | 5 | client { 6 | enabled = true 7 | } 8 | 9 | telemetry { 10 | publish_allocation_metrics = true 11 | publish_node_metrics = true 12 | prometheus_metrics = true 13 | disable_hostname = true 14 | } 15 | -------------------------------------------------------------------------------- /nomad-client/nomad.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Nomad 3 | Documentation=https://nomadproject.io/docs/ 4 | Wants=network-online.target 5 | After=network-online.target 6 | 7 | # When using Nomad with Consul it is not necessary to start Consul first. These 8 | # lines start Consul before Nomad as an optimization to avoid Nomad logging 9 | # that Consul is unavailable at startup. 10 | Wants=consul.service 11 | After=consul.service 12 | 13 | [Service] 14 | ExecReload=/bin/kill -HUP $MAINPID 15 | ExecStart=/usr/bin/nomad agent -config /etc/nomad.d 16 | KillMode=process 17 | KillSignal=SIGINT 18 | LimitNOFILE=65536 19 | LimitNPROC=infinity 20 | Restart=on-failure 21 | RestartSec=2 22 | StartLimitBurst=3 23 | StartLimitIntervalSec=10 24 | TasksMax=infinity 25 | OOMScoreAdjust=-1000 26 | 27 | [Install] 28 | WantedBy=multi-user.target 29 | -------------------------------------------------------------------------------- /nomad-client/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "type": "qemu", 5 | "iso_url": "http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img", 6 | "iso_checksum_url": "http://cloud-images.ubuntu.com/releases/bionic/release/SHA256SUMS", 7 | "iso_checksum_type": "sha256", 8 | "disk_image": true, 9 | "disk_size": 5120, 10 | "disk_interface": "virtio-scsi", 11 | "disk_discard": "unmap", 12 | "ssh_username": "packer", 13 | "ssh_password": "packerpassword", 14 | "http_directory": "cloud-data", 15 | "disk_compression": true, 16 | "qemuargs": [ 17 | ["-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"] 18 | ], 19 | "use_default_display": true 20 | } 21 | ], 22 | "provisioners": [ 23 | { 24 | "type": "file", 25 | "source": "nomad.hcl", 26 | "destination": "/tmp/nomad.hcl" 27 | }, 28 | { 29 | "type": "file", 30 | "source": "consul.hcl", 31 | "destination": "/tmp/consul.hcl" 32 | }, 33 | { 34 | "type": "file", 35 | "source": "nomad.service", 36 | "destination": "/tmp/nomad.service" 37 | }, 38 | { 39 | "type": "file", 40 | "source": "consul.service", 41 | "destination": "/tmp/consul.service" 42 | }, 43 | { 44 | "type": "shell", 45 | "inline": ["sudo apt-get update", 46 | "sudo apt-get remove docker docker-engine docker.io", 47 | "echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections", 48 | "sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y", 49 | "sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -", 50 | "sudo apt-key fingerprint 0EBFCD88", 51 | "sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"", 52 | "sudo apt-get update", 53 | "sudo apt-get install -y docker-ce", 54 | "sudo service docker restart", 55 | "sudo apt-get install unzip curl vim -y", 56 | "sudo mkdir -p /data/nomad", 57 | "sudo mkdir -p /data/consul", 58 | "export NOMAD_VERSION=0.10.4", 59 | "cd /tmp/", 60 | "curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip", 61 | "unzip nomad.zip", 62 | "sudo install nomad /usr/bin/nomad", 63 | "sudo mkdir -p /etc/nomad.d", 64 | "sudo cp /tmp/nomad.hcl /etc/nomad.d/nomad.hcl", 65 | "sudo cp /tmp/nomad.service /etc/systemd/system/", 66 | "sudo systemctl enable nomad.service", 67 | 68 | "export CONSUL_VERSION=1.6.4", 69 | "curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip > consul.zip", 70 | "unzip /tmp/consul.zip", 71 | "sudo install consul /usr/bin/consul", 72 | "sudo mkdir -p /etc/consul.d", 73 | "sudo cp /tmp/consul.hcl /etc/consul.d/consul.hcl", 74 | "sudo cp /tmp/consul.service /etc/systemd/system/", 75 | "sudo systemctl enable consul.service" 76 | 77 | ] 78 | }, 79 | 80 | { 81 | "type": "shell", 82 | "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'", 83 | "remote_folder": "/tmp", 84 | "inline": [ 85 | "/usr/bin/apt-get clean", 86 | "rm -r /etc/apparmor.d/cache/* /etc/apparmor.d/cache/.features /etc/netplan/50-cloud-init.yaml /etc/ssh/ssh_host* /etc/sudoers.d/90-cloud-init-users", 87 | "/usr/bin/truncate --size 0 /etc/machine-id", 88 | "/usr/bin/gawk -i inplace '/PasswordAuthentication/ { gsub(/yes/, \"no\") }; { print }' /etc/ssh/sshd_config", 89 | "rm -r /root/.ssh", 90 | "rm /snap/README", 91 | "find /usr/share/netplan -name __pycache__ -exec rm -r {} +", 92 | "rm /var/cache/pollinate/seeded /var/cache/snapd/* /var/cache/motd-news", 93 | "rm -r /var/lib/cloud /var/lib/dbus/machine-id /var/lib/private /var/lib/systemd/timers /var/lib/systemd/timesync /var/lib/systemd/random-seed", 94 | "rm /var/lib/ubuntu-release-upgrader/release-upgrade-available", 95 | "rm /var/lib/update-notifier/fsck-at-reboot /var/lib/update-notifier/hwe-eol", 96 | "find /var/log -type f -exec rm {} +", 97 | "rm -r /tmp/* /tmp/.*-unix /var/tmp/*", 98 | "rm -r /home/packer", 99 | "/bin/sync", 100 | "/sbin/fstrim -v /" 101 | ] 102 | } 103 | ] 104 | } 105 | 106 | -------------------------------------------------------------------------------- /nomad-server/cloud-data/meta-data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taypo/multipass-images/64f1a896b01823ec5012b88fe88114de8cc247d6/nomad-server/cloud-data/meta-data -------------------------------------------------------------------------------- /nomad-server/cloud-data/user-data: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | ssh_pwauth: true 3 | users: 4 | - name: packer 5 | sudo: ALL=(ALL) NOPASSWD:ALL 6 | groups: users, admin 7 | passwd: $6$rounds=4096$XxQGokSw4FI8unZF$lAnQ0ZSMuCvSlv.rFjcxOpyAZr/ZDwtaI/X6BSSH0wtKngvprmgr9nvSMV/dBzE.TJ7Tvd8y0.T50dW5Bi1vf/ 8 | lock_passwd: false 9 | apt: 10 | preserve_sources_list: true 11 | package_update: false 12 | -------------------------------------------------------------------------------- /nomad-server/consul.hcl: -------------------------------------------------------------------------------- 1 | bind_addr = "{{ GetPrivateInterfaces | exclude \"name\" \"docker0\" | attr \"address\" }}" 2 | client_addr = "0.0.0.0" 3 | 4 | server = true 5 | bootstrap_expect = 1 6 | ui = true 7 | 8 | data_dir = "/data/consul" 9 | 10 | log_file = "/var/log/consul.log" 11 | -------------------------------------------------------------------------------- /nomad-server/consul.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=consul agent 3 | Requires=network-online.target 4 | After=network-online.target 5 | 6 | [Service] 7 | Restart=on-failure 8 | ExecStart=/usr/bin/consul agent -config-dir=/etc/consul.d 9 | ExecReload=/bin/kill -HUP $MAINPID 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /nomad-server/nomad.hcl: -------------------------------------------------------------------------------- 1 | bind_addr = "0.0.0.0" 2 | data_dir = "/data/nomad" 3 | log_file = "/var/log/nomad" 4 | 5 | server { 6 | enabled = true 7 | bootstrap_expect = 1 8 | } 9 | 10 | telemetry { 11 | publish_allocation_metrics = true 12 | publish_node_metrics = true 13 | prometheus_metrics = true 14 | disable_hostname = true 15 | } 16 | -------------------------------------------------------------------------------- /nomad-server/nomad.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Nomad 3 | Documentation=https://nomadproject.io/docs/ 4 | Wants=network-online.target 5 | After=network-online.target 6 | 7 | # When using Nomad with Consul it is not necessary to start Consul first. These 8 | # lines start Consul before Nomad as an optimization to avoid Nomad logging 9 | # that Consul is unavailable at startup. 10 | Wants=consul.service 11 | After=consul.service 12 | 13 | [Service] 14 | ExecReload=/bin/kill -HUP $MAINPID 15 | ExecStart=/usr/bin/nomad agent -config /etc/nomad.d 16 | KillMode=process 17 | KillSignal=SIGINT 18 | LimitNOFILE=65536 19 | LimitNPROC=infinity 20 | Restart=on-failure 21 | RestartSec=2 22 | StartLimitBurst=3 23 | StartLimitIntervalSec=10 24 | TasksMax=infinity 25 | OOMScoreAdjust=-1000 26 | 27 | [Install] 28 | WantedBy=multi-user.target 29 | -------------------------------------------------------------------------------- /nomad-server/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "type": "qemu", 5 | "iso_url": "http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img", 6 | "iso_checksum_url": "http://cloud-images.ubuntu.com/releases/bionic/release/SHA256SUMS", 7 | "iso_checksum_type": "sha256", 8 | "disk_image": true, 9 | "disk_size": 5120, 10 | "disk_interface": "virtio-scsi", 11 | "disk_discard": "unmap", 12 | "ssh_username": "packer", 13 | "ssh_password": "packerpassword", 14 | "http_directory": "cloud-data", 15 | "disk_compression": true, 16 | "qemuargs": [ 17 | ["-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"] 18 | ], 19 | "use_default_display": true 20 | } 21 | ], 22 | "provisioners": [ 23 | { 24 | "type": "file", 25 | "source": "nomad.hcl", 26 | "destination": "/tmp/nomad.hcl" 27 | }, 28 | { 29 | "type": "file", 30 | "source": "consul.hcl", 31 | "destination": "/tmp/consul.hcl" 32 | }, 33 | { 34 | "type": "file", 35 | "source": "nomad.service", 36 | "destination": "/tmp/nomad.service" 37 | }, 38 | { 39 | "type": "file", 40 | "source": "consul.service", 41 | "destination": "/tmp/consul.service" 42 | }, 43 | { 44 | "type": "shell", 45 | "inline": ["sudo apt-get update", 46 | "sudo apt-get install unzip curl vim -y", 47 | "sudo mkdir -p /data/nomad", 48 | "sudo mkdir -p /data/consul", 49 | "export NOMAD_VERSION=0.10.4", 50 | "cd /tmp/", 51 | "curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip", 52 | "unzip nomad.zip", 53 | "sudo install nomad /usr/bin/nomad", 54 | "sudo mkdir -p /etc/nomad.d", 55 | "sudo cp /tmp/nomad.hcl /etc/nomad.d/nomad.hcl", 56 | "sudo cp /tmp/nomad.service /etc/systemd/system/", 57 | "sudo systemctl enable nomad.service", 58 | 59 | "export CONSUL_VERSION=1.6.4", 60 | "curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip > consul.zip", 61 | "unzip /tmp/consul.zip", 62 | "sudo install consul /usr/bin/consul", 63 | "sudo mkdir -p /etc/consul.d", 64 | "sudo cp /tmp/consul.hcl /etc/consul.d/consul.hcl", 65 | "sudo cp /tmp/consul.service /etc/systemd/system/", 66 | "sudo systemctl enable consul.service" 67 | 68 | ] 69 | }, 70 | 71 | { 72 | "type": "shell", 73 | "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'", 74 | "remote_folder": "/tmp", 75 | "inline": [ 76 | "/usr/bin/apt-get clean", 77 | "rm -r /etc/apparmor.d/cache/* /etc/apparmor.d/cache/.features /etc/netplan/50-cloud-init.yaml /etc/ssh/ssh_host* /etc/sudoers.d/90-cloud-init-users", 78 | "/usr/bin/truncate --size 0 /etc/machine-id", 79 | "/usr/bin/gawk -i inplace '/PasswordAuthentication/ { gsub(/yes/, \"no\") }; { print }' /etc/ssh/sshd_config", 80 | "rm -r /root/.ssh", 81 | "rm /snap/README", 82 | "find /usr/share/netplan -name __pycache__ -exec rm -r {} +", 83 | "rm /var/cache/pollinate/seeded /var/cache/snapd/* /var/cache/motd-news", 84 | "rm -r /var/lib/cloud /var/lib/dbus/machine-id /var/lib/private /var/lib/systemd/timers /var/lib/systemd/timesync /var/lib/systemd/random-seed", 85 | "rm /var/lib/ubuntu-release-upgrader/release-upgrade-available", 86 | "rm /var/lib/update-notifier/fsck-at-reboot /var/lib/update-notifier/hwe-eol", 87 | "find /var/log -type f -exec rm {} +", 88 | "rm -r /tmp/* /tmp/.*-unix /var/tmp/*", 89 | "rm -r /home/packer", 90 | "/bin/sync", 91 | "/sbin/fstrim -v /" 92 | ] 93 | } 94 | ] 95 | } 96 | 97 | -------------------------------------------------------------------------------- /notes.txt: -------------------------------------------------------------------------------- 1 | 2 | TODO: 3 | 4 | "for i in group gshadow passwd shadow subuid subgid; do mv /etc/$i- /etc/$i; done", 5 | replace with the recommendation from https://discourse.ubuntu.com/t/building-multipass-images-with-packer/12361/8 6 | 7 | update systemd files from the official documentation: 8 | https://nomadproject.io/docs/install/production/deployment-guide/ 9 | https://learn.hashicorp.com/consul/datacenter-deploy/deployment-guide 10 | 11 | -------------------------------------------------------------------------------- /wip/ansible-take1/ansible.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "type": "qemu", 5 | "iso_url": "http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img", 6 | "iso_checksum_url": "http://cloud-images.ubuntu.com/releases/bionic/release/SHA256SUMS", 7 | "iso_checksum_type": "sha256", 8 | "disk_image": true, 9 | "disk_size": 5120, 10 | "disk_interface": "virtio-scsi", 11 | "disk_discard": "unmap", 12 | "ssh_username": "packer", 13 | "ssh_password": "packerpassword", 14 | "disk_compression": true, 15 | "http_directory": "cloud-data", 16 | "qemuargs": [ 17 | ["-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"] 18 | ], 19 | "use_default_display": true 20 | } 21 | ], 22 | "provisioners": [ 23 | { 24 | "type": "ansible", 25 | "extra_arguments": ["-e ansible_python_interpreter=/usr/bin/python3"], 26 | "playbook_file": "./playbook.yml" 27 | }, 28 | 29 | { 30 | "type": "shell", 31 | "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'", 32 | "remote_folder": "/tmp", 33 | "inline": [ 34 | "/usr/bin/apt-get clean", 35 | "rm -r /etc/apparmor.d/cache/* /etc/apparmor.d/cache/.features /etc/netplan/50-cloud-init.yaml /etc/ssh/ssh_host* /etc/sudoers.d/90-cloud-init-users", 36 | "/usr/bin/truncate --size 0 /etc/machine-id", 37 | "/usr/bin/gawk -i inplace '/PasswordAuthentication/ { gsub(/yes/, \"no\") }; { print }' /etc/ssh/sshd_config", 38 | "rm -r /root/.ssh", 39 | "rm /snap/README", 40 | "find /usr/share/netplan -name __pycache__ -exec rm -r {} +", 41 | "rm /var/cache/pollinate/seeded /var/cache/snapd/* /var/cache/motd-news", 42 | "rm -r /var/lib/cloud /var/lib/dbus/machine-id /var/lib/private /var/lib/systemd/timers /var/lib/systemd/timesync /var/lib/systemd/random-seed", 43 | "rm /var/lib/ubuntu-release-upgrader/release-upgrade-available", 44 | "rm /var/lib/update-notifier/fsck-at-reboot /var/lib/update-notifier/hwe-eol", 45 | "find /var/log -type f -exec rm {} +", 46 | "rm -r /tmp/* /tmp/.*-unix /var/tmp/*", 47 | "rm -r /home/packer", 48 | "/bin/sync", 49 | "/sbin/fstrim -v /" 50 | ] 51 | } 52 | ] 53 | } 54 | 55 | -------------------------------------------------------------------------------- /wip/ansible-take1/cloud-data/meta-data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taypo/multipass-images/64f1a896b01823ec5012b88fe88114de8cc247d6/wip/ansible-take1/cloud-data/meta-data -------------------------------------------------------------------------------- /wip/ansible-take1/cloud-data/user-data: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | ssh_pwauth: true 3 | users: 4 | - name: packer 5 | sudo: ALL=(ALL) NOPASSWD:ALL 6 | groups: users, admin 7 | passwd: $6$rounds=4096$XxQGokSw4FI8unZF$lAnQ0ZSMuCvSlv.rFjcxOpyAZr/ZDwtaI/X6BSSH0wtKngvprmgr9nvSMV/dBzE.TJ7Tvd8y0.T50dW5Bi1vf/ 8 | lock_passwd: false 9 | apt: 10 | preserve_sources_list: true 11 | package_update: false 12 | -------------------------------------------------------------------------------- /wip/ansible-take1/playbook.retry: -------------------------------------------------------------------------------- 1 | default 2 | -------------------------------------------------------------------------------- /wip/ansible-take1/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # playbook.yml 3 | - name: "Provision Image" 4 | hosts: default 5 | become: true 6 | 7 | tasks: 8 | - name: install Apache 9 | package: 10 | name: "nginx" 11 | state: present 12 | -------------------------------------------------------------------------------- /wip/base/cloud-data/meta-data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taypo/multipass-images/64f1a896b01823ec5012b88fe88114de8cc247d6/wip/base/cloud-data/meta-data -------------------------------------------------------------------------------- /wip/base/cloud-data/user-data: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | ssh_pwauth: true 3 | users: 4 | - name: packer 5 | sudo: ALL=(ALL) NOPASSWD:ALL 6 | groups: users, admin 7 | passwd: $6$rounds=4096$XxQGokSw4FI8unZF$lAnQ0ZSMuCvSlv.rFjcxOpyAZr/ZDwtaI/X6BSSH0wtKngvprmgr9nvSMV/dBzE.TJ7Tvd8y0.T50dW5Bi1vf/ 8 | lock_passwd: false 9 | apt: 10 | preserve_sources_list: true 11 | package_update: false 12 | -------------------------------------------------------------------------------- /wip/base/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "type": "qemu", 5 | "iso_url": "http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img", 6 | "iso_checksum_url": "http://cloud-images.ubuntu.com/releases/bionic/release/SHA256SUMS", 7 | "iso_checksum_type": "sha256", 8 | "disk_image": true, 9 | "disk_size": 5120, 10 | "disk_interface": "virtio-scsi", 11 | "disk_discard": "unmap", 12 | "ssh_username": "packer", 13 | "ssh_password": "packerpassword", 14 | "http_directory": "cloud-data", 15 | "qemuargs": [ 16 | ["-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"] 17 | ], 18 | "use_default_display": true 19 | } 20 | ], 21 | "provisioners": [ 22 | { 23 | "type": "shell", 24 | "inline": ["echo Your steps go here."] 25 | }, 26 | 27 | { 28 | "type": "shell", 29 | "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'", 30 | "remote_folder": "/tmp", 31 | "inline": [ 32 | "/usr/bin/apt-get clean", 33 | "rm -r /etc/apparmor.d/cache/* /etc/apparmor.d/cache/.features /etc/netplan/50-cloud-init.yaml /etc/ssh/ssh_host* /etc/sudoers.d/90-cloud-init-users", 34 | "/usr/bin/truncate --size 0 /etc/machine-id", 35 | "/usr/bin/gawk -i inplace '/PasswordAuthentication/ { gsub(/yes/, \"no\") }; { print }' /etc/ssh/sshd_config", 36 | "rm -r /root/.ssh", 37 | "rm /snap/README", 38 | "find /usr/share/netplan -name __pycache__ -exec rm -r {} +", 39 | "rm /var/cache/pollinate/seeded /var/cache/snapd/* /var/cache/motd-news", 40 | "rm -r /var/lib/cloud /var/lib/dbus/machine-id /var/lib/private /var/lib/systemd/timers /var/lib/systemd/timesync /var/lib/systemd/random-seed", 41 | "rm /var/lib/ubuntu-release-upgrader/release-upgrade-available", 42 | "rm /var/lib/update-notifier/fsck-at-reboot /var/lib/update-notifier/hwe-eol", 43 | "find /var/log -type f -exec rm {} +", 44 | "rm -r /tmp/* /tmp/.*-unix /var/tmp/*", 45 | "rm -r /home/packer", 46 | "/bin/sync", 47 | "/sbin/fstrim -v /" 48 | ] 49 | } 50 | ] 51 | } 52 | 53 | -------------------------------------------------------------------------------- /wip/nomad-dev/cloud-data/meta-data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taypo/multipass-images/64f1a896b01823ec5012b88fe88114de8cc247d6/wip/nomad-dev/cloud-data/meta-data -------------------------------------------------------------------------------- /wip/nomad-dev/cloud-data/user-data: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | ssh_pwauth: true 3 | users: 4 | - name: packer 5 | sudo: ALL=(ALL) NOPASSWD:ALL 6 | groups: users, admin 7 | passwd: $6$rounds=4096$XxQGokSw4FI8unZF$lAnQ0ZSMuCvSlv.rFjcxOpyAZr/ZDwtaI/X6BSSH0wtKngvprmgr9nvSMV/dBzE.TJ7Tvd8y0.T50dW5Bi1vf/ 8 | lock_passwd: false 9 | apt: 10 | preserve_sources_list: true 11 | package_update: false 12 | -------------------------------------------------------------------------------- /wip/nomad-dev/consul.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=consul agent 3 | Requires=network-online.target 4 | After=network-online.target 5 | 6 | [Service] 7 | Restart=on-failure 8 | ExecStart=/usr/bin/consul agent -dev 9 | ExecReload=/bin/kill -HUP $MAINPID 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /wip/nomad-dev/nomad.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Nomad 3 | Documentation=https://nomadproject.io/docs/ 4 | Wants=network-online.target 5 | After=network-online.target 6 | 7 | # When using Nomad with Consul it is not necessary to start Consul first. These 8 | # lines start Consul before Nomad as an optimization to avoid Nomad logging 9 | # that Consul is unavailable at startup. 10 | Wants=consul.service 11 | After=consul.service 12 | 13 | [Service] 14 | ExecReload=/bin/kill -HUP $MAINPID 15 | ExecStart=/usr/bin/nomad agent -dev -config /etc/nomad.d 16 | KillMode=process 17 | KillSignal=SIGINT 18 | LimitNOFILE=65536 19 | LimitNPROC=infinity 20 | Restart=on-failure 21 | RestartSec=2 22 | StartLimitBurst=3 23 | StartLimitIntervalSec=10 24 | TasksMax=infinity 25 | OOMScoreAdjust=-1000 26 | 27 | [Install] 28 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /wip/nomad-dev/server.hcl: -------------------------------------------------------------------------------- 1 | bind_addr = "0.0.0.0" 2 | 3 | -------------------------------------------------------------------------------- /wip/nomad-dev/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "type": "qemu", 5 | "iso_url": "http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img", 6 | "iso_checksum_url": "http://cloud-images.ubuntu.com/releases/bionic/release/SHA256SUMS", 7 | "iso_checksum_type": "sha256", 8 | "disk_image": true, 9 | "disk_size": 5120, 10 | "disk_interface": "virtio-scsi", 11 | "disk_discard": "unmap", 12 | "ssh_username": "packer", 13 | "ssh_password": "packerpassword", 14 | "http_directory": "cloud-data", 15 | "disk_compression": true, 16 | "qemuargs": [ 17 | ["-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"] 18 | ], 19 | "use_default_display": true 20 | } 21 | ], 22 | "provisioners": [ 23 | { 24 | "type": "file", 25 | "source": "server.hcl", 26 | "destination": "/tmp/server.hcl" 27 | }, 28 | { 29 | "type": "file", 30 | "source": "nomad.service", 31 | "destination": "/tmp/nomad.service" 32 | }, 33 | { 34 | "type": "file", 35 | "source": "consul.service", 36 | "destination": "/tmp/consul.service" 37 | }, 38 | { 39 | "type": "shell", 40 | "inline": ["sudo apt-get update", 41 | "sudo apt-get remove docker docker-engine docker.io", 42 | "echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections", 43 | "sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y", 44 | "sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -", 45 | "sudo apt-key fingerprint 0EBFCD88", 46 | "sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"", 47 | "sudo apt-get update", 48 | "sudo apt-get install -y docker-ce", 49 | "sudo service docker restart", 50 | "sudo apt-get install unzip curl vim -y", 51 | "export NOMAD_VERSION=0.10.4", 52 | "cd /tmp/", 53 | "curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip", 54 | "unzip nomad.zip", 55 | "sudo install nomad /usr/bin/nomad", 56 | "sudo mkdir -p /etc/nomad.d", 57 | "sudo cp /tmp/server.hcl /etc/nomad.d", 58 | "sudo cp /tmp/nomad.service /etc/systemd/system/", 59 | "sudo systemctl enable nomad.service", 60 | 61 | "export CONSUL_VERSION=1.6.4", 62 | "curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip > consul.zip", 63 | "unzip /tmp/consul.zip", 64 | "sudo install consul /usr/bin/consul", 65 | "sudo cp /tmp/consul.service /etc/systemd/system/", 66 | "sudo systemctl enable consul.service", 67 | 68 | "nomad -autocomplete-install" 69 | 70 | ] 71 | }, 72 | 73 | { 74 | "type": "shell", 75 | "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'", 76 | "remote_folder": "/tmp", 77 | "inline": [ 78 | "/usr/bin/apt-get clean", 79 | "rm -r /etc/apparmor.d/cache/* /etc/apparmor.d/cache/.features /etc/netplan/50-cloud-init.yaml /etc/ssh/ssh_host* /etc/sudoers.d/90-cloud-init-users", 80 | "/usr/bin/truncate --size 0 /etc/machine-id", 81 | "/usr/bin/gawk -i inplace '/PasswordAuthentication/ { gsub(/yes/, \"no\") }; { print }' /etc/ssh/sshd_config", 82 | "rm -r /root/.ssh", 83 | "rm /snap/README", 84 | "find /usr/share/netplan -name __pycache__ -exec rm -r {} +", 85 | "rm /var/cache/pollinate/seeded /var/cache/snapd/* /var/cache/motd-news", 86 | "rm -r /var/lib/cloud /var/lib/dbus/machine-id /var/lib/private /var/lib/systemd/timers /var/lib/systemd/timesync /var/lib/systemd/random-seed", 87 | "rm /var/lib/ubuntu-release-upgrader/release-upgrade-available", 88 | "rm /var/lib/update-notifier/fsck-at-reboot /var/lib/update-notifier/hwe-eol", 89 | "find /var/log -type f -exec rm {} +", 90 | "rm -r /tmp/* /tmp/.*-unix /var/tmp/*", 91 | "rm -r /home/packer", 92 | "/bin/sync", 93 | "/sbin/fstrim -v /" 94 | ] 95 | } 96 | ] 97 | } 98 | 99 | --------------------------------------------------------------------------------