Last active
April 1, 2016 23:03
-
-
Save EntropyWorks/4d93d1469f2679aec123 to your computer and use it in GitHub Desktop.
Some of the things I have for BBB https://github.com/EntropyWorks/BBB that aren't checked in
This file contains 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 characters
#!/bin/bash | |
export ANSIBLE_HOST_KEY_CHECKING=False | |
pushd /Users/yazz/Work/ATG/BBB | |
vagrant destroy -f | |
vagrant up | |
vagrant ssh-config > ~/.ssh/config.d/01-BBB.cfg | |
vagrant flow ansibleinventory > /Users/yazz/Work/ATG/coreos/inventory-virtualbox/vagrant_ansible_inventory | |
popd | |
# https://github.com/EntropyWorks/DeCore | |
pushd /Users/yazz/ATG/coreos/DeCore | |
ansible-playbook -v -i ../inventory-virtualbox/ dockerdna-install.yml | |
popd |
This file contains 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 characters
#cloud-config | |
--- | |
write_files: | |
- path: /opt/bin/waiter.sh | |
owner: root | |
content: | | |
#! /usr/bin/bash | |
until curl http://127.0.0.1:4001/v2/machines; do sleep 2; done | |
coreos: | |
units: | |
- name: setup-network-environment.service | |
command: start | |
content: | | |
[Unit] | |
Description=Setup Network Environment | |
Documentation=https://github.com/kelseyhightower/setup-network-environment | |
Requires=network-online.target | |
After=network-online.target | |
[Service] | |
ExecStartPre=-/usr/bin/mkdir -p /opt/bin | |
ExecStartPre=/usr/bin/wget -N -P /opt/bin https://storage.googleapis.com/k8s/setup-network-environment | |
ExecStartPre=/usr/bin/chmod +x /opt/bin/setup-network-environment | |
ExecStart=/opt/bin/setup-network-environment | |
RemainAfterExit=yes | |
Type=oneshot | |
- name: etcd.service | |
command: start | |
content: | | |
[Unit] | |
Description=etcd | |
Requires=setup-network-environment.service | |
After=setup-network-environment.service | |
[Service] | |
EnvironmentFile=/etc/network-environment | |
EnvironmentFile=/etc/environment | |
User=etcd | |
PermissionsStartOnly=true | |
ExecStart=/usr/bin/etcd \ | |
--name ${COREOS_PRIVATE_IPV4} \ | |
--addr ${COREOS_PRIVATE_IPV4}:4001 \ | |
--bind-addr 0.0.0.0 \ | |
--cluster-active-size 1 \ | |
--data-dir /var/lib/etcd \ | |
--http-read-timeout 86400 \ | |
--peer-addr ${COREOS_PRIVATE_IPV4}:7001 \ | |
--discovery AUTO_REPLACED_WITH_DISCOVERY_URL \ | |
--snapshot true | |
Restart=always | |
RestartSec=10s | |
- name: fleet.socket | |
command: start | |
content: | | |
[Socket] | |
ListenStream=/var/run/fleet.sock | |
- name: fleet.service | |
command: start | |
content: | | |
[Unit] | |
Description=fleet daemon | |
Wants=etcd.service | |
After=etcd.service | |
Wants=fleet.socket | |
After=fleet.socket | |
Requires=setup-network-environment.service | |
After=setup-network-environment.service | |
[Service] | |
EnvironmentFile=/etc/network-environment | |
EnvironmentFile=/etc/environment | |
Environment="FLEET_ETCD_SERVERS=http://127.0.0.1:4001" | |
Environment="FLEET_METADATA=role=master" | |
ExecStart=/usr/bin/fleetd | |
Restart=always | |
RestartSec=10s | |
- name: etcd-waiter.service | |
command: start | |
content: | | |
[Unit] | |
Description=etcd waiter | |
Wants=network-online.target | |
Wants=etcd.service | |
After=etcd.service | |
After=network-online.target | |
Before=flannel.service | |
[Service] | |
ExecStartPre=/usr/bin/chmod +x /opt/bin/waiter.sh | |
ExecStart=/usr/bin/bash /opt/bin/waiter.sh | |
RemainAfterExit=true | |
Type=oneshot | |
- name: flannel.service | |
command: start | |
content: | | |
[Unit] | |
Wants=etcd-waiter.service | |
After=etcd-waiter.service | |
Requires=etcd.service | |
After=etcd.service | |
After=network-online.target | |
Wants=network-online.target | |
Description=flannel is an etcd backed overlay network for containers | |
[Service] | |
Type=notify | |
ExecStartPre=-/usr/bin/mkdir -p /opt/bin | |
ExecStartPre=/usr/bin/wget -N -P /opt/bin https://storage.googleapis.com/k8s/flanneld | |
ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld | |
ExecStartPre=-/usr/bin/etcdctl mk /coreos.com/network/config '{"Network":"10.244.0.0/16", "Backend": {"Type": "vxlan"}}' | |
ExecStart=/opt/bin/flanneld | |
update: | |
group: alpha | |
reboot-strategy: off |
This file contains 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 characters
--- | |
# This is used by the vagrant plugin vagrant-flow | |
# This will generate the ansible inventory file | |
servers: | |
- minion-01 | |
- minion-02 | |
- minion-03 | |
gatekeeper: | |
- gatekeeper |
This file contains 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 characters
--- | |
# Have some common items that all boxes will have. These can | |
# be overwritten simply by add them later. Check out the | |
# gatekeeper server for an example | |
shared: &shared | |
shell: "scripts/setup-minion.sh" | |
ansible: "provisioning/main.yml" | |
ram: "512" | |
# Example of having some different flavors avaliable | |
ubuntu_stable: &ubuntu_yazz | |
<<: *shared | |
box_url: "https://atlas.hashicorp.com/entropyworks/boxes/ubuntu-14.04.amd64" | |
box: "entropyworks/ubuntu-14.04.amd64" | |
debian_testing: &debian_testing | |
<<: *shared | |
box_url: "https://atlas.hashicorp.com/entropyworks/boxes/debian-7.8.0-amd64" | |
box: "entropyworks/debian-7.8.0-amd64" | |
default: &default # I set this to what I want most times | |
<<: *debian_testing | |
servers: | |
- name: minion-01 | |
<<: *default | |
ip: "172.17.8.101" | |
ip6: "2001:470:ea46:1::101" # Not used yet but will be | |
- name: minion-02 | |
<<: *default | |
ip: "172.17.8.102" | |
ip6: "2001:470:ea46:1::102" # Not used yet but will be | |
- name: gatekeeper | |
<<: *default | |
ram: "1024" | |
ansible: "provisioning/gatekeeper.yml" # overwritten shared default | |
shell: "scripts/setup-gatekeeper.sh" | |
ip: "172.17.8.100" | |
ip6: "2001:470:ea46:1::5" # Not used yet but will be |
This file contains 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 characters
--- | |
shared: &shared # Have some common items that all boxes need | |
ansible_inventory_path: "inventory-file" | |
shell: "scripts/setup-minion.sh" | |
ansible: "provisioning/main.yml" | |
ram: "512" | |
gui: "true" | |
debian_stable: &debian_stable | |
<<: *shared | |
box_url: "https://atlas.hashicorp.com/cargomedia/boxes/debian-7-amd64-cm" | |
box: "cargomedia/debian-7-amd64-cm" | |
debian_testing: &debian_testing | |
<<: *shared | |
box_url: "https://atlas.hashicorp.com/binarydata/boxes/debian-jessie" | |
box: "binarydata/debian-jessie" | |
ubuntu_stable: &ubuntu_stable | |
<<: *shared | |
box_url: "https://vagrantcloud.com/ubuntu/boxes/trusty64" | |
box: "ubuntu/trusty64" | |
pfsence_214: &pfsence_214 | |
box_url: "https://vagrantcloud.com/cmad/boxes/pfsense" | |
box: "cmad/pfsense" | |
ram: "512" | |
ubuntu_stable: &ubuntu_yazz | |
<<: *shared | |
box_url: "https://atlas.hashicorp.com/entropyworks/boxes/ubuntu-14.04.amd64" | |
box: "entropyworks/ubuntu-14.04.amd64" | |
debian_stable: &debian_stable | |
<<: *shared | |
box_url: "https://atlas.hashicorp.com/entropyworks/boxes/debian-7.8.0-amd64" | |
box: "entropyworks/debian-7.8.0-amd64" | |
debian_jessie: &debian_jessie | |
<<: *shared | |
box_url: "https://atlas.hashicorp.com/entropyworks/boxes/debian-jessie-DI-rc1-amd64" | |
box: "entropyworks/debian-jessie-DI-rc1-amd64" | |
coreos_alpha: &coreos_alpha | |
<<: *shared | |
box_url: "http://alpha.release.core-os.net/amd64-usr/current/coreos_production_vagrant.box" | |
box: "coreos/alpha" | |
default: &default # I set this to what I want most times | |
<<: *ubuntu_stable | |
#bridge: "en1: Wi-Fi (AirPort)" | |
#<<: *debian_jessie | |
servers: | |
- name: minion-01 | |
<<: *default | |
ip: "172.17.8.101" | |
ip6: "2001:470:ea46:1::101" | |
- name: minion-02 | |
<<: *default | |
ip: "172.17.8.102" | |
ip6: "2001:470:ea46:1::102" | |
# - name: minion-03 | |
# <<: *default | |
# ip: "172.17.8.103" | |
# ip6: "2001:470:ea46:1::103" | |
# | |
# - name: minion-04 | |
# <<: *default | |
# ip: "172.17.8.104" | |
# ip6: "2001:470:ea46:1::104" | |
# | |
# - name: minion-05 | |
# <<: *default | |
# ip: "172.17.8.105" | |
# ip6: "2001:470:ea46:1::105" | |
- name: gatekeeper | |
<<: *default | |
ram: "1024" | |
ansible: "provisioning/gatekeeper.yml" | |
shell: "scripts/setup-gatekeeper.sh" | |
ip: "172.17.8.100" | |
ip6: "2001:470:ea46:1::5" | |
# working on some ideas for IPv6 settings | |
#ipv6: | |
# ipv6_range: "2001:470:b:660::/64" | |
# ipv6_start: "2001:470:ea46::/48" |
This file contains 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 characters
--- | |
shared: &shared # Have some common items that all boxes need | |
ansible_inventory_path: "inventory-file" | |
ram: "512" | |
gui: "true" | |
coreos_alpha: &coreos_alpha | |
<<: *shared | |
box_url: "http://alpha.release.core-os.net/amd64-usr/current/coreos_production_vagrant.box" | |
box: "coreos/alpha" | |
default: &default # I set this to what I want most times | |
<<: *coreos_alpha | |
servers: | |
- name: core-01 | |
<<: *default | |
ip: "172.17.8.101" | |
ip6: "2001:470:ea46:1::101" | |
cloud_config: "coreos-user-data" | |
- name: core-02 | |
<<: *default | |
ip: "172.17.8.102" | |
ip6: "2001:470:ea46:1::102" | |
# - name: core-03 | |
# <<: *default | |
# ip: "172.17.8.103" | |
# ip6: "2001:470:ea46:1::103" |
This file contains 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 characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' | |
# Require YAML module so we can use yaml for doing the configuation | |
require 'yaml' | |
# Set a default configuration that you can override | |
SERVERS_CONF = ENV['SERVERS_CONF'] || 'servers.yaml' | |
# Read YAML file with box details | |
servers = YAML.load_file( SERVERS_CONF ) | |
# Check for missing vagrant plugins | |
required_plugins = %w( vagrant-hostmanager ) | |
required_plugins.each do |plugin| | |
raise " #{plugin} is not installed!" unless Vagrant.has_plugin? plugin | |
end | |
# Create boxes | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# Using the vagrant-hostmanager plugin to make life easier | |
if Vagrant.has_plugin?("vagrant-hostmanager") | |
config.hostmanager.enabled = true | |
config.hostmanager.manage_host = false | |
config.hostmanager.ignore_private_ip = false | |
config.hostmanager.include_offline = true | |
end | |
# Speed thing up if we cache packages | |
if Vagrant.has_plugin?("vagrant-cachier") | |
# Configure cached packages to be shared between instances of the same base box. | |
# More info on http://fgrehm.viewdocs.io/vagrant-cachier/usage | |
config.cache.scope = :box | |
end | |
# Iterate through entries in YAML file server section | |
servers['servers'].each do |servers| | |
config.vm.define servers["name"] do |vm_config| | |
vm_config.vm.box = servers["box"] | |
vm_config.vm.box_url = servers["box_url"] | |
vm_config.vm.hostname = servers["name"] | |
# Disable inserting an ssh key | |
# | |
if servers["insert_key"] | |
vm_config.ssh.insert_key = servers["insert_key"] | |
else | |
vm_config.ssh.insert_key = "True" | |
end | |
# Adding virtualbox options | |
# | |
vm_config.vm.provider :virtualbox do |vb| | |
vb.gui = servers["gui"] | |
vb.name = servers["name"] | |
vb.memory = servers["ram"] | |
vb.check_guest_additions = false | |
vb.functional_vboxsf = false | |
end | |
# Networking options you can have. | |
# You can have all three set in the servers.yaml | |
# | |
# bridge = set to the interface you need to brige | |
# ip = set to a private_network if not set use dhcp for private_network | |
# | |
if servers["bridge"] | |
vm_config.vm.network "public_network", bridge: servers["bridge"] | |
else | |
# Setup the network | |
# | |
if servers["ip"] # If the ip is not set assume dhcp instead | |
# I am not sure if using "virtualbox__intnet: true" would be helpful | |
vm_config.vm.network "private_network", ip: servers["ip"] | |
else | |
vm_config.vm.network "private_network", type: "dhcp" | |
end | |
end | |
# Provision the VM with ansible | |
#:1 | |
if servers["ansible"] | |
vm_config.vm.provision :ansible do |ansible| | |
ansible.playbook = servers["ansible"] | |
#ansible_inventory_path = shared["ansible_inventory_path"] | |
end | |
end | |
# Run a script | |
# | |
if servers["shell"] | |
vm_config.vm.provision :shell do |shell| | |
shell.path = servers["shell"] | |
end | |
end | |
# Trying to get CoreOS to work | |
$share_home = false | |
$shared_folders = {} | |
#$shared_folders.each_with_index do |(host_folder, guest_folder), index| | |
# config.vm.synced_folder host_folder.to_s, guest_folder.to_s, id: "core-share%02d" % index, nfs: true, mount_options: ['nolock,vers=3,udp'] | |
#end | |
if $share_home | |
config.vm.synced_folder ENV['HOME'], ENV['HOME'], id: "home", :nfs => true, :mount_options => ['nolock,vers=3,udp'] | |
end | |
if servers["cloud_config"] | |
CLOUD_CONFIG_ = servers["cloud_config"] | |
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), CLOUD_CONFIG_ ) | |
if File.exists?(CLOUD_CONFIG_PATH) && ARGV[0].eql?('up') | |
if File.exists?(CLOUD_CONFIG_PATH + ".yaml" ) | |
puts "Already have #{CLOUD_CONFIG_PATH}.yaml" | |
else | |
require 'open-uri' | |
token = open('https://discovery.etcd.io/new').read | |
file_names = [ "#{CLOUD_CONFIG_PATH}" ] | |
file_names.each do |file_name| | |
text = File.read(file_name) | |
new_contents = text.gsub(/AUTO_REPLACED_WITH_DISCOVERY_URL/, token ) | |
# To merely print the contents of the file, use: | |
puts token | |
# To write changes to the file, use: | |
File.open(file_name + '.yaml', "w") {|file| file.puts new_contents } | |
end | |
end | |
end | |
if File.exist?(CLOUD_CONFIG_PATH) | |
config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data" | |
config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment