Fix ansible-lint E301 for commands fetching data (#6465)

This commit is contained in:
Maxime Guyot 2020-07-28 17:39:47 +02:00 committed by GitHub
parent 96a2b386f2
commit fe46349786
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 17 deletions

View file

@ -2,8 +2,9 @@
- name: Calico-rr | Pre-upgrade tasks - name: Calico-rr | Pre-upgrade tasks
include_tasks: pre.yml include_tasks: pre.yml
- name: Calico-rr | Fetch current node object # noqa 301 - name: Calico-rr | Fetch current node object
command: "{{ bin_dir }}/calicoctl.sh get node {{ inventory_hostname }} -ojson" command: "{{ bin_dir }}/calicoctl.sh get node {{ inventory_hostname }} -ojson"
changed_when: false
register: calico_rr_node register: calico_rr_node
until: calico_rr_node is succeeded until: calico_rr_node is succeeded
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"

View file

@ -8,8 +8,9 @@
command: ip link del dummy0 command: ip link del dummy0
when: dummy0.stat.exists when: dummy0.stat.exists
- name: reset | get remaining routes set by bird # noqa 301 - name: reset | get remaining routes set by bird
command: ip route show proto bird command: ip route show proto bird
changed_when: false
register: bird_routes register: bird_routes
- name: reset | remove remaining routes set by bird # noqa 301 - name: reset | remove remaining routes set by bird # noqa 301

View file

@ -1,6 +1,7 @@
--- ---
- name: Macvlan | Retrieve Pod Cidr # noqa 301 - name: Macvlan | Retrieve Pod Cidr
command: "{{ bin_dir }}/kubectl get nodes {{ kube_override_hostname | default(inventory_hostname) }} -o jsonpath='{.spec.podCIDR}'" command: "{{ bin_dir }}/kubectl get nodes {{ kube_override_hostname | default(inventory_hostname) }} -o jsonpath='{.spec.podCIDR}'"
changed_when: false
register: node_pod_cidr_cmd register: node_pod_cidr_cmd
delegate_to: "{{ groups['kube-master'][0] }}" delegate_to: "{{ groups['kube-master'][0] }}"
@ -8,9 +9,10 @@
set_fact: set_fact:
node_pod_cidr={{ node_pod_cidr_cmd.stdout }} node_pod_cidr={{ node_pod_cidr_cmd.stdout }}
- name: Macvlan | Retrieve default gateway network interface # noqa 301 - name: Macvlan | Retrieve default gateway network interface
become: false become: false
raw: ip -4 route list 0/0 | sed 's/.*dev \([[:alnum:]]*\).*/\1/' raw: ip -4 route list 0/0 | sed 's/.*dev \([[:alnum:]]*\).*/\1/'
changed_when: false
register: node_default_gateway_interface_cmd register: node_default_gateway_interface_cmd
- name: Macvlan | set node_default_gateway_interface - name: Macvlan | set node_default_gateway_interface

View file

@ -29,8 +29,9 @@
loop_control: loop_control:
index_var: vm_id index_var: vm_id
- name: Wait for vms to have ipaddress assigned # noqa 301 306 - name: Wait for vms to have ipaddress assigned # noqa 306
shell: "kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'" shell: "kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'"
changed_when: false
register: vm_ips register: vm_ips
loop: "{{ range(1, vm_count|int + 1, 1) | list }}" loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
loop_control: loop_control:

View file

@ -7,8 +7,9 @@
expire_days: 2 expire_days: 2
tasks: tasks:
- name: Generate uniq bucket name prefix # noqa 301 - name: Generate uniq bucket name prefix
raw: date +%Y%m%d raw: date +%Y%m%d
changed_when: false
register: out register: out
- name: replace_test_id - name: replace_test_id

View file

@ -15,16 +15,18 @@
- import_role: - import_role:
name: cluster-dump name: cluster-dump
- name: Check kubectl output # noqa 301 305 - name: Check kubectl output # noqa 305
shell: "{{ bin_dir }}/kubectl get nodes" shell: "{{ bin_dir }}/kubectl get nodes"
changed_when: false
register: get_nodes register: get_nodes
no_log: true no_log: true
- debug: - debug:
msg: "{{ get_nodes.stdout.split('\n') }}" msg: "{{ get_nodes.stdout.split('\n') }}"
- name: Check that all nodes are running and ready # noqa 301 305 - name: Check that all nodes are running and ready # noqa 305
shell: "{{ bin_dir }}/kubectl get nodes --no-headers -o yaml" shell: "{{ bin_dir }}/kubectl get nodes --no-headers -o yaml"
changed_when: false
register: get_nodes_yaml register: get_nodes_yaml
until: until:
# Check that all nodes are Status=Ready # Check that all nodes are Status=Ready

View file

@ -15,16 +15,18 @@
- import_role: - import_role:
name: cluster-dump name: cluster-dump
- name: Check kubectl output # noqa 301 305 - name: Check kubectl output # noqa 305
shell: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide" shell: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
changed_when: false
register: get_pods register: get_pods
no_log: true no_log: true
- debug: - debug:
msg: "{{ get_pods.stdout.split('\n') }}" msg: "{{ get_pods.stdout.split('\n') }}"
- name: Check that all pods are running and ready # noqa 301 305 - name: Check that all pods are running and ready # noqa 305
shell: "{{ bin_dir }}/kubectl get pods --all-namespaces --no-headers -o yaml" shell: "{{ bin_dir }}/kubectl get pods --all-namespaces --no-headers -o yaml"
changed_when: false
register: run_pods_log register: run_pods_log
until: until:
# Check that all pods are running # Check that all pods are running
@ -36,8 +38,9 @@
failed_when: false failed_when: false
no_log: true no_log: true
- name: Check kubectl output # noqa 301 305 - name: Check kubectl output # noqa 305
shell: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide" shell: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
changed_when: false
register: get_pods register: get_pods
no_log: true no_log: true

View file

@ -18,8 +18,9 @@
- name: Create test namespace # noqa 301 305 - name: Create test namespace # noqa 301 305
shell: "{{ bin_dir }}/kubectl create namespace test" shell: "{{ bin_dir }}/kubectl create namespace test"
- name: Run 2 busybox pods in test ns # noqa 301 305 - name: Run 2 busybox pods in test ns # noqa 305
shell: "{{ bin_dir }}/kubectl run {{ item }} --image={{ test_image_repo }}:{{ test_image_tag }} --namespace test --command -- tail -f /dev/null" shell: "{{ bin_dir }}/kubectl run {{ item }} --image={{ test_image_repo }}:{{ test_image_tag }} --namespace test --command -- tail -f /dev/null"
changed_when: false
loop: loop:
- busybox1 - busybox1
- busybox2 - busybox2
@ -27,8 +28,9 @@
- import_role: - import_role:
name: cluster-dump name: cluster-dump
- name: Check that all pods are running and ready # noqa 301 305 - name: Check that all pods are running and ready # noqa 305
shell: "{{ bin_dir }}/kubectl get pods --namespace test --no-headers -o yaml" shell: "{{ bin_dir }}/kubectl get pods --namespace test --no-headers -o yaml"
changed_when: false
register: run_pods_log register: run_pods_log
until: until:
# Check that all pods are running # Check that all pods are running
@ -40,8 +42,9 @@
failed_when: false failed_when: false
no_log: true no_log: true
- name: Get pod names # noqa 301 305 - name: Get pod names # noqa 305
shell: "{{ bin_dir }}/kubectl get pods -n test -o json" shell: "{{ bin_dir }}/kubectl get pods -n test -o json"
changed_when: false
register: pods register: pods
no_log: true no_log: true
@ -49,20 +52,23 @@
msg: "{{ pods.stdout.split('\n') }}" msg: "{{ pods.stdout.split('\n') }}"
failed_when: not run_pods_log is success failed_when: not run_pods_log is success
- name: Get hostnet pods # noqa 301 - name: Get hostnet pods
command: "{{ bin_dir }}/kubectl get pods -n test -o command: "{{ bin_dir }}/kubectl get pods -n test -o
jsonpath='{range .items[?(.spec.hostNetwork)]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'" jsonpath='{range .items[?(.spec.hostNetwork)]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'"
changed_when: false
register: hostnet_pods register: hostnet_pods
no_log: true no_log: true
- name: Get running pods # noqa 301 - name: Get running pods
command: "{{ bin_dir }}/kubectl get pods -n test -o command: "{{ bin_dir }}/kubectl get pods -n test -o
jsonpath='{range .items[?(.status.phase==\"Running\")]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'" jsonpath='{range .items[?(.status.phase==\"Running\")]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'"
changed_when: False
register: running_pods register: running_pods
no_log: true no_log: true
- name: Check kubectl output # noqa 301 305 - name: Check kubectl output # noqa 305
shell: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide" shell: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
changed_when: False
register: get_pods register: get_pods
no_log: true no_log: true