Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use command to gather host distribution, kernel version facts #549

Merged
merged 1 commit into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions ansible/roles/vm_set/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,29 @@

# Need latest ubuntu 4.10 kernel to fix a openvswitch bug
# https://bugs.launchpad.net/ubuntu/+source/kernel-package/+bug/1685742
- name: get host distribution
shell: grep ^NAME /etc/os-release | awk -F '=' '{print $2}' | tr -d '"'
register: host_distribution

- name: get host distribution version
shell: grep ^VERSION_ID /etc/os-release | awk -F '=' '{print $2}' | tr -d '"'
register: host_distribution_version

- name: get host kernel version
shell: uname -r
register: host_kernel

- name: Check if kernel upgrade needed
set_fact:
kernel_upgrade_needed: true
when:
- ansible_distribution == "Ubuntu"
- ansible_distribution_version == "17.04"
- ansible_kernel.find('4.10.0') != -1
- "{{ ansible_kernel | regex_replace('4.10.0-([0-9]+)-.*', '\\1') | int < 25 }}"
- host_distribution.stdout == "Ubuntu"
- host_distribution_version.stdout == "17.04"
- host_kernel.find('4.10.0') != -1
- "{{ host_kernel | regex_replace('4.10.0-([0-9]+)-.*', '\\1') | int < 25 }}"

- block:
- debug: msg="{{ ansible_kernel }}"
- debug: msg="{{ host_kernel }}"

- name: Upgrade kernel package
apt: pkg={{ item }} state=latest
Expand All @@ -44,14 +56,14 @@
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable
state: present
become: yes
when: ansible_distribution_version == "17.04"
when: host_distribution_version == "17.04"

- name: Add docker repository for 16.04
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
state: present
become: yes
when: ansible_distribution_version == "16.04"
when: host_distribution_version == "16.04"

- name: Install necessary packages
apt: pkg={{ item }} update_cache=yes cache_valid_time=86400
Expand Down
1 change: 1 addition & 0 deletions ansible/testbed_add_vm_topology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# -e ptf_imagename=docker-ptf - name of a docker-image which will be used for the ptf docker container

- hosts: servers:&vm_host
gather_facts: no
vars_files:
- vars/docker_registry.yml
pre_tasks:
Expand Down
1 change: 1 addition & 0 deletions ansible/testbed_remove_vm_topology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# -e ptf_imagename=docker-ptf - name of a docker-image which will be used for the ptf docker container

- hosts: servers:&vm_host
gather_facts: no
vars_files:
- vars/docker_registry.yml
pre_tasks:
Expand Down
1 change: 1 addition & 0 deletions ansible/testbed_renumber_vm_topology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# -e ptf_imagename=docker-ptf - name of a docker-image which will be used for the ptf docker container

- hosts: servers:&vm_host
gatheer_facts: no
vars_files:
- vars/docker_registry.yml
pre_tasks:
Expand Down
1 change: 1 addition & 0 deletions ansible/testbed_start_VMs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#

- hosts: servers:&vm_host
gather_facts: no
vars_files:
- vars/azure_storage.yml
tasks:
Expand Down
1 change: 1 addition & 0 deletions ansible/testbed_stop_VMs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
#

- hosts: servers:&vm_host
gather_facts: no
roles:
- { role: vm_set, action: 'stop' }