diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..ece41cd --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +inventory= inventory.yaml diff --git a/ansible/inventory.yaml b/ansible/inventory.yaml new file mode 100644 index 0000000..9cb3432 --- /dev/null +++ b/ansible/inventory.yaml @@ -0,0 +1,7 @@ +aws: + hosts: + 192.168.122.45: + vars: + ansible_port: 22 + ansible_user: epietryk + ansible_key_file: /home/epietryk/.ssh/edge diff --git a/ansible/playbooks-test.yaml b/ansible/playbooks-test.yaml new file mode 100644 index 0000000..32dc3d9 --- /dev/null +++ b/ansible/playbooks-test.yaml @@ -0,0 +1,6 @@ +--- + - name: ping all inventory + hosts: all + tasks: + - name: ping + ansible.builtin.ping: diff --git a/ansible/playbooks/.vscode/settings.json b/ansible/playbooks/.vscode/settings.json new file mode 100644 index 0000000..9d14cfb --- /dev/null +++ b/ansible/playbooks/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "ansible.python.interpreterPath": "/bin/python" +} \ No newline at end of file diff --git a/ansible/playbooks/blueprint.vars b/ansible/playbooks/blueprint.vars new file mode 100644 index 0000000..72ab8fb --- /dev/null +++ b/ansible/playbooks/blueprint.vars @@ -0,0 +1,5 @@ +builder_blueprint_name: "minimal-rhel9" +builder_blueprint_description: "minimal blueprint for ostree commit" +builder_blueprint_distro: rhel-93 +builder_blueprint_customizations: + version: "1.1.0" \ No newline at end of file diff --git a/ansible/playbooks/initial_ostree.yaml b/ansible/playbooks/initial_ostree.yaml new file mode 100644 index 0000000..9224996 --- /dev/null +++ b/ansible/playbooks/initial_ostree.yaml @@ -0,0 +1,44 @@ +- name: Create the initial ostree repo + hosts: all + become: true + vars_files: + - blueprint.vars + tasks: + - name: Add user to weldr group + ansible.builtin.user: + name: "{{ ansible_user_id }}" + groups: weldr + append: true + # - name: Create a blueprint + # infra.osbuild.create_blueprint: + # dest: "/home/epietryk/blueprint/blueprint.toml" + # name: "rhel-edge-blueprint" + # description: "{{ builder_blueprint_description }}" + # distro: "{{ builder_blueprint_distro }}" + # groups: "{{ builder_blueprint_groups }}" + # packages: "{{ builder_blueprint_packages }}" + # customizations: "{{ builder_blueprint_customizations }}" + - name: Push a blueprint + infra.osbuild.push_blueprint: + src: "/home/epietryk/blueprint/blueprint.toml" + - name: Start ostree compose with idempotent transaction + infra.osbuild.start_compose: + blueprint: rhel-edge-blueprint + allow_duplicate: true + register: builder_compose_start_out + - name: Print compose UUID + ansible.builtin.debug: + var: builder_compose_start_out + - name: Wait for compose to finish + infra.osbuild.wait_compose: + compose_id: "{{ builder_compose_start_out['result']['body']['build_id'] }}" + timeout: 3600 + - name: Create /tmp repo + ansible.builtin.file: + path: /tmp/images/ + mode: '0755' + state: directory + - name: Export the compose artifact + infra.osbuild.export_compose: # noqa only-builtins + compose_id: "{{ builder_compose_start_out['result']['body']['build_id'] }}" + dest: /tmp/images/{{ builder_compose_start_out['result']['body']['build_id'] }}.tar diff --git a/ansible/playbooks/setup.yaml b/ansible/playbooks/setup.yaml new file mode 100644 index 0000000..c45b077 --- /dev/null +++ b/ansible/playbooks/setup.yaml @@ -0,0 +1,31 @@ +- name: Setup VM + hosts: all + become: true + tasks: + - name: Install software + ansible.builtin.dnf: + name: + - osbuild-composer + - composer-cli + - cockpit-composer + - git + - podman + - buildah + - nginx + - firewalld + state: present + - name: Config services + ansible.builtin.service: + name: "{{ item }}" + state: started + enabled: true + loop: + - osbuild-composer.socket + - cockpit.socket + - nginx.service + - firewalld + - name: Add user to weldr group + ansible.builtin.user: + name: "{{ ansible_user_id }}" + groups: weldr + append: true