add vagrant
This commit is contained in:
parent
51f1ae1e9e
commit
fcd669d424
5 changed files with 150 additions and 6 deletions
20
.travis.yml
20
.travis.yml
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: trusty
|
||||||
language: python
|
language: python
|
||||||
|
@ -8,14 +9,20 @@ addons:
|
||||||
- node1
|
- node1
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- SITE=cluster.yml ANSIBLE_VERSION=2.0.0
|
- SITE=cluster.yml ANSIBLE_VERSION=1.9.4 DIST=ubuntu DIST_RELEASE=wily64 INVENTORY=1node.cfg
|
||||||
- SITE=cluster.yml ANSIBLE_VERSION=1.9.4
|
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
|
- wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
|
||||||
|
- echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
|
||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
|
- sudo apt-get install -y -q virtualbox-4.3 inux-headers-3.19.0-30-generic dkms
|
||||||
|
- sudo wget -nv https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.deb
|
||||||
|
- sudo dpkg -i vagrant_1.8.1_x86_64.deb
|
||||||
|
- sudo /etc/init.d/vboxdrv setup
|
||||||
|
- mkdir -p $HOME/.ssh
|
||||||
|
- ssh-keygen -t rsa -b 4096 -C "build@ansibl8s.io" -f $HOME/.ssh/id_rsa -P ""
|
||||||
|
|
||||||
install:
|
install:
|
||||||
# Install Ansible.
|
|
||||||
- sudo -H pip install ansible==${ANSIBLE_VERSION}
|
- sudo -H pip install ansible==${ANSIBLE_VERSION}
|
||||||
- sudo -H pip install netaddr
|
- sudo -H pip install netaddr
|
||||||
|
|
||||||
|
@ -26,17 +33,18 @@ cache:
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- export PATH=$PATH:/usr/local/bin
|
- export PATH=$PATH:/usr/local/bin
|
||||||
|
- "cd tests/vagrants/$DIST/$DIST_RELEASE && vagrant up"
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# Check the role/playbook's syntax.
|
# Check the role/playbook's syntax.
|
||||||
- "sudo -H ansible-playbook -i inventory/local-tests.cfg $SITE --syntax-check"
|
- "sudo -H ansible-playbook -i tests/inventory/$INVENTORY $SITE --syntax-check"
|
||||||
|
|
||||||
# Run the role/playbook with ansible-playbook.
|
# Run the role/playbook with ansible-playbook.
|
||||||
- "sudo -H ansible-playbook -i inventory/local-tests.cfg $SITE --connection=local"
|
- "sudo -H ansible-playbook -i tests/inventory/$INVENTORY $SITE -e ansible_ssh_user=root"
|
||||||
|
|
||||||
# Run the role/playbook again, checking to make sure it's idempotent.
|
# Run the role/playbook again, checking to make sure it's idempotent.
|
||||||
- >
|
- >
|
||||||
sudo -H ansible-playbook -i inventory/local-tests.cfg $SITE --connection=local
|
sudo -H ansible-playbook -i tests/inventory/$INVENTORY $SITE -e ansible_ssh_user=root
|
||||||
| tee /dev/stderr | grep -q 'changed=0.*failed=0'
|
| tee /dev/stderr | grep -q 'changed=0.*failed=0'
|
||||||
&& (echo 'Idempotence test: pass' && exit 0)
|
&& (echo 'Idempotence test: pass' && exit 0)
|
||||||
|| (echo 'Idempotence test: fail' && exit 1)
|
|| (echo 'Idempotence test: fail' && exit 1)
|
||||||
|
|
21
tests/inventory/1node.cfg
Normal file
21
tests/inventory/1node.cfg
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
node-a ansible_ssh_host=192.168.50.4 ip=192.168.50.4
|
||||||
|
localhost ansible_connection=local
|
||||||
|
|
||||||
|
[downloader]
|
||||||
|
localhost
|
||||||
|
|
||||||
|
[kube-master]
|
||||||
|
node-a
|
||||||
|
|
||||||
|
[etcd]
|
||||||
|
node-a
|
||||||
|
|
||||||
|
[kube-node]
|
||||||
|
node-a
|
||||||
|
|
||||||
|
[k8s-cluster:children]
|
||||||
|
kube-node
|
||||||
|
kube-master
|
||||||
|
|
||||||
|
[k8s-cluster:vars]
|
||||||
|
local_release_dir=/tmp/kube-releases
|
25
tests/inventory/3nodes.cfg
Normal file
25
tests/inventory/3nodes.cfg
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
node-a ansible_ssh_host=192.168.50.4 ip=192.168.50.4
|
||||||
|
node-b ansible_ssh_host=192.168.50.5 ip=192.168.50.5
|
||||||
|
node-c ansible_ssh_host=192.168.50.6 ip=192.168.50.6
|
||||||
|
localhost ansible_connection=local
|
||||||
|
|
||||||
|
[downloader]
|
||||||
|
localhost
|
||||||
|
|
||||||
|
[kube-master]
|
||||||
|
node-a
|
||||||
|
|
||||||
|
[etcd]
|
||||||
|
node-a
|
||||||
|
|
||||||
|
[kube-node]
|
||||||
|
node-a
|
||||||
|
node-b
|
||||||
|
node-c
|
||||||
|
|
||||||
|
[k8s-cluster:children]
|
||||||
|
kube-node
|
||||||
|
kube-master
|
||||||
|
|
||||||
|
[k8s-cluster:vars]
|
||||||
|
local_release_dir=/tmp/kube-releases
|
1
tests/inventory/group_vars
Symbolic link
1
tests/inventory/group_vars
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../inventory/group_vars
|
89
tests/vagrants/ubuntu/wily64/Vagrantfile
vendored
Normal file
89
tests/vagrants/ubuntu/wily64/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
# -*- mode: ruby -*-
|
||||||
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
|
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||||
|
# configures the configuration version (we support older styles for
|
||||||
|
# backwards compatibility). Please don't change it unless you know what
|
||||||
|
# you're doing.
|
||||||
|
Vagrant.configure(2) do |config|
|
||||||
|
# The most common configuration options are documented and commented below.
|
||||||
|
# For a complete reference, please see the online documentation at
|
||||||
|
# https://docs.vagrantup.com.
|
||||||
|
|
||||||
|
# Every Vagrant development environment requires a box. You can search for
|
||||||
|
# boxes at https://atlas.hashicorp.com/search.
|
||||||
|
config.vm.provision "shell", inline: "echo Hello"
|
||||||
|
config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/.ssh/me.pub"
|
||||||
|
config.vm.provision "shell", inline: "cat ~vagrant/.ssh/me.pub >> ~vagrant/.ssh/authorized_keys"
|
||||||
|
config.vm.provision "shell", inline: "cat /home/vagrant/.ssh/me.pub >> /root/.ssh/authorized_keys"
|
||||||
|
|
||||||
|
config.vm.define "node-a" do |node|
|
||||||
|
node.vm.box = "ubuntu/wily64"
|
||||||
|
node.vm.network "private_network", ip: "192.168.50.4"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.define "node-b" do |node|
|
||||||
|
node.vm.box = "ubuntu/wily64"
|
||||||
|
node.vm.network "private_network", ip: "192.168.50.5"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.define "node-c" do |node|
|
||||||
|
node.vm.box = "ubuntu/wily64"
|
||||||
|
node.vm.network "private_network", ip: "192.168.50.6"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Disable automatic box update checking. If you disable this, then
|
||||||
|
# boxes will only be checked for updates when the user runs
|
||||||
|
# `vagrant box outdated`. This is not recommended.
|
||||||
|
# config.vm.box_check_update = false
|
||||||
|
|
||||||
|
# Create a forwarded port mapping which allows access to a specific port
|
||||||
|
# within the machine from a port on the host machine. In the example below,
|
||||||
|
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||||
|
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||||
|
|
||||||
|
# Create a private network, which allows host-only access to the machine
|
||||||
|
# using a specific IP.
|
||||||
|
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||||
|
|
||||||
|
# Create a public network, which generally matched to bridged network.
|
||||||
|
# Bridged networks make the machine appear as another physical device on
|
||||||
|
# your network.
|
||||||
|
# config.vm.network "public_network"
|
||||||
|
|
||||||
|
# Share an additional folder to the guest VM. The first argument is
|
||||||
|
# the path on the host to the actual folder. The second argument is
|
||||||
|
# the path on the guest to mount the folder. And the optional third
|
||||||
|
# argument is a set of non-required options.
|
||||||
|
# config.vm.synced_folder "../data", "/vagrant_data"
|
||||||
|
|
||||||
|
# Provider-specific configuration so you can fine-tune various
|
||||||
|
# backing providers for Vagrant. These expose provider-specific options.
|
||||||
|
# Example for VirtualBox:
|
||||||
|
#
|
||||||
|
# config.vm.provider "virtualbox" do |vb|
|
||||||
|
# # Display the VirtualBox GUI when booting the machine
|
||||||
|
# vb.gui = true
|
||||||
|
#
|
||||||
|
# # Customize the amount of memory on the VM:
|
||||||
|
# vb.memory = "1024"
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# View the documentation for the provider you are using for more
|
||||||
|
# information on available options.
|
||||||
|
|
||||||
|
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
||||||
|
# such as FTP and Heroku are also available. See the documentation at
|
||||||
|
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
||||||
|
# config.push.define "atlas" do |push|
|
||||||
|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Enable provisioning with a shell script. Additional provisioners such as
|
||||||
|
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||||
|
# documentation for more information about their specific syntax and use.
|
||||||
|
# config.vm.provision "shell", inline: <<-SHELL
|
||||||
|
# sudo apt-get update
|
||||||
|
# sudo apt-get install -y apache2
|
||||||
|
# SHELL
|
||||||
|
end
|
Loading…
Reference in a new issue