Browse Source

add gen & kickstart

ca-cert-and-multi-ks
ePietry 2 years ago
parent
commit
2def96a891
  1. 55
      ansible/playbooks/gen_iso_image.yaml
  2. 11
      ansible/playbooks/kickstart.yaml
  3. 43
      ansible/playbooks/ostree_construction.yaml

55
ansible/playbooks/gen_iso_image.yaml

@ -0,0 +1,55 @@
- name: Generate the Installer ISO image
hosts: all
vars_files: ../credentials.yaml
tasks:
- name: Clear /tmp/microshift_bluprint
ansible.builtin.file:
path: /tmp/microshift_bluprint.toml
state: absent
- name: Create /tmp/microshift_bluprint
ansible.builtin.file:
path: /tmp/microshift_bluprint.toml
state: file
mode: "0755"
- name: Write blueprint content to /tmp/microshift_bluprint file
ansible.builtin.copy:
dest: "/tmp/microshift_blueprint"
content: |
name = "microshift-installer"
description = ""
version = "0.0.0"
modules = []
groups = []
packages = []
become: true
- name: Push Blueprint
infra.osbuild.push_blueprint:
src: "/tmp/microshift_blueprint.toml"
- name: Start the compose
ansible.builtin.shell: |
BUILDID=$(composer-cli compose start-ostree --url {{ repo_url }} --ref {{ ostree_ref }} {{ blueprint_name }} {{ compose_type }} | awk '{print $2}')
echo $BUILDID > /tmp/build_id
args:
executable: /bin/bash
register: start_compose_result
- name: Wait for compose to finish (simplified example)
ansible.builtin.shell: |
BUILDID=$(cat /tmp/build_id)
until composer-cli compose status | grep -E "$BUILDID.*FINISHED"; do
sleep 30
done
args:
executable: /bin/bash
- name: Get BUILDID from file
ansible.builtin.shell: "cat /tmp/build_id"
register: build_id
- name: Generate image from the compose
ansible.builtin.command:
cmd: "composer-cli compose image {{ build_id.stdout }}"

11
ansible/playbooks/kickstart.yaml

@ -0,0 +1,11 @@
- name: creat kickstart
hosts: all
become: true
vars_files: ../config.yaml
tasks:
- name: set MICROSHIFT_PULL_SECRET
ansible.builtin.lineinfile:
path: "{{ ansible_env.HOME }}/red-hat-kiosk/imagebuilder/kiosk.ks"
regexp: '--url=http://__MYIP__/repo'
line: '--url=http://"{{ ansible_default_ipv4.address }}"'
backrefs: yes

43
ansible/playbooks/ostree_construction.yaml

@ -5,20 +5,21 @@
- name: Solve dependencies for the blueprint - name: Solve dependencies for the blueprint
ansible.builtin.command: composer-cli blueprints depsolve kiosk ansible.builtin.command: composer-cli blueprints depsolve kiosk
- name: Start OSTree Compose
- name: Start ostree compose ansible.builtin.shell:
infra.osbuild.start_compose: cmd: composer-cli compose start-ostree kiosk edge-commit --url http://{{ ansible_default_ipv4.address }}/repo --ref "rhel/9/{{ ansible_architecture }}/edge-kiosk" --parent "rhel/9/{{ ansible_architecture }}/edge" | awk '{print $2}'
blueprint: kiosk register: build_id
compose_type: edge-commit
allow_duplicate: true - name: Echo BuildID for Microshift Installer
ostree_url: http://{{ ansible_default_ipv4.address }}/repo ansible.builtin.debug:
register: builder_compose_start_out msg: "Build {{ build_id.stdout_lines | first }} is running..."
- name: Wait for compose to finish - name: Wait for compose to finish
infra.osbuild.wait_compose: infra.osbuild.wait_compose:
compose_id: "{{ builder_compose_start_out['result']['body']['build_id'] }}" compose_id: "{{build_id.stdout_lines | first}}"
timeout: 3600 timeout: 3600
- name: Create /tmp/commit repo - name: Create /tmp/commit repo
ansible.builtin.file: ansible.builtin.file:
path: /tmp/commit/ path: /tmp/commit/
@ -27,26 +28,31 @@
- name: Export the compose artifact to /tmp/commit - name: Export the compose artifact to /tmp/commit
infra.osbuild.export_compose: # noqa only-builtins infra.osbuild.export_compose: # noqa only-builtins
compose_id: "{{ builder_compose_start_out['result']['body']['build_id'] }}" compose_id: "{{ build_id.stdout_lines | first }}"
dest: /tmp/commit/{{ builder_compose_start_out['result']['body']['build_id'] }}.tar dest: /tmp/commit/{{ build_id.stdout_lines | first }}.tar
- name: Create /tmp/commit/ID repo - name: Create /tmp/commit/ID repo
ansible.builtin.file: ansible.builtin.file:
path: /tmp/commit/{{ builder_compose_start_out['result']['body']['build_id'] }} path: /tmp/commit/{{ build_id.stdout_lines | first }}
mode: '0755' mode: '0755'
state: directory state: directory
- name: Extract compose artifact into /var/www/repo - name: Extract compose artifact into /tmp/commit/ID
ansible.builtin.unarchive: ansible.builtin.unarchive:
src: /tmp/commit/{{ builder_compose_start_out['result']['body']['build_id'] }}.tar src: /tmp/commit/{{ build_id.stdout_lines | first }}.tar
dest: /tmp/commit/{{ builder_compose_start_out['result']['body']['build_id'] }} dest: /tmp/commit/{{ build_id.stdout_lines | first }}
remote_src: true remote_src: true
- name: Pull local ostree repository - name: Pull local ostree repository
become: true become: true
ansible.builtin.shell: ostree --repo=/var/www/repo pull-local "/tmp/commit/{{ builder_compose_start_out['result']['body']['build_id'] }}/repo" ansible.builtin.shell: ostree --repo=/var/www/repo pull-local "/tmp/commit/{{ build_id.stdout_lines | first }}/repo"
# - name: Clear /tmp/commit repo
# ansible.builtin.file:
# path: /tmp/commit/
# state: absent
- name: config ostree ref - name: config ostree ref
become: true become: true
ansible.builtin.shell: ostree --repo=/var/www/repo refs ansible.builtin.shell: ostree --repo=/var/www/repo refs
@ -58,9 +64,10 @@
- name: config ostree logs kiosk - name: config ostree logs kiosk
become: true become: true
ansible.builtin.shell: ostree --repo=/var/www/repo log rhel/9/x86_64/edge ansible.builtin.shell: ostree --repo=/var/www/repo log rhel/9/{{ ansible_architecture }}/edge-kiosk
register: logs register: logs
- name: Print refs - name: Print refs
ansible.builtin.debug: ansible.builtin.debug:
var: logs.stdout_lines var: logs.stdout_lines

Loading…
Cancel
Save