#!/usr/bin/env -S ansible-playbook -i /etc/ansible/hosts # # shorthand to install an ocp-on-libvirt lab --- - name: Install ocp-on-libvirt lab in the given host(s) hosts: '*' become: true vars: dci_client_id: "{{ lookup('pipe', 'pass show Hacking/distributed-ci.io | grep client_id | cut -d\\ -f 2') }}" dci_api_secret: "{{ lookup('pipe', 'pass show Hacking/distributed-ci.io | grep api_secret | cut -d\\ -f 2') }}" dci_cs_url: "https://api.distributed-ci.io/" sm_user: "jorge.gallegos" sm_pass: "{{ lookup('pipe', 'pass Hacking/access.redhat.com | head -1') }}" extra_pkgs: - byobu - rsync - tcpdump tasks: - name: Subscribe this system to RHN tags: - setup redhat_subscription: state: present username: "{{ sm_user }}" password: "{{ sm_pass }}" auto_attach: true when: - ansible_distribution == "RedHat" - name: Install EPEL Release tags: - setup yum: name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" state: present disable_gpg_check: true - name: Install DCI Release tags: - setup yum: name: "https://packages.distributed-ci.io/dci-release.el7.noarch.rpm" state: present disable_gpg_check: true - name: Install extra packages tags: - setup - pkgs yum: name: "{{ extra_pkgs }}" state: present - name: Enable extra repos for RHEL7 tags: - setup shell: < subscription-manager repos --enable={{ item }} with_items: - rhel-7-server-extras-rpms - rhel-7-server-optional-rpms when: - ansible_distribution == "RedHat" - ansible_distribution_major_version == 7 - name: Install dci-openshift-agent tags: - setup - install package: name: dci-openshift-agent state: present - name: Enable byobu for the dci-openshift-agent user tags: - setup - install become_user: dci-openshift-agent shell: | byobu-enable byobu-ctrl-a screen - name: Copy SSH key to the dci-openshift-agent user tags: - setup - install authorized_key: user: dci-openshift-agent state: present key: https://github.com/thekad.keys - name: Ensure there is a ~/tmp directory for d-o-a tags: - setup - install become_user: dci-openshift-agent file: path: ~/tmp state: directory - name: Destroy VMs tags: - install - destroy become_user: dci-openshift-agent environment: ANSIBLE_LOG_PATH: /tmp/libvirt-destroy.log shell: ansible-playbook libvirt_destroy.yml args: chdir: ~dci-openshift-agent/samples/ocp_on_libvirt - name: Create VMs tags: - install - create become_user: dci-openshift-agent environment: ANSIBLE_LOG_PATH: /tmp/libvirt-up.log shell: ansible-playbook libvirt_up.yml args: chdir: ~dci-openshift-agent/samples/ocp_on_libvirt - name: Copy the hosts file tags: - install - create - config copy: src: ~dci-openshift-agent/samples/ocp_on_libvirt/hosts dest: /etc/dci-openshift-agent/hosts remote_src: true - name: Create the dcirc file tags: - install - create - config shell: | cat > /etc/dci-openshift-agent/dcirc.sh < /usr/local/bin/go-dci <