<commit_before>---
# Any step that should happen before initiating the osp-d playbook
# This could be validation of the hosts, package installation that is assumed as per the guide, etc..
- name: Prepare our undercloud
  hosts: virthost
  gather_facts: no
  vars:
      undercloud_image_file: "undercloud-quickstart-{{ director_puddle_version | default(core_puddle_version) }}"
      # todo(yfried): add external refs so users can override these values and customize the Undercloud
      undercloud_node:
          name: 'undercloud-0'
          disk_cache: "default"
          memory: '16384'
          cpu: '4'
          os:
              type: linux
              variant: rhel7
      undercloud_disk_path: "/var/lib/libvirt/images/{{ undercloud_node.name }}-disk1.qcow2"
#      xml: "{{ undercloud_node.name }}.xml"

  tasks:
      - block:
            - name: download the undercloud image file
              get_url:
                  url: "http://{{ private.storage.oc_image_repo.server }}/{{ private.storage.oc_image_repo.path }}/{{ installer.product.version }}/{{ undercloud_image_file }}.qcow2"
                  dest: "~/{{ undercloud_image_file }}.qcow2"


        # Old images are tar'ed
        rescue:
            - name: download the undercloud tar file
              get_url:
                  url: "http://{{ private.storage.oc_image_repo.server }}/{{ private.storage.oc_image_repo.path }}/{{ installer.product.version }}/{{ undercloud_image_file }}.tar"
                  dest: "~/{{ undercloud_image_file }}.tar"

            - name: untar the undercloud quickstart
              unarchive:
                  src: "~/{{ undercloud_image_file }}.tar"
                  dest: "~/"
                  copy: no
                  list_files: yes
              register: tar

            - name: remove the old XML
              file:
                  state: absent
                  path: "{{ undercloud_node.name }}.xml"
#
      - name: copy the image into libvirt images folder
        vars:
            image_filename: "~/{{ (tar is defined) | ternary(undercloud_node.name + '-disk1', undercloud_image_file) }}.qcow2"
        copy:
            remote_src: yes
            force: yes
            src: "{{ image_filename }}"
            dest: "{{ undercloud_disk_path }}"
#
      - name: inject our key into the undercloud image
        shell: "virt-customize -a {{ undercloud_disk_path }} --ssh-inject root:file:/root/.ssh/id_rsa.pub --selinux-relabel"

      - name: create Undercloud VM from snapshot
        shell: |
            virt-install --name {{ undercloud_node.name }} \
               --disk path={{ undercloud_disk_path }},device=disk,bus=virtio,format=qcow2,cache={{ undercloud_node.disk_cache }} \
               --network network:data \
               --network network:management \
               --network network:external \
               --virt-type kvm \
               --cpu host-model \
               --ram {{ undercloud_node.memory }} \
               --vcpus {{ undercloud_node.cpu }} \
               --os-variant {{ undercloud_node.os.variant }} \
               --import \
               --noautoconsole \
               --autostart \
               --vnc \
               --dry-run --print-xml
        register: virt_xml

      - name: define the undercloud VM
        virt:
            name: "{{ undercloud_node.name }}"
            command: define
            xml: "{{ virt_xml.stdout }}"
<commit_msg>Update our virt-customize command to be backward compatible<commit_after>---
# Any step that should happen before initiating the osp-d playbook
# This could be validation of the hosts, package installation that is assumed as per the guide, etc..
- name: Prepare our undercloud
  hosts: virthost
  gather_facts: no
  vars:
      undercloud_image_file: "undercloud-quickstart-{{ director_puddle_version | default(core_puddle_version) }}"
      # todo(yfried): add external refs so users can override these values and customize the Undercloud
      undercloud_node:
          name: 'undercloud-0'
          disk_cache: "default"
          memory: '16384'
          cpu: '4'
          os:
              type: linux
              variant: rhel7
      undercloud_disk_path: "/var/lib/libvirt/images/{{ undercloud_node.name }}-disk1.qcow2"

  tasks:
      - block:
          - name: download the undercloud image file
            get_url:
                url: "http://{{ private.storage.oc_image_repo.server }}/{{ private.storage.oc_image_repo.path }}/{{ installer.product.version }}/{{ undercloud_image_file }}.qcow2"
                dest: "~/{{ undercloud_image_file }}.qcow2"

        # Old images are tar'ed
        rescue:
          - name: download the undercloud tar file
            get_url:
                url: "http://{{ private.storage.oc_image_repo.server }}/{{ private.storage.oc_image_repo.path }}/{{ installer.product.version }}/{{ undercloud_image_file }}.tar"
                dest: "~/{{ undercloud_image_file }}.tar"

          - name: untar the undercloud quickstart
            unarchive:
                src: "~/{{ undercloud_image_file }}.tar"
                dest: "~/"
                copy: no
                list_files: yes
            register: tar

          - name: remove the old XML
            file:
                state: absent
                path: "{{ undercloud_node.name }}.xml"

      - name: copy the image into libvirt images folder
        vars:
            image_filename: "~/{{ (tar is defined) | ternary(undercloud_node.name + '-disk1', undercloud_image_file) }}.qcow2"
        copy:
            remote_src: yes
            force: yes
            src: "{{ image_filename }}"
            dest: "{{ undercloud_disk_path }}"

      - name: inject our key into the undercloud image
        shell: "virt-customize -a {{ undercloud_disk_path }} --root-password password:redhat --mkdir /root/.ssh --chmod 0700:/root/.ssh --upload /root/.ssh/id_rsa.pub:/root/.ssh/authorized_keys --selinux-relabel"

      - name: create Undercloud VM from snapshot
        shell: |
            virt-install --name {{ undercloud_node.name }} \
               --disk path={{ undercloud_disk_path }},device=disk,bus=virtio,format=qcow2,cache={{ undercloud_node.disk_cache }} \
               --network network:data \
               --network network:management \
               --network network:external \
               --virt-type kvm \
               --cpu host-model \
               --ram {{ undercloud_node.memory }} \
               --vcpus {{ undercloud_node.cpu }} \
               --os-variant {{ undercloud_node.os.variant }} \
               --import \
               --noautoconsole \
               --autostart \
               --vnc \
               --dry-run --print-xml
        register: virt_xml

      - name: define the undercloud VM
        virt:
            name: "{{ undercloud_node.name }}"
            command: define
            xml: "{{ virt_xml.stdout }}"

{'fraction_non_alphanumeric': 0.11488626547653326, 'fraction_numerical': 0.0048949035416066804, 'mean_word_length': 1.7371946414499606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3132665', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1913, 'n_words': 482}