Skip to content

Commit

Permalink
Use fully qualified collection names in playbooks/
Browse files Browse the repository at this point in the history
  • Loading branch information
wbclark committed Aug 24, 2022
1 parent 41ea76d commit 5ec3a2b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 63 deletions.
12 changes: 6 additions & 6 deletions playbooks/collect_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
- role: sos_report
tasks:
- name: "Find bats files"
find:
ansible.builtin.find:
paths: "{{ bats_output_dir }}"
patterns: "*.tap"
register: bats_results

- name: "Copy bats results"
fetch:
ansible.builtin.fetch:
src: "{{ item.path }}"
dest: "{{ remote_dir }}"
with_items: "{{ bats_results.files }}"

- name: "Find smoker files"
find:
ansible.builtin.find:
paths: "{{ smoker_output_dir }}"
patterns:
- "junit.xml"
Expand All @@ -34,20 +34,20 @@
register: smoker_results

- name: "Copy smoker results"
fetch:
ansible.builtin.fetch:
src: "{{ item.path }}"
dest: "{{ remote_dir }}"
with_items: "{{ smoker_results.files }}"

- name: "Find backup files"
find:
ansible.builtin.find:
paths: "{{ backup_output_dir }}"
recurse: True
hidden: True
register: backup_results

- name: "Copy backup results"
fetch:
ansible.builtin.fetch:
src: "{{ item.path }}"
dest: "{{ remote_dir }}"
with_items: "{{ backup_results.files }}"
74 changes: 37 additions & 37 deletions playbooks/kubevirt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
- epel_repositories
tasks:
- name: disable swap
command: swapoff -a
ansible.builtin.command: swapoff -a

- name: deconfigure swap
mount:
ansible.posix.mount:
src: /swapfile
fstype: swap
path: none
state: absent

- name: modprobe br_netfilter
modprobe:
community.general.modprobe:
name: br_netfilter

- name: configure bridge iptables
sysctl:
ansible.posix.sysctl:
name: "{{ item }}"
value: 1
sysctl_file: /etc/sysctl.d/k8s.conf
Expand All @@ -37,29 +37,29 @@
- net.bridge.bridge-nf-call-iptables

- name: install needed network manager libs
yum:
ansible.builtin.yum:
name:
- NetworkManager-glib
- NetworkManager

- name: Configure bridge
nmcli:
community.general.nmcli:
state: present
type: bridge
conn_name: foreman

- name: install docker
yum:
ansible.builtin.yum:
name: docker

- name: enable docker
service:
ansible.builtin.service:
name: docker
enabled: true
state: started

- name: k8s repo
yum_repository:
ansible.builtin.yum_repository:
name: kubernetes
description: Kubernetes
baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
Expand All @@ -70,101 +70,101 @@
exclude: kube*

- name: install kubelet kubeadm kubectl
yum:
ansible.builtin.yum:
name:
- kubelet-{{ kubernetes_version }}
- kubeadm-{{ kubernetes_version }}
- kubectl-{{ kubernetes_version }}
disable_excludes: kubernetes

- name: create /etc/systemd/system/kubelet.service.d/
file:
ansible.builtin.file:
path: /etc/systemd/system/kubelet.service.d/
state: directory

- name: enable kubelet accounting
copy:
ansible.builtin.copy:
dest: /etc/systemd/system/kubelet.service.d/11-cgroups.conf
content: |
[Service]
CPUAccounting=true
MemoryAccounting=true
- name: reload systemd
systemd:
ansible.builtin.systemd:
daemon_reload: yes

- name: enable kubelet
service:
ansible.builtin.service:
name: kubelet
enabled: true
state: started

- name: init cluster
command: kubeadm init --pod-network-cidr={{ pod_network }} --apiserver-advertise-address={{ ansible_eth0['ipv4']['address'] }}
ansible.builtin.command: kubeadm init --pod-network-cidr={{ pod_network }} --apiserver-advertise-address={{ ansible_eth0['ipv4']['address'] }}
args:
creates: /etc/kubernetes/admin.conf

