Skip to content

Instantly share code, notes, and snippets.

@flrichar
Last active August 11, 2021 15:17
Show Gist options
  • Select an option

  • Save flrichar/e1fb0fe36f6a41766b00787a8eaac924 to your computer and use it in GitHub Desktop.

Select an option

Save flrichar/e1fb0fe36f6a41766b00787a8eaac924 to your computer and use it in GitHub Desktop.
### lab has two node groups, leap152 & bionics
### fetch/install calicoctl of specific version on all nodes
---
- hosts: bionics,leap152
become: yes
vars_files:
- ~/YAML/vars/become.yaml
vars:
calctlver: 3.17.2
tasks:
- name: install calicoctl {{ calctlver }}
ansible.builtin.get_url:
url: https://github.com/projectcalico/calicoctl/releases/download/v{{ calctlver }}/calicoctl
dest: /usr/local/bin
mode: '0755'
### one-liner ad-hoc to run calicoctl node status on all nodes
ansible -b -e '@~/YAML/vars/become.yml' -a '/usr/local/bin/calicoctl node status' leap152,bionics
### dump diags to /tmp , find and fetch
---
- hosts: leap152,bioncs
become: true
vars_files: ~/YAML/vars/become.yml
vars:
today: "{{ lookup('pipe', 'date +%Y_%m%d') }}"
cluster_home: "/home/User/rancher/custom/geexology/fred-pool"
tasks:
# instert check here for if node-diags is requested or previously run
- name: find calicoctl tmp/ node-diags files
ansible.builtin.command: 'find /tmp/ -iname diags-*.tar.gz'
register: files_to_fetch
- name: fetch calicoctl tmp/ node-diags files
ansible.builtin.fetch:
src: "{{ item }}"
dest: "{{ cluster_home }}/diags-{{ today }}/"
with_items: '{{ files_to_fetch.stdout }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment