Add Ansible support

Add support for running Ansible playbook to configure VMs with packages necessary to turn up Kubernetes using kubeadm

Signed-off-by: Scott Lowe <scott.lowe@scottlowe.org>
This commit is contained in:
Scott Lowe 2018-03-11 16:38:59 -06:00
parent 2b49f918c9
commit 99f1a3d73a
No known key found for this signature in database
GPG key ID: 949F43F6E6C11780
3 changed files with 52 additions and 0 deletions

View file

@ -66,4 +66,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end # srv.vm.provider 'virtualbox'
end # config.vm.define
end # machines.each
# Configure the VM using Ansible
config.vm.provision 'ansible' do |ansible|
ansible.playbook = 'ansible.yml'
end # config.vm.provision
end # Vagrant.configure

View file

@ -0,0 +1,5 @@
[defaults]
inventory = .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
private_key_file = ~/.vagrant.d/insecure_private_key
remote_user = vagrant
host_key_checking = False

View file

@ -0,0 +1,42 @@
---
- hosts: "all"
become: true
remote_user: "vagrant"
gather_facts: false
tasks:
- name: "Install Python"
raw: "apt-get -y -q install python"
- name: "Gather facts"
setup:
- name: "Install Kubernetes APT Key"
apt_key:
url: "https://packages.cloud.google.com/apt/doc/apt-key.gpg"
state: "present"
tags:
- manager
- worker
- name: "Add Kubernetes repository for Ubuntu Xenial"
apt_repository:
repo: "deb http://apt.kubernetes.io/ kubernetes-xenial main"
state: "present"
update_cache: "yes"
tags:
- manager
- worker
- name: "Install packages for Docker and Kubernetes"
apt:
name: "{{ item }}"
state: "present"
with_items:
- "docker.io"
- "kubectl"
- "kubelet"
- "kubeadm"
tags:
- manager
- node