Avoid relying on subject environment-vars
There are so many ways/places they can change values on the host from one moment to the next. Yet as written, the value of ansible_env.GOPATH is really only fixed at "fact gathering" time. In other words, the environment variable can change (even during a play), but won't be noticed until possibly much later. This can cause very strange things to happen which aren't easy to debug. Fix this by using established facts (variables), and continuously establishing them as environment variables. This way, if/when a task fails, the value of the environment will be present w/in the failure message instead of obscrured by the shell. Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
parent
9e273538a7
commit
0e752a6423
11 changed files with 53 additions and 72 deletions
|
@ -3,12 +3,12 @@
|
||||||
- name: clone bats source repo
|
- name: clone bats source repo
|
||||||
git:
|
git:
|
||||||
repo: "https://github.com/sstephenson/bats.git"
|
repo: "https://github.com/sstephenson/bats.git"
|
||||||
dest: "{{ ansible_env.GOPATH }}/src/github.com/sstephenson/bats"
|
dest: "{{ go_path }}/src/github.com/sstephenson/bats"
|
||||||
|
|
||||||
- name: install bats
|
- name: install bats
|
||||||
command: "./install.sh /usr/local"
|
command: "./install.sh /usr/local"
|
||||||
args:
|
args:
|
||||||
chdir: "{{ ansible_env.GOPATH }}/src/github.com/sstephenson/bats"
|
chdir: "{{ go_path }}/src/github.com/sstephenson/bats"
|
||||||
|
|
||||||
- name: link bats
|
- name: link bats
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
- name: clone cri-tools source repo
|
- name: clone cri-tools source repo
|
||||||
git:
|
git:
|
||||||
repo: "https://github.com/kubernetes-incubator/cri-tools.git"
|
repo: "https://github.com/kubernetes-incubator/cri-tools.git"
|
||||||
dest: "{{ ansible_env.GOPATH }}/src/github.com/kubernetes-incubator/cri-tools"
|
dest: "{{ go_path }}/src/github.com/kubernetes-incubator/cri-tools"
|
||||||
version: "9ff5e8f78a4182ab8d5ba9bcccdda5f338600eab"
|
version: "9ff5e8f78a4182ab8d5ba9bcccdda5f338600eab"
|
||||||
|
|
||||||
- name: install crictl
|
- name: install crictl
|
||||||
|
@ -11,6 +11,6 @@
|
||||||
|
|
||||||
- name: link crictl
|
- name: link crictl
|
||||||
file:
|
file:
|
||||||
src: "{{ ansible_env.GOPATH }}/bin/crictl"
|
src: "{{ go_path }}/bin/crictl"
|
||||||
dest: /usr/bin/crictl
|
dest: /usr/bin/crictl
|
||||||
state: link
|
state: link
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
- name: clone kubernetes source repo
|
- name: clone kubernetes source repo
|
||||||
git:
|
git:
|
||||||
repo: "https://github.com/runcom/kubernetes.git"
|
repo: "https://github.com/runcom/kubernetes.git"
|
||||||
dest: "{{ ansible_env.GOPATH }}/src/k8s.io/kubernetes"
|
dest: "{{ go_path }}/src/k8s.io/kubernetes"
|
||||||
version: "cri-o-patched-1.8"
|
version: "cri-o-patched-1.8"
|
||||||
|
|
||||||
- name: install etcd
|
- name: install etcd
|
||||||
command: "hack/install-etcd.sh"
|
command: "hack/install-etcd.sh"
|
||||||
args:
|
args:
|
||||||
chdir: "{{ ansible_env.GOPATH }}/src/k8s.io/kubernetes"
|
chdir: "{{ go_path }}/src/k8s.io/kubernetes"
|
||||||
|
|
||||||
- name: build kubernetes
|
- name: build kubernetes
|
||||||
make:
|
make:
|
||||||
chdir: "{{ ansible_env.GOPATH }}/src/k8s.io/kubernetes"
|
chdir: "{{ go_path }}/src/k8s.io/kubernetes"
|
||||||
|
|
||||||
- name: Add custom cluster service file for the e2e testing
|
- name: Add custom cluster service file for the e2e testing
|
||||||
copy:
|
copy:
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory={{ ansible_env.GOPATH }}/src/k8s.io/kubernetes
|
WorkingDirectory={{ go_path }}/src/k8s.io/kubernetes
|
||||||
ExecStart=/usr/local/bin/createcluster.sh
|
ExecStart=/usr/local/bin/createcluster.sh
|
||||||
User=root
|
User=root
|
||||||
[Install]
|
[Install]
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
content: |
|
content: |
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
export PATH=/usr/local/go/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/root/bin:{{ ansible_env.GOPATH }}/bin:{{ ansible_env.GOPATH }}/src/k8s.io/kubernetes/third_party/etcd:{{ ansible_env.GOPATH }}/src/k8s.io/kubernetes/_output/local/bin/linux/amd64/
|
export PATH=/usr/local/go/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/root/bin:{{ go_path }}/bin:{{ go_path }}/src/k8s.io/kubernetes/third_party/etcd:{{ go_path }}/src/k8s.io/kubernetes/_output/local/bin/linux/amd64/
|
||||||
export CONTAINER_RUNTIME=remote
|
export CONTAINER_RUNTIME=remote
|
||||||
export CGROUP_DRIVER=systemd
|
export CGROUP_DRIVER=systemd
|
||||||
export CONTAINER_RUNTIME_ENDPOINT='/var/run/crio.sock --runtime-request-timeout=5m'
|
export CONTAINER_RUNTIME_ENDPOINT='/var/run/crio.sock --runtime-request-timeout=5m'
|
||||||
|
@ -47,17 +47,3 @@
|
||||||
export KUBE_ENABLE_CLUSTER_DNS=true
|
export KUBE_ENABLE_CLUSTER_DNS=true
|
||||||
./hack/local-up-cluster.sh
|
./hack/local-up-cluster.sh
|
||||||
mode: "u=rwx,g=rwx,o=x"
|
mode: "u=rwx,g=rwx,o=x"
|
||||||
|
|
||||||
- name: Set kubernetes_provider to be local
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/environment
|
|
||||||
line: 'KUBERNETES_PROVIDER=local'
|
|
||||||
regexp: 'KUBERNETES_PROVIDER='
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Set KUBECONFIG
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/environment
|
|
||||||
line: 'KUBECONFIG=/var/run/kubernetes/admin.kubeconfig'
|
|
||||||
regexp: 'KUBECONFIG='
|
|
||||||
state: present
|
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
- name: clone plugins source repo
|
- name: clone plugins source repo
|
||||||
git:
|
git:
|
||||||
repo: "https://github.com/containernetworking/plugins.git"
|
repo: "https://github.com/containernetworking/plugins.git"
|
||||||
dest: "{{ ansible_env.GOPATH }}/src/github.com/containernetworking/plugins"
|
dest: "{{ go_path }}/src/github.com/containernetworking/plugins"
|
||||||
version: "dcf7368eeab15e2affc6256f0bb1e84dd46a34de"
|
version: "dcf7368eeab15e2affc6256f0bb1e84dd46a34de"
|
||||||
|
|
||||||
- name: build plugins
|
- name: build plugins
|
||||||
command: "./build.sh"
|
command: "./build.sh"
|
||||||
args:
|
args:
|
||||||
chdir: "{{ ansible_env.GOPATH }}/src/github.com/containernetworking/plugins"
|
chdir: "{{ go_path }}/src/github.com/containernetworking/plugins"
|
||||||
|
|
||||||
- name: install plugins
|
- name: install plugins
|
||||||
copy:
|
copy:
|
||||||
src: "{{ ansible_env.GOPATH }}/src/github.com/containernetworking/plugins/bin/{{ item }}"
|
src: "{{ go_path }}/src/github.com/containernetworking/plugins/bin/{{ item }}"
|
||||||
dest: "/opt/cni/bin"
|
dest: "/opt/cni/bin"
|
||||||
mode: "o=rwx,g=rx,o=rx"
|
mode: "o=rwx,g=rx,o=rx"
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
|
@ -33,18 +33,18 @@
|
||||||
- name: clone runcom plugins source repo
|
- name: clone runcom plugins source repo
|
||||||
git:
|
git:
|
||||||
repo: "https://github.com/runcom/plugins.git"
|
repo: "https://github.com/runcom/plugins.git"
|
||||||
dest: "{{ ansible_env.GOPATH }}/src/github.com/containernetworking/plugins"
|
dest: "{{ go_path }}/src/github.com/containernetworking/plugins"
|
||||||
version: "custom-bridge"
|
version: "custom-bridge"
|
||||||
force: yes
|
force: yes
|
||||||
|
|
||||||
- name: build plugins
|
- name: build plugins
|
||||||
command: "./build.sh"
|
command: "./build.sh"
|
||||||
args:
|
args:
|
||||||
chdir: "{{ ansible_env.GOPATH }}/src/github.com/containernetworking/plugins"
|
chdir: "{{ go_path }}/src/github.com/containernetworking/plugins"
|
||||||
|
|
||||||
- name: install custom bridge
|
- name: install custom bridge
|
||||||
copy:
|
copy:
|
||||||
src: "{{ ansible_env.GOPATH }}/src/github.com/containernetworking/plugins/bin/bridge"
|
src: "{{ go_path }}/src/github.com/containernetworking/plugins/bin/bridge"
|
||||||
dest: "/opt/cni/bin/bridge-custom"
|
dest: "/opt/cni/bin/bridge-custom"
|
||||||
mode: "o=rwx,g=rx,o=rx"
|
mode: "o=rwx,g=rx,o=rx"
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
|
|
|
@ -3,18 +3,18 @@
|
||||||
- name: clone runc source repo
|
- name: clone runc source repo
|
||||||
git:
|
git:
|
||||||
repo: "https://github.com/opencontainers/runc.git"
|
repo: "https://github.com/opencontainers/runc.git"
|
||||||
dest: "{{ ansible_env.GOPATH }}/src/github.com/opencontainers/runc"
|
dest: "{{ go_path }}/src/github.com/opencontainers/runc"
|
||||||
version: "84a082bfef6f932de921437815355186db37aeb1"
|
version: "84a082bfef6f932de921437815355186db37aeb1"
|
||||||
|
|
||||||
- name: build runc
|
- name: build runc
|
||||||
make:
|
make:
|
||||||
params: BUILDTAGS="seccomp selinux"
|
params: BUILDTAGS="seccomp selinux"
|
||||||
chdir: "{{ ansible_env.GOPATH }}/src/github.com/opencontainers/runc"
|
chdir: "{{ go_path }}/src/github.com/opencontainers/runc"
|
||||||
|
|
||||||
- name: install runc
|
- name: install runc
|
||||||
make:
|
make:
|
||||||
target: "install"
|
target: "install"
|
||||||
chdir: "{{ ansible_env.GOPATH }}/src/github.com/opencontainers/runc"
|
chdir: "{{ go_path }}/src/github.com/opencontainers/runc"
|
||||||
|
|
||||||
- name: link runc
|
- name: link runc
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
|
|
||||||
- name: wait for the cluster to be running
|
- name: wait for the cluster to be running
|
||||||
command: "{{ ansible_env.GOPATH }}/src/k8s.io/kubernetes/_output/bin/kubectl get service kubernetes --namespace default"
|
command: "{{ go_path }}/src/k8s.io/kubernetes/_output/bin/kubectl get service kubernetes --namespace default"
|
||||||
register: kube_poll
|
register: kube_poll
|
||||||
until: kube_poll | succeeded
|
until: kube_poll | succeeded
|
||||||
retries: 100
|
retries: 100
|
||||||
|
@ -51,10 +51,7 @@
|
||||||
&> {{ artifacts }}/e2e.log
|
&> {{ artifacts }}/e2e.log
|
||||||
# Fix vim syntax hilighting: "
|
# Fix vim syntax hilighting: "
|
||||||
|
|
||||||
- name: disable SELinux
|
|
||||||
command: setenforce 0
|
|
||||||
|
|
||||||
- name: run e2e tests
|
- name: run e2e tests
|
||||||
shell: "{{ e2e_shell_cmd | regex_replace('\\s+', ' ') }}"
|
shell: "{{ e2e_shell_cmd | regex_replace('\\s+', ' ') }}"
|
||||||
args:
|
args:
|
||||||
chdir: "{{ ansible_env.GOPATH }}/src/k8s.io/kubernetes"
|
chdir: "{{ go_path }}/src/k8s.io/kubernetes"
|
||||||
|
|
|
@ -16,28 +16,16 @@
|
||||||
- gofmt
|
- gofmt
|
||||||
- godoc
|
- godoc
|
||||||
|
|
||||||
- name: ensure user profile exists
|
|
||||||
file:
|
|
||||||
path: "{{ ansible_user_dir }}/.profile"
|
|
||||||
state: touch
|
|
||||||
|
|
||||||
- name: set up PATH for Go toolchain and built binaries
|
|
||||||
lineinfile:
|
|
||||||
dest: "{{ ansible_user_dir }}/.profile"
|
|
||||||
line: 'PATH={{ ansible_env.PATH }}:{{ ansible_env.GOPATH }}/bin:/usr/local/go/bin'
|
|
||||||
regexp: '^PATH='
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: set up directories
|
- name: set up directories
|
||||||
file:
|
file:
|
||||||
path: "{{ item }}"
|
path: "{{ go_path }}/{{ item }}"
|
||||||
state: directory
|
state: directory
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ ansible_env.GOPATH }}/src/github.com/containernetworking"
|
- "src/github.com/containernetworking"
|
||||||
- "{{ ansible_env.GOPATH }}/src/github.com/kubernetes-incubator"
|
- "src/github.com/kubernetes-incubator"
|
||||||
- "{{ ansible_env.GOPATH }}/src/github.com/k8s.io"
|
- "src/github.com/k8s.io"
|
||||||
- "{{ ansible_env.GOPATH }}/src/github.com/sstephenson"
|
- "src/github.com/sstephenson"
|
||||||
- "{{ ansible_env.GOPATH }}/src/github.com/opencontainers"
|
- "src/github.com/opencontainers"
|
||||||
|
|
||||||
- name: install Go tools and dependencies
|
- name: install Go tools and dependencies
|
||||||
shell: /usr/bin/go get -u "github.com/{{ item }}"
|
shell: /usr/bin/go get -u "github.com/{{ item }}"
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
gather_facts: False # Requires low-level ansible-dependencies
|
gather_facts: False # Requires low-level ansible-dependencies
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
tags:
|
||||||
|
- setup
|
||||||
tasks:
|
tasks:
|
||||||
- name: Ensure low-level ansible-dependencies are installed
|
- name: Ensure low-level ansible-dependencies are installed
|
||||||
raw: $(type -P dnf || type -P yum) install -y python2 python2-dnf libselinux-python git rsync
|
raw: $(type -P dnf || type -P yum) install -y python2 python2-dnf libselinux-python git rsync
|
||||||
|
@ -26,6 +28,7 @@
|
||||||
- hosts: '{{ subjects | default("localhost") }}'
|
- hosts: '{{ subjects | default("localhost") }}'
|
||||||
vars_files:
|
vars_files:
|
||||||
- "{{ playbook_dir }}/vars.yml"
|
- "{{ playbook_dir }}/vars.yml"
|
||||||
|
environment: '{{ environment_variables }}'
|
||||||
tags:
|
tags:
|
||||||
- setup
|
- setup
|
||||||
tasks:
|
tasks:
|
||||||
|
@ -54,6 +57,7 @@
|
||||||
- hosts: '{{ subjects | default("localhost") }}'
|
- hosts: '{{ subjects | default("localhost") }}'
|
||||||
vars_files:
|
vars_files:
|
||||||
- "{{ playbook_dir }}/vars.yml"
|
- "{{ playbook_dir }}/vars.yml"
|
||||||
|
environment: '{{ environment_variables }}'
|
||||||
tags:
|
tags:
|
||||||
- integration
|
- integration
|
||||||
- e2e
|
- e2e
|
||||||
|
@ -64,6 +68,7 @@
|
||||||
- hosts: '{{ subjects | default("localhost") }}'
|
- hosts: '{{ subjects | default("localhost") }}'
|
||||||
vars_files:
|
vars_files:
|
||||||
- "{{ playbook_dir }}/vars.yml"
|
- "{{ playbook_dir }}/vars.yml"
|
||||||
|
environment: '{{ environment_variables }}'
|
||||||
tags:
|
tags:
|
||||||
- integration
|
- integration
|
||||||
tasks:
|
tasks:
|
||||||
|
@ -73,6 +78,7 @@
|
||||||
- hosts: '{{ subjects | default("localhost") }}'
|
- hosts: '{{ subjects | default("localhost") }}'
|
||||||
vars_files:
|
vars_files:
|
||||||
- "{{ playbook_dir }}/vars.yml"
|
- "{{ playbook_dir }}/vars.yml"
|
||||||
|
environment: '{{ environment_variables }}'
|
||||||
tags:
|
tags:
|
||||||
- e2e
|
- e2e
|
||||||
tasks:
|
tasks:
|
||||||
|
|
|
@ -116,17 +116,3 @@
|
||||||
- name: Update the kernel cmdline to include quota support
|
- name: Update the kernel cmdline to include quota support
|
||||||
command: grubby --update-kernel=ALL --args="rootflags=pquota"
|
command: grubby --update-kernel=ALL --args="rootflags=pquota"
|
||||||
when: ansible_distribution in ['RedHat', 'CentOS']
|
when: ansible_distribution in ['RedHat', 'CentOS']
|
||||||
|
|
||||||
- name: Configure the GOPATH environment variable for all users
|
|
||||||
blockinfile:
|
|
||||||
path: /etc/environment
|
|
||||||
block: "GOPATH={{ go_path }}"
|
|
||||||
create: True
|
|
||||||
follow: True
|
|
||||||
|
|
||||||
- name: Reset the ansible connection to incorporate /etc/environment changes
|
|
||||||
meta: reset_connection
|
|
||||||
|
|
||||||
- name: Refresh facts to incorporate /etc/environment changes
|
|
||||||
setup:
|
|
||||||
gather_subset: network
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
- name: Make testing output verbose so it can be converted to xunit
|
- name: Make testing output verbose so it can be converted to xunit
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "{{ ansible_env.GOPATH }}/src/k8s.io/kubernetes/hack/make-rules/test.sh"
|
dest: "{{ go_path }}/src/k8s.io/kubernetes/hack/make-rules/test.sh"
|
||||||
line: ' go test -v "${goflags[@]:+${goflags[@]}}" \'
|
line: ' go test -v "${goflags[@]:+${goflags[@]}}" \'
|
||||||
regexp: ' go test \"\$'
|
regexp: ' go test \"\$'
|
||||||
state: present
|
state: present
|
||||||
|
@ -21,8 +21,8 @@
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: run integration tests
|
- name: run integration tests
|
||||||
shell: "CGROUP_MANAGER=cgroupfs STORAGE_OPTIONS='--storage-driver=overlay{{ extra_storage_opts | default('') }}' make localintegration >& {{ artifacts }}/testout.txt"
|
shell: "make localintegration >& {{ artifacts }}/testout.txt"
|
||||||
args:
|
args:
|
||||||
chdir: "{{ ansible_env.GOPATH }}/src/github.com/kubernetes-incubator/cri-o"
|
chdir: "{{ cri_o_dest_path }}"
|
||||||
async: 5400
|
async: 5400
|
||||||
poll: 30
|
poll: 30
|
||||||
|
|
|
@ -1,5 +1,23 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
|
# Path to encode into /etc/environment on all hosts
|
||||||
|
go_path: "/go"
|
||||||
|
|
||||||
|
# Absolute path on control-host where the cri-o source exists
|
||||||
|
cri_o_src_path: "{{ playbook_dir }}/../../../"
|
||||||
|
|
||||||
|
# Absolute path on subject-host where cri-o source is expected
|
||||||
|
cri_o_dest_path: "{{ go_path }}/src/github.com/kubernetes-incubator/cri-o"
|
||||||
|
|
||||||
|
# Global environment variables to use for tasks on subject-hosts
|
||||||
|
environment_variables:
|
||||||
|
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:{{ go_path }}/bin:/usr/local/go/bin"
|
||||||
|
GOPATH: "{{ go_path }}"
|
||||||
|
KUBERNETES_PROVIDER: "local"
|
||||||
|
KUBECONFIG: "/var/run/kubernetes/admin.kubeconfig"
|
||||||
|
CGROUP_MANAGER: "cgroupfs"
|
||||||
|
STORAGE_OPTS: '--storage-driver=overlay{{ extra_storage_opts | default("") }}'
|
||||||
|
|
||||||
# For results.yml Paths use rsync 'source' conventions
|
# For results.yml Paths use rsync 'source' conventions
|
||||||
artifacts: "/tmp/artifacts" # Base-directory for collection
|
artifacts: "/tmp/artifacts" # Base-directory for collection
|
||||||
crio_integration_filepath: "{{ artifacts }}/testout.txt"
|
crio_integration_filepath: "{{ artifacts }}/testout.txt"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue