Skip to content

Commit

Permalink
Fix Ansible-lint error [E502] (kubernetes-sigs#4743)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusTeufelberger authored and k8s-ci-robot committed May 16, 2019
1 parent 13f225e commit 73c2ff1
Show file tree
Hide file tree
Showing 30 changed files with 160 additions and 70 deletions.
1 change: 0 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ skip_list:
- '305'
- '306'
- '404'
- '502'
- '503'
- '701'
3 changes: 2 additions & 1 deletion contrib/azurerm/roles/generate-inventory/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
command: azure vm list-ip-address --json {{ azure_resource_group }}
register: vm_list_cmd

- set_fact:
- name: Set vm_list
set_fact:
vm_list: "{{ vm_list_cmd.stdout }}"

- name: Generate inventory
Expand Down
3 changes: 2 additions & 1 deletion contrib/azurerm/roles/generate-inventory_2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
command: az vm list -o json --resource-group {{ azure_resource_group }}
register: vm_list_cmd

- set_fact:
- name: Set VM IP and roles lists
set_fact:
vm_ip_list: "{{ vm_ip_list_cmd.stdout }}"
vm_roles_list: "{{ vm_list_cmd.stdout }}"

Expand Down
9 changes: 6 additions & 3 deletions contrib/azurerm/roles/generate-templates/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
- set_fact:
- name: Set base_dir
set_fact:
base_dir: "{{ playbook_dir }}/.generated/"

- file:
- name: Create base_dir
file:
path: "{{ base_dir }}"
state: directory
recurse: true

- template:
- name: Store json files in base_dir
template:
src: "{{ item }}"
dest: "{{ base_dir }}/{{ item }}"
with_items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
register: "initial_heketi_state"
changed_when: false
command: "{{ bin_dir }}/kubectl get services,deployments,pods --selector=deploy-heketi --output=json"

- name: "Bootstrap heketi."
when:
- "(initial_heketi_state.stdout|from_json|json_query(\"items[?kind=='Service']\"))|length == 0"
Expand All @@ -16,15 +17,20 @@
register: "initial_heketi_pod"
command: "{{ bin_dir }}/kubectl get pods --selector=deploy-heketi=pod,glusterfs=heketi-pod,name=deploy-heketi --output=json"
changed_when: false

- name: "Ensure heketi bootstrap pod is up."
assert:
that: "(initial_heketi_pod.stdout|from_json|json_query('items[*]'))|length == 1"
- set_fact:

- name: Store the initial heketi pod name
set_fact:
initial_heketi_pod_name: "{{ initial_heketi_pod.stdout|from_json|json_query(\"items[*].metadata.name|[0]\") }}"

- name: "Test heketi topology."
changed_when: false
register: "heketi_topology"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli --user admin --secret {{ heketi_admin_key }} topology info --json"

- name: "Load heketi topology."
when: "heketi_topology.stdout|from_json|json_query(\"clusters[*].nodes[*]\")|flatten|length == 0"
include_tasks: "bootstrap/topology.yml"
Expand All @@ -42,6 +48,7 @@
command: "{{ bin_dir }}/kubectl get secrets,endpoints,services,jobs --output=json"
changed_when: false
register: "heketi_storage_state"

# ensure endpoints actually exist before trying to move database data to it
- name: "Create heketi storage."
include_tasks: "bootstrap/storage.yml"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
---
- register: "label_present"
- name: Get storage nodes
register: "label_present"
command: "{{ bin_dir }}/kubectl get node --selector=storagenode=glusterfs,kubernetes.io/hostname={{ node }} --ignore-not-found=true"
changed_when: false

- name: "Assign storage label"
when: "label_present.stdout_lines|length == 0"
command: "{{ bin_dir }}/kubectl label node {{ node }} storagenode=glusterfs"
- register: "label_present"

- name: Get storage nodes again
register: "label_present"
command: "{{ bin_dir }}/kubectl get node --selector=storagenode=glusterfs,kubernetes.io/hostname={{ node }} --ignore-not-found=true"
changed_when: false
- assert: { that: "label_present|length > 0", msg: "Node {{ node }} has not been assigned with label storagenode=glusterfs." }

- name: Ensure the label has been set
assert:
that: "label_present|length > 0"
msg: "Node {{ node }} has not been assigned with label storagenode=glusterfs."
13 changes: 10 additions & 3 deletions contrib/network-storage/heketi/roles/provision/tasks/heketi.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
---
- name: "Kubernetes Apps | Lay Down Heketi"
become: true
template: { src: "heketi-deployment.json.j2", dest: "{{ kube_config_dir }}/heketi-deployment.json" }
template:
src: "heketi-deployment.json.j2"
dest: "{{ kube_config_dir }}/heketi-deployment.json"
register: "rendering"

- name: "Kubernetes Apps | Install and configure Heketi"
kube:
name: "GlusterFS"
kubectl: "{{ bin_dir }}/kubectl"
filename: "{{ kube_config_dir }}/heketi-deployment.json"
state: "{{ rendering.changed | ternary('latest', 'present') }}"

- name: "Ensure heketi is up and running."
changed_when: false
register: "heketi_state"
vars:
heketi_state: { stdout: "{}" }
heketi_state:
stdout: "{}"
pods_query: "items[?kind=='Pod'].status.conditions|[0][?type=='Ready'].status|[0]"
deployments_query: "items[?kind=='Deployment'].status.conditions|[0][?type=='Available'].status|[0]"
command: "{{ bin_dir }}/kubectl get deployments,pods --selector=glusterfs --output=json"
Expand All @@ -22,5 +27,7 @@
- "heketi_state.stdout|from_json|json_query(deployments_query) == 'True'"
retries: 60
delay: 5
- set_fact:

- name: Set the Heketi pod name
set_fact:
heketi_pod_name: "{{ heketi_state.stdout|from_json|json_query(\"items[?kind=='Pod'].metadata.name|[0]\") }}"
25 changes: 19 additions & 6 deletions contrib/network-storage/heketi/roles/provision/tasks/secret.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
---
- register: "clusterrolebinding_state"
- name: Get clusterrolebindings
register: "clusterrolebinding_state"
command: "{{ bin_dir }}/kubectl get clusterrolebinding heketi-gluster-admin -o=name --ignore-not-found=true"
changed_when: false

- name: "Kubernetes Apps | Deploy cluster role binding."
when: "clusterrolebinding_state.stdout == \"\""
command: "{{ bin_dir }}/kubectl create clusterrolebinding heketi-gluster-admin --clusterrole=edit --serviceaccount=default:heketi-service-account"
- register: "clusterrolebinding_state"

- name: Get clusterrolebindings again
register: "clusterrolebinding_state"
command: "{{ bin_dir }}/kubectl get clusterrolebinding heketi-gluster-admin -o=name --ignore-not-found=true"
changed_when: false
- assert:

- name: Make sure that clusterrolebindings are present now
assert:
that: "clusterrolebinding_state.stdout != \"\""
msg: "Cluster role binding is not present."

- register: "secret_state"
- name: Get the heketi-config-secret secret
register: "secret_state"
command: "{{ bin_dir }}/kubectl get secret heketi-config-secret -o=name --ignore-not-found=true"
changed_when: false

- name: "Render Heketi secret configuration."
become: true
template:
src: "heketi.json.j2"
dest: "{{ kube_config_dir }}/heketi.json"

- name: "Deploy Heketi config secret"
when: "secret_state.stdout == \"\""
command: "{{ bin_dir }}/kubectl create secret generic heketi-config-secret --from-file={{ kube_config_dir }}/heketi.json"
- register: "secret_state"

- name: Get the heketi-config-secret secret again
register: "secret_state"
command: "{{ bin_dir }}/kubectl get secret heketi-config-secret -o=name --ignore-not-found=true"
changed_when: false
- assert:

- name: Make sure the heketi-config-secret secret exists now
assert:
that: "secret_state.stdout != \"\""
msg: "Heketi config secret is not present."
6 changes: 4 additions & 2 deletions roles/bastion-ssh-config/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
- set_fact:
- name: set bastion host IP
set_fact:
bastion_ip: "{{ hostvars[groups['bastion'][0]]['ansible_host'] | d(hostvars[groups['bastion'][0]]['ansible_ssh_host']) }}"
delegate_to: localhost

# As we are actually running on localhost, the ansible_ssh_user is your local user when you try to use it directly
# To figure out the real ssh user, we delegate this task to the bastion and store the ansible_user in real_user
- set_fact:
- name: Store the current ansible_user in the real_user fact
set_fact:
real_user: "{{ ansible_user }}"

- name: create ssh bastion conf
Expand Down
3 changes: 2 additions & 1 deletion roles/container-engine/docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
path: /run/ostree-booted
register: ostree

- set_fact:
- name: set is_atomic
set_fact:
is_atomic: "{{ ostree.stat.exists }}"

- name: gather os specific variables
Expand Down
6 changes: 4 additions & 2 deletions roles/download/tasks/kubeadm_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
when: download_run_once
changed_when: false

- vars:
- name: container_download | extract container names from list of kubeadm config images
vars:
kubeadm_images_list: "{{ result.stdout_lines }}"
set_fact:
kubeadm_image:
Expand All @@ -66,7 +67,8 @@
when: download_run_once
register: result_images

- set_fact:
- name: container_download | set kubeadm_images
set_fact:
kubeadm_images: "{{ result_images.results | map(attribute='ansible_facts.kubeadm_image') | list | items2dict }}"
run_once: true
when: download_run_once
3 changes: 2 additions & 1 deletion roles/download/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- not skip_downloads|default(false)
- inventory_hostname in groups['kube-master']

- set_fact:
- name: Set kubeadm_images
set_fact:
kubeadm_images: {}
when:
- kubeadm_images is not defined
Expand Down
9 changes: 6 additions & 3 deletions roles/download/tasks/set_docker_image_facts.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
- set_fact:
- name: Set if containers should be pulled by digest
set_fact:
pull_by_digest: >-
{%- if download.sha256 is defined and download.sha256 -%}true{%- else -%}false{%- endif -%}
- set_fact:
- name: Set pull_args
set_fact:
pull_args: >-
{%- if pull_by_digest %}{{ download.repo }}@sha256:{{ download.sha256 }}{%- else -%}{{ download.repo }}:{{ download.tag }}{%- endif -%}
Expand All @@ -19,7 +21,8 @@
- not download_always_pull
- group_names | intersect(download.groups) | length

- set_fact:
- name: Set if pull is required per container
set_fact:
pull_required: >-
{%- if pull_args in docker_images.stdout.split(',') %}false{%- else -%}true{%- endif -%}
when:
Expand Down
4 changes: 2 additions & 2 deletions roles/download/tasks/sync_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
tags:
- facts

- set_fact:
- name: container_download | Set file name of container tarballs
set_fact:
fname: "{{ local_release_dir }}/containers/{{ download.repo|regex_replace('/|\0|:', '_') }}:{{ download.tag|default(download.sha256)|regex_replace('/|\0|:', '_') }}.tar"
run_once: true
when:
- download.enabled
- download.container
- download_run_once

tags:
- facts

Expand Down
3 changes: 2 additions & 1 deletion roles/etcd/tasks/gen_certs_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
loop_control:
label: "{{ item.item }}"

- set_fact:
- name: Gen_certs | Set cert names per node
set_fact:
my_etcd_node_certs: ['ca.pem',
'node-{{ inventory_hostname }}.pem',
'node-{{ inventory_hostname }}-key.pem']
Expand Down
3 changes: 2 additions & 1 deletion roles/etcd/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- set_fact:
- name: set architecture_groups
set_fact:
architecture_groups:
x86_64: amd64
aarch64: arm64
Expand Down
3 changes: 2 additions & 1 deletion roles/kubernetes-apps/helm/tasks/gen_helm_tiller_certs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
delegate_to: "{{ groups['kube-master'][0] }}"
command: "{{ helm_script_dir }}/helm-make-ssl.sh -e {{ helm_home_dir }} -d {{ helm_tiller_cert_dir }}"

- set_fact:
- name: Check_helm_client_certs | Set helm_client_certs
set_fact:
helm_client_certs: ['ca.pem', 'cert.pem', 'key.pem']

- name: "Check_helm_client_certs | check if a cert already exists on master node"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
run_once: true
changed_when: false

- set_fact:
- name: Contiv | Set contiv_global_config
set_fact:
contiv_global_config: "{{ (global_config.stdout|from_json)[0] }}"

- name: Contiv | Set global forwarding mode
Expand Down
3 changes: 2 additions & 1 deletion roles/kubernetes/node/tasks/facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
register: docker_cgroup_driver_result
changed_when: false

- set_fact:
- name: set facts
set_fact:
standalone_kubelet: >-
{%- if inventory_hostname in groups['kube-master'] and inventory_hostname not in groups['kube-node'] -%}true{%- else -%}false{%- endif -%}
kubelet_cgroup_driver_detected: "{{ docker_cgroup_driver_result.stdout }}"
Expand Down
14 changes: 8 additions & 6 deletions roles/kubernetes/preinstall/tasks/0040-set_facts.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- set_fact:
- name: set architecture_groups
set_fact:
architecture_groups:
x86_64: amd64
aarch64: arm64
Expand All @@ -25,10 +26,12 @@
path: /run/ostree-booted
register: ostree

- set_fact:
- name: set is_atomic
set_fact:
is_atomic: "{{ ostree.stat.exists }}"

- set_fact:
- name: set kube_cert_group on atomic hosts
set_fact:
kube_cert_group: "kube"
when: is_atomic

Expand All @@ -39,11 +42,10 @@
changed_when: false
check_mode: no

- set_fact:
- name: set dns facts
set_fact:
resolvconf: >-
{%- if resolvconf.rc == 0 -%}true{%- else -%}false{%- endif -%}
- set_fact:
bogus_domains: |-
{% for d in [ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([]) -%}
{{ dns_domain }}.{{ d }}./{{ d }}.{{ d }}./com.{{ d }}./
Expand Down
3 changes: 2 additions & 1 deletion roles/network_plugin/contiv/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
- {name: contiv-netplugin, file: contiv-netplugin.yml, type: daemonset}
when: inventory_hostname in groups['kube-master']

- set_fact:
- name: Contiv | Add another manifest if contiv_enable_api_proxy is true
set_fact:
contiv_manifests: |-
{% set _ = contiv_manifests.append({"name": "contiv-api-proxy", "file": "contiv-api-proxy.yml", "type": "daemonset"}) %}
{{ contiv_manifests }}
Expand Down
3 changes: 2 additions & 1 deletion roles/upgrade/pre-upgrade/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
failed_when: false
changed_when: false

- set_fact:
- name: Set if node needs cordoning
set_fact:
needs_cordoning: >-
{% if kubectl_node_ready.stdout == "True" and not kubectl_node_schedulable.stdout -%}
true
Expand Down
Loading

0 comments on commit 73c2ff1

Please sign in to comment.