Commit f0d7f708 authored by Mike Danese's avatar Mike Danese

Merge pull request #11264 from eparis/total-ansible

Ansible updates
parents bfd22a69 1253ca52
# Kubernetes Ansible # Kubernetes Ansible
This playbook helps you to set up a Kubernetes cluster on machines where you This playbook and set of roles set up a Kubernetes cluster onto machines. They
can't or don't want to use the salt scripts and cluster up/down tools. They can be real hardware, VMs, things in a public cloud, etc. Anything that you can connect to via SSH.
can be real hardware, VMs, things in a public cloud, etc.
## Before starting ## Before starting
* Record the IP address/hostname of which machine you want to be your master (only support a single master) * Record the IP address/hostname of which machine you want to be your master (only support a single master)
* Record the IP address/hostname of the machine you want to be your etcd server (often same as master, only one) * Record the IP address/hostname of the machine you want to be your etcd server (often same as master, only one)
* Record the IP addresses/hostname of the machines you want to be your nodes. (the master can also be a node) * Record the IP addresses/hostname of the machines you want to be your nodes. (the master can also be a node)
* Make sure your ansible running machine has ansible 1.9 and python-netaddr installed.
### Configure the inventory file ## Setup
Stick the system information gathered above into the 'inventory' file. ### Configure inventory
### Configure your cluster Add the system information gathered above into the 'inventory' file, or create a new inventory file for the cluster.
You will want to look though all of the options in `group_vars/all.yml` and ### Configure Cluster options
set the variables to reflect your needs. The options should be described there
Look though all of the options in `group_vars/all.yml` and
set the variables to reflect your needs. The options are described there
in full detail. in full detail.
### Set up the actual kubernetes cluster ## Running the playbook
Now run the setup: After going through the setup, run the setup script provided:
`$ ./setup.sh` `$ ./setup.sh`
In generel this will work on very recent Fedora, rawhide or F21. Future work to You may override the inventory file by doing:
`INVENTORY=myinventory ./setup.sh`
In general this will work on very recent Fedora, rawhide or F21. Future work to
support RHEL7, CentOS, and possible other distros should be forthcoming. support RHEL7, CentOS, and possible other distros should be forthcoming.
### You can just set up certain parts instead of doing it all ### Targeted runs
Only etcd: You can just setup certain parts instead of doing it all.
#### etcd
`$ ./setup.sh --tags=etcd` `$ ./setup.sh --tags=etcd`
Only the kubernetes master: #### Kubernetes master
`$ ./setup.sh --tags=masters` `$ ./setup.sh --tags=masters`
Only the kubernetes nodes: #### kubernetes nodes
`$ ./setup.sh --tags=nodes` `$ ./setup.sh --tags=nodes`
### You may overwrite the inventory file by doing ### flannel
`INVENTORY=myinventory ./setup.sh`
Only flannel:
$ ./setup.sh --tags=flannel `$ ./setup.sh --tags=flannel`
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/contrib/ansible/README.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/contrib/ansible/README.md?pixel)]()
# This value determines how kubernetes binaries, config files, and service
# files are loaded onto the target machines. The following are the only
# valid options:
#
# localBuild - requires make release to have been run to build local binaries
# packageManager - will install packages from your distribution using yum/dnf/apt
source_type: localBuild
# will be used as the Internal dns domain name if DNS is enabled. Services # will be used as the Internal dns domain name if DNS is enabled. Services
# will be discoverable under <service-name>.<namespace>.svc.<domainname>, e.g. # will be discoverable under <service-name>.<namespace>.svc.<domainname>, e.g.
# myservice.default.svc.cluster.local # myservice.default.svc.cluster.local
...@@ -50,6 +58,9 @@ cluster_logging: true ...@@ -50,6 +58,9 @@ cluster_logging: true
# Turn to false to disable cluster monitoring with heapster and influxdb # Turn to false to disable cluster monitoring with heapster and influxdb
cluster_monitoring: true cluster_monitoring: true
# Turn to false to disable the kube-ui addon for this cluster
kube-ui: false
# Turn this varable to 'false' to disable whole DNS configuration. # Turn this varable to 'false' to disable whole DNS configuration.
dns_setup: true dns_setup: true
# How many replicas in the Replication Controller # How many replicas in the Replication Controller
......
...@@ -27,6 +27,14 @@ ...@@ -27,6 +27,14 @@
has_rpm: true has_rpm: true
when: s.stat.exists when: s.stat.exists
- name: Init the has_firewalld fact
set_fact:
has_firewalld: false
- name: Init the has_iptables fact
set_fact:
has_iptables: false
# collect information about what packages are installed # collect information about what packages are installed
- include: rpm.yml - include: rpm.yml
when: has_rpm when: has_rpm
......
...@@ -5,10 +5,6 @@ ...@@ -5,10 +5,6 @@
changed_when: false changed_when: false
failed_when: false failed_when: false
- name: Init the has_firewalld fact
set_fact:
has_firewalld: false
- name: Set the has_firewalld fact - name: Set the has_firewalld fact
set_fact: set_fact:
has_firewalld: true has_firewalld: true
...@@ -20,10 +16,6 @@ ...@@ -20,10 +16,6 @@
changed_when: false changed_when: false
failed_when: false failed_when: false
- name: Init the has_iptables fact
set_fact:
has_iptables: false
- name: Set the has_iptables fact - name: Set the has_iptables fact
set_fact: set_fact:
has_iptables: true has_iptables: true
......
---
- name: DEBIAN | Make sure this is stretch or sid, jessies does not have docker
fail: msg="Docker.io only available in sid and stretch, https://wiki.debian.org/Docker"
when: ansible_lsb.codename != "stretch" and ansible_lsb.codename != "sid"
- name: DEBIAN | Install Docker
action: "{{ ansible_pkg_mgr }}"
args:
name: docker.io
state: latest
...@@ -4,3 +4,4 @@ ...@@ -4,3 +4,4 @@
args: args:
name: docker name: docker
state: latest state: latest
when: not is_atomic
--- ---
- include: debian-install.yml
when: ansible_distribution == "Debian"
- include: generic-install.yml - include: generic-install.yml
when: not is_atomic when: ansible_distribution != "Debian"
- name: Set docker config file directory
set_fact:
docker_config_dir: "/etc/sysconfig"
- name: Override docker config file directory for Debian
set_fact:
docker_config_dir: "/etc/default"
when: ansible_distribution == "Debian"
- name: Verify docker config files exists
file: path={{ docker_config_dir }}/{{ item }} state=touch
changed_when: false
with_items:
- docker
- docker-network
- name: Turn down docker logging - name: Turn down docker logging
lineinfile: dest=/etc/sysconfig/docker regexp=^OPTIONS= line=OPTIONS="--selinux-enabled --log-level=warn" lineinfile: dest={{ docker_config_dir }}/docker regexp=^OPTIONS= line=OPTIONS="--selinux-enabled --log-level=warn"
notify: notify:
- restart docker - restart docker
- name: Install http_proxy into docker-network - name: Install http_proxy into docker-network
lineinfile: dest=/etc/sysconfig/docker-network regexp=^HTTP_PROXY= line=HTTP_PROXY="{{ http_proxy }}" lineinfile: dest={{ docker_config_dir }}/docker-network regexp=^HTTP_PROXY= line=HTTP_PROXY="{{ http_proxy }}"
when: http_proxy is defined when: http_proxy is defined
notify: notify:
- restart docker - restart docker
- name: Install https_proxy into docker-network - name: Install https_proxy into docker-network
lineinfile: dest=/etc/sysconfig/docker-network regexp=^HTTPS_PROXY= line=HTTPS_PROXY="{{ https_proxy }}" lineinfile: dest={{ docker_config_dir }}/docker-network regexp=^HTTPS_PROXY= line=HTTPS_PROXY="{{ https_proxy }}"
when: https_proxy is defined when: https_proxy is defined
notify: notify:
- restart docker - restart docker
- name: Install no-proxy into docker-network - name: Install no-proxy into docker-network
lineinfile: dest=/etc/sysconfig/docker-network regexp=^NO_PROXY= line=NO_PROXY="{{ no_proxy }}" lineinfile: dest={{ docker_config_dir }}/docker-network regexp=^NO_PROXY= line=NO_PROXY="{{ no_proxy }}"
when: no_proxy is defined when: no_proxy is defined
notify: notify:
- restart docker - restart docker
- name: Add any insecure registrys to docker config - name: Add any insecure registrys to docker config
lineinfile: dest=/etc/sysconfig/docker regexp=^INSECURE_REGISTRY= line=INSECURE_REGISTRY='{% for reg in insecure_registrys %}--insecure-registry="{{ reg }}" {% endfor %}' lineinfile: dest={{ docker_config_dir }}/docker regexp=^INSECURE_REGISTRY= line=INSECURE_REGISTRY='{% for reg in insecure_registrys %}--insecure-registry="{{ reg }}" {% endfor %}'
when: insecure_registrys is defined and insecure_registrys > 0 when: insecure_registrys is defined and insecure_registrys > 0
notify: notify:
- restart docker - restart docker
......
[Unit]
Description=Etcd Server
After=network.target
[Service]
Type=simple
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
ExecStart=/usr/bin/etcd
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
--- ---
- name: reload systemd
command: systemctl --system daemon-reload
- name: restart etcd - name: restart etcd
service: name=etcd state=restarted service: name=etcd state=restarted
when: etcd_started.changed == false when: etcd_started.changed == false
......
...@@ -13,6 +13,13 @@ ...@@ -13,6 +13,13 @@
notify: notify:
- restart etcd - restart etcd
- name: Write etcd systemd unit file for Debian
copy: src=etcd.service dest=/etc/systemd/system
notify:
- reload systemd
- restart etcd
when: ansible_distribution == "Debian"
- name: Enable etcd - name: Enable etcd
service: name=etcd enabled=yes service: name=etcd enabled=yes
......
...@@ -16,3 +16,5 @@ ...@@ -16,3 +16,5 @@
- name: start docker - name: start docker
service: name=docker state=started service: name=docker state=started
# This might fail if docker isn't installed yet
ignore_errors: yes
kube_addons_dir: "{{ kube_config_dir }}/addons"
local_temp_addon_dir: /tmp/kubernetes/addons local_temp_addon_dir: /tmp/kubernetes/addons
...@@ -21,6 +21,8 @@ KUBECTL=${KUBECTL_BIN:-/usr/local/bin/kubectl} ...@@ -21,6 +21,8 @@ KUBECTL=${KUBECTL_BIN:-/usr/local/bin/kubectl}
ADDON_CHECK_INTERVAL_SEC=${TEST_ADDON_CHECK_INTERVAL_SEC:-600} ADDON_CHECK_INTERVAL_SEC=${TEST_ADDON_CHECK_INTERVAL_SEC:-600}
SYSTEM_NAMESPACE=kube-system
token_dir=${TOKEN_DIR:-/srv/kubernetes} token_dir=${TOKEN_DIR:-/srv/kubernetes}
function create-kubeconfig-secret() { function create-kubeconfig-secret() {
...@@ -49,6 +51,7 @@ contexts: ...@@ -49,6 +51,7 @@ contexts:
- context: - context:
cluster: local cluster: local
user: ${username} user: ${username}
namespace: ${SYSTEM_NAMESPACE}
name: service-account-context name: service-account-context
current-context: service-account-context current-context: service-account-context
EOF EOF
...@@ -69,6 +72,7 @@ contexts: ...@@ -69,6 +72,7 @@ contexts:
- context: - context:
cluster: local cluster: local
user: ${username} user: ${username}
namespace: ${SYSTEM_NAMESPACE}
name: service-account-context name: service-account-context
current-context: service-account-context current-context: service-account-context
EOF EOF
...@@ -84,36 +88,39 @@ metadata: ...@@ -84,36 +88,39 @@ metadata:
name: token-${safe_username} name: token-${safe_username}
type: Opaque type: Opaque
EOF EOF
create-resource-from-string "${secretyaml}" 100 10 "Secret-for-token-for-user-${username}" & create-resource-from-string "${secretyaml}" 100 10 "Secret-for-token-for-user-${username}" "${SYSTEM_NAMESPACE}" &
# TODO: label the secrets with special label so kubectl does not show these?
} }
# $1 filename of addon to start. # $1 filename of addon to start.
# $2 count of tries to start the addon. # $2 count of tries to start the addon.
# $3 delay in seconds between two consecutive tries # $3 delay in seconds between two consecutive tries
# $4 namespace
function start_addon() { function start_addon() {
local -r addon_filename=$1; local -r addon_filename=$1;
local -r tries=$2; local -r tries=$2;
local -r delay=$3; local -r delay=$3;
local -r namespace=$4
create-resource-from-string "$(cat ${addon_filename})" "${tries}" "${delay}" "${addon_filename}" create-resource-from-string "$(cat ${addon_filename})" "${tries}" "${delay}" "${addon_filename}" "${namespace}"
} }
# $1 string with json or yaml. # $1 string with json or yaml.
# $2 count of tries to start the addon. # $2 count of tries to start the addon.
# $3 delay in seconds between two consecutive tries # $3 delay in seconds between two consecutive tries
# $3 name of this object to use when logging about it. # $4 name of this object to use when logging about it.
# $5 namespace for this object
function create-resource-from-string() { function create-resource-from-string() {
local -r config_string=$1; local -r config_string=$1;
local tries=$2; local tries=$2;
local -r delay=$3; local -r delay=$3;
local -r config_name=$4; local -r config_name=$4;
local -r namespace=$5;
while [ ${tries} -gt 0 ]; do while [ ${tries} -gt 0 ]; do
echo "${config_string}" | ${KUBECTL} create -f - && \ echo "${config_string}" | ${KUBECTL} --namespace="${namespace}" create -f - && \
echo "== Successfully started ${config_name} at $(date -Is)" && \ echo "== Successfully started ${config_name} in namespace ${namespace} at $(date -Is)" && \
return 0; return 0;
let tries=tries-1; let tries=tries-1;
echo "== Failed to start ${config_name} at $(date -Is). ${tries} tries remaining. ==" echo "== Failed to start ${config_name} in namespace ${namespace} at $(date -Is). ${tries} tries remaining. =="
sleep ${delay}; sleep ${delay};
done done
return 1; return 1;
...@@ -122,7 +129,7 @@ function create-resource-from-string() { ...@@ -122,7 +129,7 @@ function create-resource-from-string() {
# The business logic for whether a given object should be created # The business logic for whether a given object should be created
# was already enforced by salt, and /etc/kubernetes/addons is the # was already enforced by salt, and /etc/kubernetes/addons is the
# managed result is of that. Start everything below that directory. # managed result is of that. Start everything below that directory.
echo "== Kubernetes addon manager started at $(date -Is) with ADDON_CHECK_INTERVAL_SEC=${ADDON_CHECK_INTERVAL_SEC}==" echo "== Kubernetes addon manager started at $(date -Is) with ADDON_CHECK_INTERVAL_SEC=${ADDON_CHECK_INTERVAL_SEC} =="
# Load the kube-env, which has all the environment variables we care # Load the kube-env, which has all the environment variables we care
# about, in a flat yaml format. # about, in a flat yaml format.
...@@ -136,6 +143,18 @@ for k,v in yaml.load(sys.stdin).iteritems(): ...@@ -136,6 +143,18 @@ for k,v in yaml.load(sys.stdin).iteritems():
''' < "${kube_env_yaml}") ''' < "${kube_env_yaml}")
fi fi
# Create the namespace that will be used to host the cluster-level add-ons.
start_addon /etc/kubernetes/addons/namespace.yaml 100 10 "" &
# Wait for the default service account to be created in the kube-system namespace.
token_found=""
while [ -z "${token_found}" ]; do
sleep .5
token_found=$(${KUBECTL} get --namespace="${SYSTEM_NAMESPACE}" serviceaccount default -o template -t "{{with index .secrets 0}}{{.name}}{{end}}" || true)
done
echo "== default service account in the ${SYSTEM_NAMESPACE} namespace has token ${token_found} =="
# Generate secrets for "internal service accounts". # Generate secrets for "internal service accounts".
# TODO(etune): move to a completely yaml/object based # TODO(etune): move to a completely yaml/object based
# workflow so that service accounts can be created # workflow so that service accounts can be created
...@@ -143,6 +162,7 @@ fi ...@@ -143,6 +162,7 @@ fi
# NOTE: needs to run as root to read this file. # NOTE: needs to run as root to read this file.
# Read each line in the csv file of tokens. # Read each line in the csv file of tokens.
# Expect errors when the script is started again. # Expect errors when the script is started again.
# NOTE: secrets are created asynchronously, in background.
while read line; do while read line; do
# Split each line into the token and username. # Split each line into the token and username.
IFS=',' read -a parts <<< "${line}" IFS=',' read -a parts <<< "${line}"
...@@ -154,25 +174,29 @@ while read line; do ...@@ -154,25 +174,29 @@ while read line; do
else else
# Set the server to https://kubernetes. Pods/components that # Set the server to https://kubernetes. Pods/components that
# do not have DNS available will have to override the server. # do not have DNS available will have to override the server.
create-kubeconfig-secret "${token}" "${username}" "https://kubernetes" create-kubeconfig-secret "${token}" "${username}" "https://kubernetes.default"
fi fi
done < ${token_dir}/known_tokens.csv done < "${token_dir}/known_tokens.csv"
# Create admission_control objects if defined before any other addon services. If the limits # Create admission_control objects if defined before any other addon services. If the limits
# are defined in a namespace other than default, we should still create the limits for the # are defined in a namespace other than default, we should still create the limits for the
# default namespace. # default namespace.
for obj in $(find /etc/kubernetes/admission-controls \( -name \*.yaml -o -name \*.json \)); do for obj in $(find /etc/kubernetes/admission-controls \( -name \*.yaml -o -name \*.json \)); do
start_addon ${obj} 100 10 & start_addon ${obj} 100 10 default &
echo "++ obj ${obj} is created ++" echo "++ obj ${obj} is created ++"
done done
# Check if the configuration has changed recently - in case the user # Check if the configuration has changed recently - in case the user
# created/updated/deleted the files on the master. # created/updated/deleted the files on the master.
while true; do while true; do
start_sec=$(date +"%s")
#kube-addon-update.sh must be deployed in the same directory as this file #kube-addon-update.sh must be deployed in the same directory as this file
`dirname $0`/kube-addon-update.sh /etc/kubernetes/addons `dirname $0`/kube-addon-update.sh /etc/kubernetes/addons ${ADDON_CHECK_INTERVAL_SEC}
sleep $ADDON_CHECK_INTERVAL_SEC end_sec=$(date +"%s")
len_sec=$((${end_sec}-${start_sec}))
# subtract the time passed from the sleep time
if [[ ${len_sec} -lt ${ADDON_CHECK_INTERVAL_SEC} ]]; then
sleep_time=$((${ADDON_CHECK_INTERVAL_SEC}-${len_sec}))
sleep ${sleep_time}
fi
done done
--- ---
- name: reload and restart kube-addons - name: reload and restart kube-addons
command: systemctl daemon-reload command: systemctl --system daemon-reload
notify: notify:
- restart kube-addons - restart kube-addons
......
--- ---
- name: LOGGING | Assures {{ kube_config_dir }}/addons/cluster-logging dir exists - name: LOGGING | Assures {{ kube_addons_dir }}/cluster-logging dir exists
file: path={{ kube_config_dir }}/addons/cluster-logging state=directory file: path={{ kube_addons_dir }}/cluster-logging state=directory
- name: LOGGING | Download logging files from Kubernetes repo - name: LOGGING | Download logging files from Kubernetes repo
get_url: get_url:
url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/addons/fluentd-elasticsearch/{{ item }} url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/addons/fluentd-elasticsearch/{{ item }}
dest="{{ kube_config_dir }}/addons/cluster-logging/" dest="{{ kube_addons_dir }}/cluster-logging/"
force=yes force=yes
with_items: with_items:
- es-controller.yaml - es-controller.yaml
......
--- ---
- name: MONITORING | Assures {{ kube_config_dir }}/addons/cluster-monitoring dir exists - name: MONITORING | Assures {{ kube_config_dir }}/addons/cluster-monitoring dir exists
file: path={{ kube_config_dir }}/addons/cluster-monitoring state=directory file: path={{ kube_addons_dir }}/cluster-monitoring state=directory
- name: MONITORING | Download monitoring files from Kubernetes repo - name: MONITORING | Download monitoring files from Kubernetes repo
get_url: get_url:
url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/addons/cluster-monitoring/influxdb/{{ item }} url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/addons/cluster-monitoring/influxdb/{{ item }}
dest="{{ kube_config_dir }}/addons/cluster-monitoring/" dest="{{ kube_addons_dir }}/cluster-monitoring/"
force=yes force=yes
with_items: with_items:
- grafana-service.yaml - grafana-service.yaml
......
--- ---
- name: DNS | Assures {{ kube_config_dir }}/addons/dns dir exists - name: DNS | Assures {{ kube_addons_dir }}/dns dir exists
file: path={{ kube_config_dir }}/addons/dns state=directory file: path={{ kube_addons_dir }}/dns state=directory
- name: DNS | Assures local dns addon dir exists - name: DNS | Assures local dns addon dir exists
local_action: file local_action: file
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
template: template:
args: args:
src: "{{ local_temp_addon_dir }}/dns/skydns-rc.yaml.j2" src: "{{ local_temp_addon_dir }}/dns/skydns-rc.yaml.j2"
dest: "{{ kube_config_dir }}/addons/dns/skydns-rc.yaml" dest: "{{ kube_addons_dir }}/dns/skydns-rc.yaml"
mode: 0755 mode: 0755
owner: root owner: root
group: root group: root
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
template: template:
args: args:
src: "{{ local_temp_addon_dir }}/dns/skydns-svc.yaml.j2" src: "{{ local_temp_addon_dir }}/dns/skydns-svc.yaml.j2"
dest: "{{ kube_config_dir }}/addons/dns/skydns-svc.yaml" dest: "{{ kube_addons_dir }}/dns/skydns-svc.yaml"
mode: 0755 mode: 0755
owner: root owner: root
group: root group: root
- name: Install PyYAML - name: Set pyyaml package name
set_fact:
pyyaml_name: python-yaml
- name: Overwrite pyyaml package name for non-Debian
set_fact:
pyyaml_name: PyYAML
when: ansible_distribution != "Debian"
- name: Install PyYAML for non-debian
action: "{{ ansible_pkg_mgr }}" action: "{{ ansible_pkg_mgr }}"
args: args:
name: PyYAML name: "{{ pyyaml_name }}"
state: latest state: latest
---
- name: KUBE-UI | Assures {{ kube_addons_dir }}/kube-ui dir exists
file: path={{ kube_addons_dir }}/kube-ui state=directory
- name: KUBE-UI | Download kube-ui files from Kubernetes repo
get_url:
url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/addons/kube-ui/{{ item }}
dest="{{ kube_addons_dir }}/kube-ui/"
force=yes
with_items:
- kube-ui-rc.yaml
- kube-ui-svc.yaml
--- ---
- name: Assures /etc/kubernetes/addons/ dir exists - name: Assures addons dir exists
file: path=/etc/kubernetes/addons/ state=directory file: path={{ kube_addons_dir }} state=directory
- include: generic-install.yml - include: generic-install.yml
when: not is_atomic when: not is_atomic
...@@ -11,6 +11,12 @@ ...@@ -11,6 +11,12 @@
state=directory state=directory
sudo: no sudo: no
- name: Make sure the system services namespace exists
get_url:
url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/saltbase/salt/kube-addons/namespace.yaml
dest="{{ kube_config_dir }}/addons/"
force=yes
- include: dns.yml - include: dns.yml
when: dns_setup when: dns_setup
...@@ -20,6 +26,9 @@ ...@@ -20,6 +26,9 @@
- include: cluster-logging.yml - include: cluster-logging.yml
when: cluster_logging when: cluster_logging
- include: kube-ui.yml
when: kube-ui
#- name: Get kube-addons script from Kubernetes #- name: Get kube-addons script from Kubernetes
# get_url: # get_url:
# url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/saltbase/salt/kube-addons/kube-addons.sh # url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/saltbase/salt/kube-addons/kube-addons.sh
......
# The port that the Kubernetes apiserver component listens on.
kube_master_api_port: 443
# This directory is where all the additional scripts go # This directory is where all the additional scripts go
# that Kubernetes normally puts in /srv/kubernetes. # that Kubernetes normally puts in /srv/kubernetes.
# This puts them in a sane location # This puts them in a sane location
......
...@@ -20,9 +20,9 @@ set -o pipefail ...@@ -20,9 +20,9 @@ set -o pipefail
# Caller should set in the ev: # Caller should set in the ev:
# MASTER_IP - this may be an ip or things like "_use_gce_external_ip_" # MASTER_IP - this may be an ip or things like "_use_gce_external_ip_"
# MASTER_NAME - DNS name for the master
# DNS_DOMAIN - which will be passed to minions in --cluster_domain # DNS_DOMAIN - which will be passed to minions in --cluster_domain
# SERVICE_CLUSTER_IP_RANGE - where all service IPs are allocated # SERVICE_CLUSTER_IP_RANGE - where all service IPs are allocated
# MASTER_NAME - I'm not sure what it is...
# Also the following will be respected # Also the following will be respected
# CERT_DIR - where to place the finished certs # CERT_DIR - where to place the finished certs
......
--- ---
- name: Install openssl for easy-rsa stuff
action: "{{ ansible_pkg_mgr }}"
args:
name: "{{ item }}"
state: latest
with_items:
- openssl
- curl
#- name: Get create ca cert script from Kubernetes #- name: Get create ca cert script from Kubernetes
# get_url: # get_url:
# url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/saltbase/salt/generate-cert/make-ca-cert.sh # url=https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes/master/cluster/saltbase/salt/generate-cert/make-ca-cert.sh
...@@ -15,12 +24,12 @@ ...@@ -15,12 +24,12 @@
# FIXME This only generates a cert for one master... # FIXME This only generates a cert for one master...
- name: Run create cert script on master - name: Run create cert script on master
command: command:
"{{ kube_script_dir }}/make-ca-cert.sh {{ inventory_hostname }}" "{{ kube_script_dir }}/make-ca-cert.sh"
args: args:
creates: "{{ kube_cert_dir }}/server.crt" creates: "{{ kube_cert_dir }}/server.crt"
environment: environment:
MASTER_IP: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}" MASTER_IP: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
MASTER_NAME: "kubernetes" MASTER_NAME: "{{ inventory_hostname }}"
DNS_DOMAIN: "{{ dns_domain }}" DNS_DOMAIN: "{{ dns_domain }}"
SERVICE_CLUSTER_IP_RANGE: "{{ kube_service_addresses }}" SERVICE_CLUSTER_IP_RANGE: "{{ kube_service_addresses }}"
CERT_DIR: "{{ kube_cert_dir }}" CERT_DIR: "{{ kube_cert_dir }}"
......
...@@ -20,4 +20,4 @@ KUBE_LOG_LEVEL="--v=0" ...@@ -20,4 +20,4 @@ KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow_privileged=true" KUBE_ALLOW_PRIV="--allow_privileged=true"
# How the replication controller, scheduler, and proxy # How the replication controller, scheduler, and proxy
KUBE_MASTER="--master=https://{{ groups['masters'][0] }}:443" KUBE_MASTER="--master=https://{{ groups['masters'][0] }}:{{ kube_master_api_port }}"
--- ---
- name: reload systemd
command: systemctl --system daemon-reload
notify:
- restart daemons
- name: restart daemons - name: restart daemons
command: /bin/true command: /bin/true
notify: notify:
......
--- ---
- name: Open firewalld port for apiserver - name: Open firewalld port for apiserver
firewalld: port=443/tcp permanent=false state=enabled firewalld: port={{ kube_master_api_port }}/tcp permanent=false state=enabled
# in case this is also a node with firewalld turned off # in case this is also a node with firewalld turned off
ignore_errors: yes ignore_errors: yes
- name: Save firewalld port for apiserver - name: Save firewalld port for apiserver
firewalld: port=443/tcp permanent=true state=enabled firewalld: port={{ kube_master_api_port }}/tcp permanent=true state=enabled
# in case this is also a node with firewalld turned off # in case this is also a node with firewalld turned off
ignore_errors: yes ignore_errors: yes
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
always_run: yes always_run: yes
- name: Open apiserver port with iptables - name: Open apiserver port with iptables
command: /sbin/iptables -I INPUT 1 -p tcp --dport 443 -j ACCEPT -m comment --comment "kube-apiserver" command: /sbin/iptables -I INPUT 1 -p tcp --dport {{ kube_master_api_port }} -j ACCEPT -m comment --comment "kube-apiserver"
when: "'kube-apiserver' not in iptablesrules.stdout" when: "'kube-apiserver' not in iptablesrules.stdout"
notify: notify:
- restart iptables - restart iptables
......
---
- name: Copy master binaries
copy:
src: ../../_output/local/go/bin/{{ item }}
dest: /usr/bin/
mode: 755
with_items:
- kube-apiserver
- kube-scheduler
- kube-controller-manager
- kubectl
notify: restart daemons
- name: Copy master service files
copy:
src: ../init/systemd/{{ item }}
dest: /etc/systemd/system/
mode: 644
with_items:
- kube-apiserver.service
- kube-scheduler.service
- kube-controller-manager.service
notify: reload systemd
- name: Copy systemd tmpfile for apiserver
copy:
src: ../init/systemd/tmpfiles.d/
dest: /etc/tmpfiles.d/
mode: 644
notify: reload systemd
--- ---
- include: generic-install.yml - include: packageManagerInstall.yml
when: not is_atomic and not ansible_distribution == "CentOS" when: source_type == "packageManager"
tags:
- binary-update
- include: centos.yml - include: localBuildInstall.yml
when: not is_atomic and ansible_distribution == "CentOS" when: source_type == "localBuild"
tags:
- binary-update
- name: write the config file for the api server - name: write the config file for the api server
template: src=apiserver.j2 dest={{ kube_config_dir }}/apiserver template: src=apiserver.j2 dest={{ kube_config_dir }}/apiserver
...@@ -21,7 +25,7 @@ ...@@ -21,7 +25,7 @@
- name: Enable apiserver - name: Enable apiserver
service: name=kube-apiserver enabled=yes state=started service: name=kube-apiserver enabled=yes state=started
- name: Get the node token values - name: Get the master token values
slurp: slurp:
src: "{{ kube_token_dir }}/{{ item }}-{{ inventory_hostname }}.token" src: "{{ kube_token_dir }}/{{ item }}-{{ inventory_hostname }}.token"
with_items: with_items:
......
---
- include: pkgMgrInstallers/centos-install.yml
when: ansible_distribution == "CentOS"
- name: Set fact saying we did CentOS package install
set_fact:
did_install: true
when: ansible_distribution == "CentOS"
- include: pkgMgrInstallers/fedora-install.yml
when: ansible_distribution == "Fedora" and ansible_distribution_release != "Rawhide"
- name: Set fact saying we did Fedora package install
set_fact:
did_install: true
when: ansible_distribution == "Fedora" and ansible_distribution_release != "Rawhide"
- include: pkgMgrInstallers/generic-install.yml
when: not did_install
--- ---
- name: CentOS | Install kubernetes master - name: CentOS | Install kubernetes master
yum: yum:
pkg=kubernetes-master pkg=kubernetes-master
state=latest state=latest
enablerepo=virt7-docker-common-candidate enablerepo=virt7-docker-common-candidate
notify: notify:
- restart daemons - restart daemons
when: not is_atomic
- name: Fedora | Install kubernetes master
action: "{{ ansible_pkg_mgr }}"
args:
name: kubernetes-master
state: latest
enablerepo: "updates-testing"
notify:
- restart daemons
when: not is_atomic
- name: Install kubernetes - name: Generic | Install kubernetes master
action: "{{ ansible_pkg_mgr }}" action: "{{ ansible_pkg_mgr }}"
args: args:
name: kubernetes-master name: kubernetes-master
state: latest state: latest
notify: notify:
- restart daemons - restart daemons
when: not is_atomic
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
KUBE_API_ADDRESS="--insecure-bind-address=127.0.0.1" KUBE_API_ADDRESS="--insecure-bind-address=127.0.0.1"
# The port on the local server to listen on. # The port on the local server to listen on.
KUBE_API_PORT="--secure-port=443" KUBE_API_PORT="--secure-port={{ kube_master_api_port }}"
# Port nodes listen on # Port nodes listen on
# KUBELET_PORT="--kubelet_port=10250" # KUBELET_PORT="--kubelet_port=10250"
......
...@@ -5,7 +5,7 @@ preferences: {} ...@@ -5,7 +5,7 @@ preferences: {}
clusters: clusters:
- cluster: - cluster:
certificate-authority: {{ kube_cert_dir }}/ca.crt certificate-authority: {{ kube_cert_dir }}/ca.crt
server: https://{{ groups['masters'][0] }}:443 server: https://{{ groups['masters'][0] }}:{{ kube_master_api_port }}
name: {{ cluster_name }} name: {{ cluster_name }}
contexts: contexts:
- context: - context:
......
...@@ -5,7 +5,7 @@ preferences: {} ...@@ -5,7 +5,7 @@ preferences: {}
clusters: clusters:
- cluster: - cluster:
certificate-authority-data: {{ kube_ca_cert|b64encode }} certificate-authority-data: {{ kube_ca_cert|b64encode }}
server: https://{{ groups['masters'][0] }}:443 server: https://{{ groups['masters'][0] }}:{{ kube_master_api_port }}
name: {{ cluster_name }} name: {{ cluster_name }}
contexts: contexts:
- context: - context:
......
...@@ -5,7 +5,7 @@ preferences: {} ...@@ -5,7 +5,7 @@ preferences: {}
clusters: clusters:
- cluster: - cluster:
certificate-authority: {{ kube_cert_dir }}/ca.crt certificate-authority: {{ kube_cert_dir }}/ca.crt
server: https://{{ groups['masters'][0] }}:443 server: https://{{ groups['masters'][0] }}:{{ kube_master_api_port }}
name: {{ cluster_name }} name: {{ cluster_name }}
contexts: contexts:
- context: - context:
......
--- ---
- name: reload systemd
command: systemctl --system daemon-reload
notify:
- restart daemons
- name: restart daemons - name: restart daemons
command: /bin/true command: /bin/true
notify: notify:
......
---
- name: Copy node binaries
copy:
src: ../../_output/local/go/bin/{{ item }}
dest: /usr/bin/
mode: 755
with_items:
- kubelet
- kube-proxy
- kubectl
notify:
- restart daemons
- name: Copy node service files
copy:
src: ../init/systemd/{{ item }}
dest: /etc/systemd/system/
mode: 644
with_items:
- kube-proxy.service
- kubelet.service
notify: reload systemd
- name: Create the /var/lib/kubelet working directory
file:
path: /var/lib/kubelet
state: directory
...@@ -3,16 +3,21 @@ ...@@ -3,16 +3,21 @@
command: getenforce command: getenforce
register: selinux register: selinux
changed_when: false changed_when: false
when: ansible_selinux
- name: Set selinux permissive because tokens and selinux don't work together - name: Set selinux permissive because tokens and selinux don't work together
selinux: state=permissive policy=targeted selinux: state=permissive policy=targeted
when: "'Enforcing' in selinux.stdout" when: ansible_selinux and 'Enforcing' in selinux.stdout
- include: generic-install.yml - include: packageManagerInstall.yml
when: not is_atomic and not ansible_distribution == "CentOS" when: source_type == "packageManager"
tags:
- binary-update
- include: centos.yml - include: localBuildInstall.yml
when: not is_atomic and ansible_distribution == "CentOS" when: source_type == "localBuild"
tags:
- binary-update
- name: Make sure manifest directory exists - name: Make sure manifest directory exists
file: path={{ kube_manifest_dir }} state=directory file: path={{ kube_manifest_dir }} state=directory
......
---
- include: pkgMgrInstallers/centos-install.yml
when: ansible_distribution == "CentOS"
- name: Set fact saying we did CentOS package install
set_fact:
did_install: true
when: ansible_distribution == "CentOS"
- include: pkgMgrInstallers/fedora-install.yml
when: ansible_distribution == "Fedora" and ansible_distribution_release != "Rawhide"
- name: Set fact saying we did Fedora package install
set_fact:
did_install: true
when: ansible_distribution == "Fedora" and ansible_distribution_release != "Rawhide"
- include: pkgMgrInstallers/generic-install.yml
when: not did_install
...@@ -6,3 +6,4 @@ ...@@ -6,3 +6,4 @@
enablerepo=virt7-docker-common-candidate enablerepo=virt7-docker-common-candidate
notify: notify:
- restart daemons - restart daemons
when: not is_atomic
- name: Fedora | Install kubernetes node
action: "{{ ansible_pkg_mgr }}"
args:
name: kubernetes-node
state: latest
enablerepo: "updates-testing"
notify:
- restart daemons
when: not is_atomic
- name: Install kubernetes - name: Generic | Install kubernetes node
action: "{{ ansible_pkg_mgr }}" action: "{{ ansible_pkg_mgr }}"
args: args:
name: kubernetes-node name: kubernetes-node
state: latest state: latest
notify: notify:
- restart daemons - restart daemons
when: not is_atomic
...@@ -11,11 +11,11 @@ KUBELET_ADDRESS="--address=0.0.0.0" ...@@ -11,11 +11,11 @@ KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_HOSTNAME="--hostname_override={{ inventory_hostname }}" KUBELET_HOSTNAME="--hostname_override={{ inventory_hostname }}"
# location of the api-server # location of the api-server
KUBELET_API_SERVER="--api_servers=https://{{ groups['masters'][0]}}:443" KUBELET_API_SERVER="--api_servers=https://{{ groups['masters'][0] }}:{{ kube_master_api_port }}"
# Add your own! # Add your own!
{% if dns_setup %} {% if dns_setup %}
KUBELET_ARGS="--cluster_dns={{ dns_server }} --cluster_domain={{ dns_domain }} --kubeconfig={{ kube_config_dir}}/kubelet.kubeconfig --config={{ kube_manifest_dir }}" KUBELET_ARGS="--cluster_dns={{ dns_server }} --cluster_domain={{ dns_domain }} --kubeconfig={{ kube_config_dir}}/kubelet.kubeconfig --config={{ kube_manifest_dir }}"
{% else %} {% else %}
KUBELET_ARGS="--kubeconfig={{ kube_config_dir}}/kubelet.kubeconfig --config={{ kube_manifest_dir }}" KUBELET_ARGS="--kubeconfig={{ kube_config_dir }}/kubelet.kubeconfig --config={{ kube_manifest_dir }}"
{% endif %} {% endif %}
...@@ -5,7 +5,7 @@ preferences: {} ...@@ -5,7 +5,7 @@ preferences: {}
clusters: clusters:
- cluster: - cluster:
certificate-authority: {{ kube_cert_dir }}/ca.crt certificate-authority: {{ kube_cert_dir }}/ca.crt
server: https://{{ groups['masters'][0] }}:443 server: https://{{ groups['masters'][0] }}:{{ kube_master_api_port }}
name: {{ cluster_name }} name: {{ cluster_name }}
contexts: contexts:
- context: - context:
......
...@@ -10,7 +10,7 @@ contexts: ...@@ -10,7 +10,7 @@ contexts:
clusters: clusters:
- cluster: - cluster:
certificate-authority: {{ kube_cert_dir }}/ca.crt certificate-authority: {{ kube_cert_dir }}/ca.crt
server: https://{{ groups['masters'][0] }}:443 server: https://{{ groups['masters'][0] }}:{{ kube_master_api_port }}
name: {{ cluster_name }} name: {{ cluster_name }}
users: users:
- name: proxy - name: proxy
......
## Vagrant deployer for Kubernetes Ansible
This deployer sets up a vagrant cluster and installs kubernetes with flannel on it.
## Before you start !
You will need a functioning vagrant provider. Currently supported are openstack, libvirt, and virtualbox.
## USAGE
In general all that should be needed it to run
```
vagrant up
```
If you export an env variable such as
```
export NUM_MINIONS=4
```
The system will create that number of nodes. Default is 2.
## Provider Specific Information
Vagrant tries to be intelligent and pick the first provider supported by your installation. If you want to specify a provider you can do so by running vagrant like so:
```
vagrant up --provider=openstack
```
### OpenStack
Make sure to install the openstack provider for vagrant.
```
vagrant plugin install vagrant-openstack-provider --plugin-version ">= 0.6.1"
```
NOTE This is a more up-to-date provider than the similar `vagrant-openstack-plugin`.
Also note that current (required) versions of `vagrant-openstack-provider` are not compatible with ruby 2.2.
https://github.com/ggiamarchi/vagrant-openstack-provider/pull/237
So make sure you get at least version 0.6.1.
To use the vagrant openstack provider you will need
- Copy `openstack_config.yml.example` to `openstack_config.yml`
- Edit `openstack_config.yml` to include your relevant details.
For vagrant (1.7.2) does not seem to ever want to pick openstack as the provider. So you will need to tell it to use openstack explicitly.
###### Libvirt
The libvirt vagrant provider is non-deterministic when launching VMs. This is a problem as we need ansible to only run after all of the VMs are running. To solve this when using libvirt one must
do the following
```
vagrant up --no-provision
vagrant provision
```
### VirtualBox
Nothing special with VirtualBox. Hopefully `vagrant up` just works.
## Random Information
If you just want to update the binaries on your systems (either pkgManager or localBuild) you can do so using the ansible binary-update tag. To do so with vagrant provision you would need to run
```
ANSIBLE_TAGS="binary-update" vagrant provision
```
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/contrib/ansible/vagrant/README.md?pixel)]()
# -*- mode: ruby -*- # -*- mode: ruby -*-
# vi: set ft=ruby : # vi: set ft=ruby :
require "yaml"
# All Vagrant configuration is done below. The "2" in Vagrant.configure ### This is a new provider, different then cloudbau's.
# configures the configuration version (we support older styles for ### RUN: vagrant plugin uninstall vagrant-openstack-plugin"
# backwards compatibility). Please don't change it unless you know what ### Then RUN: "vagrant plugin install vagrant-openstack-provider"
# you're doing. require 'vagrant-openstack-provider'
Vagrant.configure(2) do |config|
config.vm.box = "chef/centos-7.0"
# config.vm.network "public_network" $num_nodes = (ENV['NUM_NODES'] || 2).to_i
ansible_tags = ENV['ANSIBLE_TAGS']
config.vm.define "master", primary: true do |master| VAGRANTFILE_API_VERSION = "2"
master.vm.hostname = "master.vms.local"
master.vm.network "private_network", ip: "192.168.1.100" # Openstack providers are best used with latest versions.
Vagrant.require_version ">= 1.7"
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
# to use the same keypair for all the machines is to disable
# this feature and rely on the legacy insecure key.
config.ssh.insert_key = false
# This explicitly sets the order that vagrant will use by default if no --provider given
config.vm.provider "openstack"
config.vm.provider "libvirt"
config.vm.provider "virtualbox"
def set_openstack(os, config, n)
# common config
config.vm.box = "dummy"
config.vm.box_url = "https://github.com/cloudbau/vagrant-openstack-plugin/raw/master/dummy.box"
# this crap is to make it not fail if the file doesn't exist (which is ok if we are using a different provisioner)
__filename = File.join(File.dirname(__FILE__), "openstack_config.yml")
if File.exist?(__filename)
_config = YAML.load(File.open(__filename, File::RDONLY).read)
else
_config = Hash.new("")
_config['security_group'] = []
end
config.ssh.username = "fedora"
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.
os.username = _config['os_username']
os.password = _config['os_password']
os.tenant_name = _config['os_tenant']
os.keypair_name = _config['os_ssh_key_name']
os.openstack_auth_url = _config['os_auth_url']
os.region = _config['os_region_name']
os.floating_ip_pool = _config['os_floating_ip_pool']
os.flavor = _config['os_flavor']
os.image = _config['os_image']
os.security_groups = _config['os_security_groups']
os.server_name = n.vm.hostname
end end
(1..1).each do |i| def set_vbox(vb, config)
config.vm.define "node-#{i}" do |node| config.vm.box = "chef/centos-7.0"
node.vm.hostname = "node-#{i}.vms.local" config.vm.network "private_network", type: "dhcp"
node.vm.network "private_network", ip: "192.168.1.1#{i}" vb.gui = false
node.vm.provision :ansible do |ansible| vb.memory = 2048
ansible.host_key_checking = false vb.cpus = 2
ansible.extra_vars = {
ansible_ssh_user: 'vagrant', # Use faster paravirtualized networking
ansible_ssh_pass: 'vagrant', vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
user: 'vagrant' vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
} end
#ansible.verbose = 'vvv'
ansible.playbook = "../cluster.yml" def set_libvirt(lv, config)
ansible.inventory_path = "vinventory" config.vm.box = "kube-centos-7"
config.vm.box_url = "http://cloud.centos.org/centos/7/vagrant/x86_64/images/CentOS-7.LibVirt.box"
ansible.limit = 'all' lv.memory = 2048
end lv.cpus = 2
lv.nested = true
lv.volume_cache = 'none'
end
def set_provider(n)
n.vm.provider :openstack do |os, override|
set_openstack(os, override, n)
end
n.vm.provider :virtualbox do |vb, override|
set_vbox(vb, override)
end
n.vm.provider :libvirt do |lv, override|
set_libvirt(lv, override)
end end
end end
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider "virtualbox" do |vb| nodes = Array.new()
# Display the VirtualBox GUI when booting the machine $num_nodes.times do |i|
vb.gui = false # multi vm config
# Customize the amount of memory on the VM: name = "kube-node-#{i+1}"
vb.memory = "2048" nodes.push(name)
# vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] config.vm.define "#{name}" do |n|
n.vm.hostname = name
set_provider(n)
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'
# and you'll see exactly how the cluster comes up via ansible inv.
groups = {
"etcd" => ["kube-master"],
"masters" => ["kube-master"],
"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?
end
end
# This sets up both flannel and kube.
n.vm.provision :ansible do |ansible|
ansible.groups = groups
ansible.playbook = "../cluster.yml"
ansible.limit = "all" #otherwise the metadata wont be there for ipv4?
ansible.tags = ansible_tags
end
end end
end end
os_username: eparis
os_password: redhat
os_tenant: "RH US Business Group"
os_auth_url: "http://os1-public.osop.rhcloud.com:5000/v2.0"
os_region_name: "OS1Public"
os_ssh_key_name: "eparis"
os_flavor: "m1.small"
os_image: "Fedora 22 Cloud Base x86_64 (final)"
os_security_groups:
- "default"
#- some_other_group
os_floating_ip_pool: "os1_public"
os_username: eparis
os_password: password
os_tenant: "RH US Business Group"
os_auth_url: "http://os1-public.osop.rhcloud.com:5000/v2.0"
os_region_name: "OS1Public"
os_ssh_key_name: "eparis"
os_flavor: "m1.small"
os_image: "Fedora 22 Cloud Base x86_64 (final)"
os_security_groups:
- "default"
#- some_other_group
os_floating_ip_pool: "os1_public"
- hosts: all
sudo: yes
tasks:
- name: "Build hosts file"
lineinfile:
dest=/etc/hosts
regexp=".*{{ item }}$"
line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}"
state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
[masters]
192.168.1.100
[etcd]
192.168.1.100
[nodes]
192.168.1.11
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment