--- /dev/null
+---
+### This playbook is useful for setting up a baremetal hosts (irvingi or senta)
+### as a RHEL Hypervisor to serve Jenkins VMs. Expects a RHEL7 image
+### already subscribed to RHSM and had ceph-cm-ansible common role
+### ran against it.
+
+- hosts:
+ - irvingi
+ - senta
+ vars:
+ # Default to configure /vms disk
+ configure_disk: true
+ vars_prompt:
+ # Forcefully reconfigure disk even if it's already mounted
+ - name: "force_configure_disk"
+ prompt: "\nWARNING: You will lose data if you enter \"y\"\nDo you want to forcefully reconfigure the VMs disk even if it's already set up? (y|n)"
+ default: "n"
+ become: true
+ tasks:
+
+ - name: Enable rhev-mgmt repo
+ command: "subscription-manager repos --enable=rhel-7-server-rhev-mgmt-agent-rpms"
+
+ - name: Install packages
+ yum:
+ name: "{{ item }}"
+ state: latest
+ enablerepo: epel
+ with_items:
+ - gdisk
+ - parted
+ - vdsm
+
+ - name: Find 1TB SSD
+ set_fact:
+ vm_ssd: "{{ item.key }}"
+ with_dict: "{{ ansible_devices }}"
+ when: item.value.model == "Samsung SSD 850"
+
+ # This is where the RHEV virtual machines will reside
+ - name: Make /vms dir and set permissions
+ file:
+ state: directory
+ path: /vms
+ owner: vdsm
+ group: kvm
+
+ # Unmount /vms so configure_disk is set to true
+ - name: Unmount 1TB SSD if we're forcefully reconfiguring
+ mount:
+ name: /vms
+ state: unmounted
+ when: force_configure_disk == "y"
+
+ - name: Update ansible_mounts
+ setup:
+ filter: ansible_mounts
+ when: force_configure_disk == "y"
+
+ # Check if the 1TB SSD is already mounted at the /vms mountpoint.
+ # This is the ONLY way the playbook checks if the host is already configured
+ - name: Check if /vms already mounted
+ set_fact:
+ configure_disk: false
+ with_items: "{{ ansible_mounts }}"
+ when: '"/vms" in item.mount'
+
+ - debug: var=configure_disk
+
+ - name: Zap 1TB SSD
+ command: sgdisk -Z "/dev/{{ vm_ssd }}"
+ when: configure_disk == true
+
+ - name: Create partition table
+ command: "parted -s /dev/{{ vm_ssd }} mktable msdos"
+ when: configure_disk == true
+
+ - name: Create partition
+ command: "parted /dev/{{ vm_ssd }} unit '%' mkpart primary 0 100"
+ when: configure_disk == true
+
+ - name: Create filesystem
+ filesystem:
+ fstype: xfs
+ dev: "/dev/{{ vm_ssd }}1"
+ force: yes
+ when: configure_disk == true
+
+ - name: Find VM partition UUID
+ command: "lsblk -n -o uuid /dev/{{ vm_ssd }}1"
+ register: vm_uuid
+
+ - name: Mount 1TB SSD to /vms
+ mount:
+ name: /vms
+ src: "UUID={{ vm_uuid.stdout }}"
+ fstype: xfs
+ opts: defaults
+ state: mounted
+
+ - name: Copy RHEV SSH key to root's authorized_keys
+ authorized_key:
+ user: root
+ key: http://mgr01.front.sepia.ceph.com/engine.ssh.key.txt
--- /dev/null
+---
+### This playbook is useful for setting up a smithi as Jenkins slave
+### for use with 2.jenkins.ceph.com.
+### Primarily, this just sets up the NVMe device to be mounted at {{ mount_dir }}
+### NOTE: Not idempotent! This will erase any data at {{ mount_dir }}
+
+- hosts:
+ - smithi
+ become: true
+ vars:
+ mount_dir: "/var/lib/libvirt/images"
+ tasks:
+
+ - name: Remove all non-admin users
+ user:
+ name: "{{ item.name }}"
+ state: absent
+ remove: yes
+ with_items: "{{ lab_users }} + [{'name': 'ubuntu'}]"
+
+ - name: Install deps
+ package:
+ state: latest
+ name: "{{ item }}"
+ with_items:
+ - xfsprogs
+
+ - name: Stop Jenkins slave service in case it's running
+ service:
+ name: jenkins
+ state: stopped
+ failed_when: false
+
+ - name: "Unmount /dev/nvme0n1"
+ mount:
+ path: "{{ item.mount }}"
+ state: unmounted
+ with_items: "{{ ansible_mounts }}"
+ when: item.device == "/dev/nvme0n1"
+
+ - name: Zap NVMe disk
+ command: "sgdisk -Z /dev/nvme0n1"
+
+ - name: Make filesystem on NVMe disk
+ filesystem:
+ fstype: xfs
+ dev: "/dev/nvme0n1"
+
+ - name: "Make {{ mount_dir }} dir"
+ file:
+ path: "{{ mount_dir }}"
+ state: directory
+
+ - name: Mount NVMe disk
+ mount:
+ path: "{{ mount_dir }}"
+ src: "/dev/nvme0n1"
+ fstype: xfs
+ state: mounted