- name: untaint master
command: kubectl taint nodes --all node-role.kubernetes.io/master-
ansible.builtin.command: kubectl taint nodes --all node-role.kubernetes.io/master-
register: untaint_master
failed_when: false
changed_when: untaint_master.rc == 0
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

- name: deploy flannel
command: kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/{{ flannel_version }}/Documentation/kube-flannel.yml
ansible.builtin.command: kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/{{ flannel_version }}/Documentation/kube-flannel.yml
args:
creates: /etc/cni/net.d/10-flannel.conflist
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

- name: deploy network namespace
command: kubectl apply -f https://github.com/kubevirt/cluster-network-addons-operator/releases/download/{{ network_operator }}/namespace.yaml
ansible.builtin.command: kubectl apply -f https://github.com/kubevirt/cluster-network-addons-operator/releases/download/{{ network_operator }}/namespace.yaml
args:
creates: /etc/cni/net.d/multus.d/multus.kubeconfig
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

- name: deploy network crd
command: kubectl apply -f https://github.com/kubevirt/cluster-network-addons-operator/releases/download/{{ network_operator }}/network-addons-config.crd.yaml
ansible.builtin.command: kubectl apply -f https://github.com/kubevirt/cluster-network-addons-operator/releases/download/{{ network_operator }}/network-addons-config.crd.yaml
args:
creates: /etc/cni/net.d/multus.d/multus.kubeconfig
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

- name: deploy network operator
command: kubectl apply -f https://github.com/kubevirt/cluster-network-addons-operator/releases/download/{{ network_operator }}/operator.yaml
ansible.builtin.command: kubectl apply -f https://github.com/kubevirt/cluster-network-addons-operator/releases/download/{{ network_operator }}/operator.yaml
args:
creates: /etc/cni/net.d/multus.d/multus.kubeconfig
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

- name: deploy kubevirt operator
command: kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/{{ kubevirt_version }}/kubevirt-operator.yaml
ansible.builtin.command: kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/{{ kubevirt_version }}/kubevirt-operator.yaml
args:
creates: /var/lib/kubelet/device-plugins/kubevirt-tun.sock
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

- name: deploy kubevirt cr
command: kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/{{ kubevirt_version }}/kubevirt-cr.yaml
ansible.builtin.command: kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/{{ kubevirt_version }}/kubevirt-cr.yaml
args:
creates: /var/lib/kubelet/device-plugins/kubevirt-tun.sock
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

- name: check for NetworkAddonsConfig
command: kubectl get networkaddonsconfigs cluster
ansible.builtin.command: kubectl get networkaddonsconfigs cluster
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
failed_when: false
changed_when: false
register: netaddonsconfig

- name: prepare NetworkAddonsConfig file
copy:
ansible.builtin.copy:
dest: /tmp/netaddonsconfig
content: |
apiVersion: networkaddonsoperator.network.kubevirt.io/v1alpha1
Expand All @@ -179,32 +179,32 @@
when: netaddonsconfig.rc != 0

- name: create NetworkAddonsConfig
command: kubectl create -f /tmp/netaddonsconfig
ansible.builtin.command: kubectl create -f /tmp/netaddonsconfig
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
when: netaddonsconfig.rc != 0

- name: install virtctl
get_url:
ansible.builtin.get_url:
url: https://github.com/kubevirt/kubevirt/releases/download/{{ kubevirt_version }}/virtctl-{{ kubevirt_version }}-linux-amd64
dest: /usr/bin/virtctl
mode: u=rwx,g=rx,o=rx

- name: wait for the network to be ready
command: kubectl wait networkaddonsconfig cluster --for condition=Ready --timeout=300s
ansible.builtin.command: kubectl wait networkaddonsconfig cluster --for condition=Ready --timeout=300s
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

- name: check for bridge-foreman NetworkAttachmentDefinition
command: kubectl get net-attach-def bridge-foreman
ansible.builtin.command: kubectl get net-attach-def bridge-foreman
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
failed_when: false
changed_when: false
register: bridge_foreman_net_attach

