-
-
Save jayunit100/40296e1e9a864d61f03c to your computer and use it in GitHub Desktop.
This is a big diff i did to hack vbox to work w/ vagrant+ansible contrib recipes. just some notes. probably some of it was unnecessary.
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 characters
diff --git a/ansible/roles/common/tasks/fedora-install.yml b/ansible/roles/common/tasks/fedora-install.yml | |
index 48454fa..91cb424 100644 | |
--- a/ansible/roles/common/tasks/fedora-install.yml | |
+++ b/ansible/roles/common/tasks/fedora-install.yml | |
@@ -5,3 +5,15 @@ | |
name: python-firewall | |
state: latest | |
when: ansible_distribution_major_version|int >= 22 | |
+ | |
+- name: Generic | Install Python | |
+ action: "{{ ansible_pkg_mgr }}" | |
+ args: | |
+ name: python | |
+ state: latest | |
+ | |
+- name: Generic | Install SELinux Python Bindings | |
+ action: "{{ ansible_pkg_mgr }}" | |
+ args: | |
+ name: libselinux-python | |
+ state: latest | |
diff --git a/ansible/roles/flannel/templates/flanneld.j2 b/ansible/roles/flannel/templates/flanneld.j2 | |
index e24ce89..c494c87 100644 | |
--- a/ansible/roles/flannel/templates/flanneld.j2 | |
+++ b/ansible/roles/flannel/templates/flanneld.j2 | |
@@ -8,4 +8,4 @@ FLANNEL_ETCD="{% for node in groups['etcd'] %}http://{{ node }}:2379{% if not lo | |
FLANNEL_ETCD_KEY="/{{ cluster_name }}/network" | |
# Any additional options that you want to pass | |
-#FLANNEL_OPTIONS="" | |
+FLANNEL_OPTIONS="--iface=eth1" | |
diff --git a/ansible/roles/kubernetes/files/make-ca-cert.sh b/ansible/roles/kubernetes/files/make-ca-cert.sh | |
index a9966b7..5159cd4 100755 | |
--- a/ansible/roles/kubernetes/files/make-ca-cert.sh | |
+++ b/ansible/roles/kubernetes/files/make-ca-cert.sh | |
@@ -101,14 +101,17 @@ tar xzf easy-rsa.tar.gz | |
cd easy-rsa-master/easyrsa3 | |
# Sadly, openssl is very verbose to std*err* with no option to turn it off. | |
-if ! (./easyrsa --batch init-pki | |
- ./easyrsa --batch "--req-cn=${cert_ip}@$(date +%s)" build-ca nopass | |
- ./easyrsa --batch --subject-alt-name="${sans}" build-server-full "${master_name}" nopass | |
- ./easyrsa --batch build-client-full kubelet nopass | |
- ./easyrsa --batch build-client-full kubecfg nopass) >/dev/null 2>&1; then | |
- echo "=== Failed to generate certificates: Aborting ===" 1>&2 | |
- exit 2 | |
-fi | |
+echo "Starting........... ${cert_ip} $(date +%s) " | |
+./easyrsa --batch init-pki | |
+echo "1 build init-pki $?" | |
+./easyrsa --batch "--req-cn=kube.example.com@$(date +%s)" build-ca nopass | |
+echo "2 build-ca nopass $?" | |
+./easyrsa --batch --subject-alt-name="${sans}" build-server-full "${master_name}" nopass | |
+echo "4 build serv full $?" | |
+./easyrsa --batch build-client-full kubelet nopass | |
+echo "5 build client full $?" | |
+./easyrsa --batch build-client-full kubecfg nopass | |
+echo "6 bcf $?" | |
mkdir -p "$cert_dir" | |
diff --git a/ansible/roles/master/defaults/main.yml b/ansible/roles/master/defaults/main.yml | |
index 9c8cc29..948f334 100644 | |
--- a/ansible/roles/master/defaults/main.yml | |
+++ b/ansible/roles/master/defaults/main.yml | |
@@ -1,3 +1,3 @@ | |
kube_master_insecure_port: 8080 | |
-localBuildOutput: ../../_output/local/go/bin | |
\ No newline at end of file | |
+localBuildOutput: /Users/jayunit100/Development/kubernetes/_output/dockerized/bin/linux/amd64/ | |
diff --git a/ansible/roles/node/tasks/localBuildInstall.yml b/ansible/roles/node/tasks/localBuildInstall.yml | |
index f208d48..8912b9c 100644 | |
--- a/ansible/roles/node/tasks/localBuildInstall.yml | |
+++ b/ansible/roles/node/tasks/localBuildInstall.yml | |
@@ -1,7 +1,7 @@ | |
--- | |
- name: Copy node binaries | |
copy: | |
- src: "{{ localBuildOutput }}/{{ item }}" | |
+ src: "/Users/jayunit100/Development/kubernetes/_output/dockerized/bin/linux/amd64/{{ item }}" | |
dest: /usr/bin/ | |
mode: 0755 | |
with_items: | |
diff --git a/ansible/vagrant/Vagrantfile b/ansible/vagrant/Vagrantfile | |
index 7d40fa5..b0202e0 100644 | |
--- a/ansible/vagrant/Vagrantfile | |
+++ b/ansible/vagrant/Vagrantfile | |
@@ -5,7 +5,7 @@ require "yaml" | |
### This is a new provider, different then cloudbau's. | |
### RUN: vagrant plugin uninstall vagrant-openstack-plugin" | |
### Then RUN: "vagrant plugin install vagrant-openstack-provider" | |
-require 'vagrant-openstack-provider' | |
+# require 'vagrant-openstack-provider' | |
$num_nodes = (ENV['NUM_NODES'] || 2).to_i | |
ansible_tags = ENV['ANSIBLE_TAGS'] | |
@@ -15,6 +15,19 @@ VAGRANTFILE_API_VERSION = "2" | |
# Openstack providers are best used with latest versions. | |
Vagrant.require_version ">= 1.7" | |
+def getip(vm, cached_addresses, name) | |
+ | |
+ if cached_addresses[vm.name].nil? | |
+ if hostname = (vm.ssh_info && vm.ssh_info[:host]) | |
+ vm.communicate.execute("/usr/sbin/ip addr show eth1 | grep 'inet ' | xargs | cut -f 2 -d ' '| cut -f 1 -d '/' 2>&1") do |type, contents| | |
+ cached_addresses[name] = contents.split("\n").first[/(\d+\.\d+\.\d+\.\d+)/, 1] | |
+ end | |
+ end | |
+ end | |
+### Since we aren't gauranteed to have calculated the result, just return whatevers in the cache. | |
+cached_addresses[name] | |
+end | |
+ | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# By default, Vagrant 1.7+ automatically inserts a different | |
# insecure keypair for each new VM created. The easiest way | |
@@ -45,7 +58,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.ssh.private_key_path = "~/.ssh/id_rsa" | |
config.vm.boot_timeout = 60*10 | |
- ### The below parameters need to be modified per your openstack instance. | |
+ ### The below parameters need to be modified per your openstack instance. | |
os.username = _config['os_username'] | |
os.password = _config['os_password'] | |
os.tenant_name = _config['os_tenant'] | |
@@ -60,7 +73,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
end | |
def set_vbox(vb, config) | |
- config.vm.box = "chef/centos-7.0" | |
+ #config.vm.box = "chef/centos-7.0" | |
+ config.vm.box = "hfm4/centos7" | |
+ #config.vm.box = "boxcutter/fedora21" | |
+ #config.vm.box = "fedora_fedora23" | |
+ #config.vm.name = "f23" | |
+ #config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box" | |
+ | |
config.vm.network "private_network", type: "dhcp" | |
vb.gui = false | |
vb.memory = 2048 | |
@@ -93,17 +112,28 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
end | |
config.vm.synced_folder ".", "/vagrant", disabled: true | |
- | |
+cached_addresses = {} | |
+ config.hostmanager.enabled = true | |
+ | |
nodes = Array.new() | |
- $num_nodes.times do |i| | |
- # multi vm config | |
- name = "kube-node-#{i+1}" | |
- nodes.push(name) | |
- config.vm.define "#{name}" do |n| | |
- n.vm.hostname = name | |
+ | |
+ config.vm.define "kube-node-1" do |n| | |
+ n.vm.hostname = "kube-node-1" | |
set_provider(n) | |
+ nodes.push("kube-node-1") | |
+ config.hostmanager.ip_resolver = proc do |vm, resolving_vm| | |
+ getip(vm, cached_addresses, vm.name) | |
+ end | |
+ end | |
+ | |
+ config.vm.define "kube-node-2" do |n| | |
+ nodes.push("kube-node-2") | |
+ n.vm.hostname = "kube-node-2" | |
+ set_provider(n) | |
+ config.hostmanager.ip_resolver = proc do |vm, resolving_vm| | |
+ getip(vm, cached_addresses, vm.name) | |
+ end | |
end | |
- end | |
# This is how we create the ansible inventory, see it in .vagrant | |
# if you want to debug, run 'VAGRANT_LOG=info vagrant up' | |
@@ -114,24 +144,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
"nodes" => nodes, | |
"all_groups:children" => ["etcd","masters","nodes"] | |
} | |
- | |
config.vm.define "kube-master" do |n| | |
name = "kube-master" | |
n.vm.hostname = name | |
set_provider(n) | |
- | |
- if ansible_tags.nil? | |
- # This set up the vagrant hosts before we run the main playbook | |
- # Today this just creates /etc/hosts so machines can talk via their | |
- # 'internal' IPs instead of the openstack public ip. | |
- n.vm.provision :ansible do |ansible| | |
- ansible.groups = groups | |
- ansible.playbook = "./vagrant-ansible.yml" | |
- ansible.limit = "all" #otherwise the metadata wont be there for ipv4? | |
- ansible.raw_ssh_args = ['-o ControlMaster=no'] | |
- end | |
+ config.hostmanager.ip_resolver = proc do |vm, resolving_vm| | |
+ getip(vm, cached_addresses, vm.name) | |
end | |
- | |
+ | |
# This sets up both flannel and kube. | |
n.vm.provision :ansible do |ansible| | |
ansible.groups = groups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment