d0e2016592
This adds a custom ansible-lint rule at .rules/ZuulJobsNamespaceLoopVar.py that enforces the loop var policy described at: https://zuul-ci.org/docs/zuul-jobs/policy.html#ansible-loops-in-roles It also updates existing roles to follow the policy. Change-Id: I92b2ff56a1c2702542fc07b316f1809087a4c92f
86 lines
2.2 KiB
YAML
86 lines
2.2 KiB
YAML
- name: Check for Minikube install
|
|
stat:
|
|
path: /tmp/minikube
|
|
register: stat_result
|
|
|
|
- name: Download Minikube
|
|
get_url:
|
|
url: https://storage.googleapis.com/minikube/releases/{{ minikube_version }}/minikube-linux-amd64
|
|
dest: /tmp/minikube
|
|
mode: 0755
|
|
when: not stat_result.stat.exists
|
|
|
|
- name: Run ensure-docker role
|
|
include_role:
|
|
name: ensure-docker
|
|
|
|
- name: Install crio
|
|
when: kubernetes_runtime == 'cri-o'
|
|
include_tasks: crio.yaml
|
|
|
|
- name: Create .kube directory
|
|
file:
|
|
path: "{{ ansible_user_dir }}/.kube"
|
|
state: directory
|
|
mode: 0755
|
|
|
|
- name: Create .kube/config file
|
|
file:
|
|
path: "{{ ansible_user_dir }}/.kube/config"
|
|
state: touch
|
|
mode: 0644
|
|
|
|
- name: Create .minikube directory
|
|
file:
|
|
path: "{{ ansible_user_dir }}/.minikube"
|
|
state: directory
|
|
mode: 0755
|
|
|
|
- name: Default args
|
|
set_fact:
|
|
minikube_args: ""
|
|
|
|
- name: Configure dns options if set
|
|
block:
|
|
- name: Write resolv.conf
|
|
template:
|
|
src: resolv.conf.j2
|
|
dest: "{{ ansible_user_dir }}/.minikube/k8s_resolv.conf"
|
|
mode: "0444"
|
|
- name: Set extra kube setttings
|
|
set_fact:
|
|
minikube_args: "--extra-config=kubelet.resolv-conf={{ ansible_user_dir }}/.minikube/k8s_resolv.conf"
|
|
when: minikube_dns_resolvers
|
|
|
|
- name: Start Minikube
|
|
become: yes
|
|
command: "/tmp/minikube start --v=7 --vm-driver=none --container-runtime={{ kubernetes_runtime }} {{ minikube_args }}"
|
|
environment:
|
|
MINIKUBE_WANTUPDATENOTIFICATION: false
|
|
MINIKUBE_WANTREPORTERRORPROMPT: false
|
|
MINIKUBE_WANTNONEDRIVERWARNING: false
|
|
MINIKUBE_WANTKUBECTLDOWNLOADMSG: false
|
|
CHANGE_MINIKUBE_NONE_USER: true
|
|
MINIKUBE_HOME: "{{ ansible_user_dir }}"
|
|
KUBECONFIG: "{{ ansible_user_dir }}/.kube/config"
|
|
|
|
- name: Get KUBECONFIG
|
|
command: "kubectl config view"
|
|
register: kubeconfig_yaml
|
|
|
|
- name: Parse KUBECONFIG YAML
|
|
set_fact:
|
|
kube_config: "{{ kubeconfig_yaml.stdout | from_yaml }}"
|
|
|
|
- name: Ensure minikube config is owned by ansible_user
|
|
become: yes
|
|
loop: "{{ kube_config['users'] }}"
|
|
loop_control:
|
|
loop_var: zj_item
|
|
file:
|
|
path: "{{ zj_item['user']['client-key'] }}"
|
|
owner: "{{ ansible_user }}"
|
|
|
|
- name: Get cluster info
|
|
command: kubectl cluster-info
|