- name: prepare bridge-foreman NetworkAttachmentDefinition file
copy:
ansible.builtin.copy:
dest: /tmp/bridge-foreman-net-attach-def
content: |
apiVersion: "k8s.cni.cncf.io/v1"
Expand All @@ -221,21 +221,21 @@
when: bridge_foreman_net_attach.rc != 0

- name: create bridge-foreman NetworkAttachmentDefinition
command: kubectl create -f /tmp/bridge-foreman-net-attach-def
ansible.builtin.command: kubectl create -f /tmp/bridge-foreman-net-attach-def
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
when: bridge_foreman_net_attach.rc != 0

- name: check for foreman-account ServiceAccount
command: kubectl get sa foreman-account
ansible.builtin.command: kubectl get sa foreman-account
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
failed_when: false
changed_when: false
register: foreman_service_sa

- name: prepare foreman-account ServiceAccount file
copy:
ansible.builtin.copy:
dest: /tmp/foreman-account-sa
content: |
apiVersion: v1
Expand All @@ -259,33 +259,33 @@
when: foreman_service_sa.rc != 0

- name: create foreman-account ServiceAccount
command: kubectl create -f /tmp/foreman-account-sa
ansible.builtin.command: kubectl create -f /tmp/foreman-account-sa
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
when: foreman_service_sa.rc != 0

- name: create /home/vagrant/.kube
file:
ansible.builtin.file:
path: /home/vagrant/.kube
state: directory
owner: vagrant
group: vagrant

- name: deploy kube config
copy:
ansible.builtin.copy:
src: /etc/kubernetes/admin.conf
dest: /home/vagrant/.kube/config
remote_src: yes
owner: vagrant
group: vagrant

- name: get foreman-account secret
shell: "set -o pipefail && kubectl get secrets $(kubectl get sa foreman-account -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 -d | xargs"
ansible.builtin.shell: "set -o pipefail && kubectl get secrets $(kubectl get sa foreman-account -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 -d | xargs"
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
changed_when: false
register: foreman_account_secret

- name: show foreman-account secret
debug:
ansible.builtin.debug:
msg: "{{ foreman_account_secret.stdout }}"
16 changes: 8 additions & 8 deletions playbooks/resize_disk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
become: true
tasks:
- name: Find root partition
shell: set -o pipefail && df --output=source,fstype / | tail -n 1
ansible.builtin.shell: set -o pipefail && df --output=source,fstype / | tail -n 1
register: root_partition

- name: Install cloud-utils-growpart package
package:
ansible.builtin.package:
name: cloud-utils-growpart
when: ansible_os_family == 'RedHat'

- name: Install cloud-guest-utils package
package:
ansible.builtin.package:
name: cloud-guest-utils
when: ansible_os_family == 'Debian'

- name: Install e2fsprogs package
package:
ansible.builtin.package:
name: e2fsprogs
when: '"ext4" in root_partition.stdout'

- name: Extend partition
command: growpart /dev/vda {{ root_partition.stdout.split(' ')[0].replace('/dev/vda', '') }}
ansible.builtin.command: growpart /dev/vda {{ root_partition.stdout.split(' ')[0].replace('/dev/vda', '') }}
register: growpart_output
failed_when:
- growpart_output.rc != 0
- '"NOCHANGE" not in growpart_output.stdout'

- name: Grow XFS filesystem
command: xfs_growfs -d /
ansible.builtin.command: xfs_growfs -d /
when: '"xfs" in root_partition.stdout'

- name: Grow ext4 filesystem
command: resize2fs {{ root_partition.stdout.split(' ')[0] }}
ansible.builtin.command: resize2fs {{ root_partition.stdout.split(' ')[0] }}
when: '"ext4" in root_partition.stdout'

- name: Grow btrfs filesystem
command: btrfs filesystem resize max /
ansible.builtin.command: btrfs filesystem resize max /
when: '"btrfs" in root_partition.stdout'
Loading

0 comments on commit 5ec3a2b

Please sign in to comment.