From 3a14297dca576dd7e2c9f09d84bf0f5cf58c1938 Mon Sep 17 00:00:00 2001 From: Peter Mikus Date: Sat, 19 May 2018 15:15:29 +0200 Subject: CSIT-1070 Update Ansible structure Change-Id: I9adab174f0c15f4c05a93f61b17714fa6542ea5d Signed-off-by: Peter Mikus --- .../ansible/roles/common/files/apt-sources.list | 61 ++++++++++++++++++++++ .../testbed-setup/ansible/roles/common/files/grub | 34 ++++++++++++ .../ansible/roles/common/handlers/main.yaml | 6 +++ .../ansible/roles/common/handlers/reboot.yaml | 14 +++++ .../ansible/roles/common/tasks/main.yaml | 46 ++++++++++++++++ .../ansible/roles/common/tasks/ubuntu_x86_64.yaml | 50 ++++++++++++++++++ 6 files changed, 211 insertions(+) create mode 100644 resources/tools/testbed-setup/ansible/roles/common/files/apt-sources.list create mode 100644 resources/tools/testbed-setup/ansible/roles/common/files/grub create mode 100644 resources/tools/testbed-setup/ansible/roles/common/handlers/main.yaml create mode 100644 resources/tools/testbed-setup/ansible/roles/common/handlers/reboot.yaml create mode 100644 resources/tools/testbed-setup/ansible/roles/common/tasks/main.yaml create mode 100644 resources/tools/testbed-setup/ansible/roles/common/tasks/ubuntu_x86_64.yaml (limited to 'resources/tools/testbed-setup/ansible/roles/common') diff --git a/resources/tools/testbed-setup/ansible/roles/common/files/apt-sources.list b/resources/tools/testbed-setup/ansible/roles/common/files/apt-sources.list new file mode 100644 index 0000000000..e8ccadfc64 --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/common/files/apt-sources.list @@ -0,0 +1,61 @@ +# deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted + +# deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted +# deb http://security.ubuntu.com/ubuntu bionic-security main restricted + +# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to +# newer versions of the distribution. +deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted +deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted + +## Major bug fix updates produced after the final release of the +## distribution. +deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted +deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team. Also, please note that software in universe WILL NOT receive any +## review or updates from the Ubuntu security team. +deb http://us.archive.ubuntu.com/ubuntu/ bionic universe +deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe +deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe +deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## multiverse WILL NOT receive any review or updates from the Ubuntu +## security team. +deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse +deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse +deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse +deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse + +## N.B. software from this repository may not have been tested as +## extensively as that contained in the main release, although it includes +## newer versions of some applications which may provide useful features. +## Also, please note that software in backports WILL NOT receive any review +## or updates from the Ubuntu security team. +deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse +deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse + +deb http://security.ubuntu.com/ubuntu bionic-security main restricted +deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted +deb http://security.ubuntu.com/ubuntu bionic-security universe +deb-src http://security.ubuntu.com/ubuntu bionic-security universe +deb http://security.ubuntu.com/ubuntu bionic-security multiverse +deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse + +## Uncomment the following two lines to add software from Canonical's +## 'partner' repository. +## This software is not part of Ubuntu, but is offered by Canonical and the +## respective vendors as a service to Ubuntu users. +# deb http://archive.canonical.com/ubuntu bionic partner +# deb-src http://archive.canonical.com/ubuntu bionic partner + +## Uncomment the following two lines to add software from Ubuntu's +## 'extras' repository. +## This software is not part of Ubuntu, but is offered by third-party +## developers who want to ship their latest software. +# deb http://extras.ubuntu.com/ubuntu bionic main +# deb-src http://extras.ubuntu.com/ubuntu bionic main diff --git a/resources/tools/testbed-setup/ansible/roles/common/files/grub b/resources/tools/testbed-setup/ansible/roles/common/files/grub new file mode 100644 index 0000000000..d4e27b3f0f --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/common/files/grub @@ -0,0 +1,34 @@ +# If you change this file, run 'update-grub' afterwards to update +# /boot/grub/grub.cfg. +# For full documentation of the options in this file, see: +# info -f grub -n 'Simple configuration' + +GRUB_DEFAULT=0 +GRUB_TIMEOUT=10 +GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` +GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8" +GRUB_CMDLINE_LINUX="" + +# Uncomment to enable BadRAM filtering, modify to suit your needs +# This works with Linux (no patch required) and with any kernel that obtains +# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) +#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" + +# Uncomment to disable graphical terminal (grub-pc only) +#GRUB_TERMINAL=console +GRUB_TERMINAL=serial +GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1" + +# The resolution used on graphical terminal +# note that you can use only modes which your graphic card supports via VBE +# you can see them in real GRUB with the command `vbeinfo' +#GRUB_GFXMODE=640x480 + +# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux +#GRUB_DISABLE_LINUX_UUID=true + +# Uncomment to disable generation of recovery mode menu entries +#GRUB_DISABLE_RECOVERY="true" + +# Uncomment to get a beep at grub start +#GRUB_INIT_TUNE="480 440 1" diff --git a/resources/tools/testbed-setup/ansible/roles/common/handlers/main.yaml b/resources/tools/testbed-setup/ansible/roles/common/handlers/main.yaml new file mode 100644 index 0000000000..bdcf6832f4 --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/common/handlers/main.yaml @@ -0,0 +1,6 @@ +--- +# file: roles/common/handlers/main.yaml + +- name: Update GRUB + command: update-grub + tags: update-grub diff --git a/resources/tools/testbed-setup/ansible/roles/common/handlers/reboot.yaml b/resources/tools/testbed-setup/ansible/roles/common/handlers/reboot.yaml new file mode 100644 index 0000000000..01e1eb1b6b --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/common/handlers/reboot.yaml @@ -0,0 +1,14 @@ +--- +# file roles/common/handlers/reboot.yaml + +- name: Reboot host + command: shutdown -r now "Ansible updates triggered" + async: 0 + poll: 0 + ignore_errors: true + tags: reboot-host + +- name: Waiting for server to come back + local_action: wait_for host={{ inventory_hostname }} + state=started + tags: reboot-host diff --git a/resources/tools/testbed-setup/ansible/roles/common/tasks/main.yaml b/resources/tools/testbed-setup/ansible/roles/common/tasks/main.yaml new file mode 100644 index 0000000000..e16a6a7356 --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/common/tasks/main.yaml @@ -0,0 +1,46 @@ +--- +# file: roles/common/tasks/main.yaml + +- name: Ubuntu specific + import_tasks: ubuntu_x86_64.yaml + when: ansible_distribution|lower == 'ubuntu' and ansible_machine == 'x86_64' + +- name: Set hostname + hostname: + name: '{{ hostname }}' + tags: set-hostname + +- name: Ensure hostname is in /etc/hosts + lineinfile: + path: '/etc/hosts' + regexp: '^{{ ansible_default_ipv4.address }}.+$' + line: '{{ ansible_default_ipv4.address }} {{ hostname }}.linuxfoundation.org' + tags: set-hostname + +- name: Set sudoers + lineinfile: + path: '/etc/sudoers' + state: 'present' + regexp: '^%admin ALL=' + line: '%admin ALL=(ALL) ALL' + validate: '/usr/sbin/visudo -cf %s' + tags: set-sudoers + +- name: Set sudoers + lineinfile: + path: '/etc/sudoers' + state: 'present' + regexp: '^%sudo' + line: '%sudo ALL=(ALL:ALL) NOPASSWD: ALL' + validate: '/usr/sbin/visudo -cf %s' + tags: set-sudoers + +- name: Copy grub file + template: + src: 'files/grub' + dest: '/etc/default/grub' + owner: 'root' + group: 'root' + mode: '644' + notify: ['Update GRUB'] + tags: copy-grub diff --git a/resources/tools/testbed-setup/ansible/roles/common/tasks/ubuntu_x86_64.yaml b/resources/tools/testbed-setup/ansible/roles/common/tasks/ubuntu_x86_64.yaml new file mode 100644 index 0000000000..d0f32a31cc --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/common/tasks/ubuntu_x86_64.yaml @@ -0,0 +1,50 @@ +--- +# file: roles/common/tasks/ubuntu_x86_64.yaml + +- name: Copy apt sources file + template: + src: 'files/apt-sources.list' + dest: '/etc/apt/sources.list' + tags: copy-apt-sources + +- name: Install python-apt + apt: + name: 'python-apt' + state: 'present' + update_cache: True + tags: install-python-apt + +- name: Install git + apt: + name: 'git' + state: 'present' + update_cache: True + tags: install-git + +- name: Install crudini + apt: + name: 'crudini' + state: 'present' + update_cache: True + tags: install-crudini + +- name: Install expect + apt: + name: 'expect' + state: 'present' + update_cache: True + tags: install-expect + +- name: Install socat + apt: + name: 'socat' + state: 'present' + update_cache: True + tags: install-socat + +- name: Install qemu + apt: + name: 'qemu-system-x86' + state: 'present' + update_cache: True + tags: install-qemu -- cgit 1.2.3-korg