--- - name: check OS, fail if not OpenBSD fail: msg: "must only be run on OpenBSD system" when: not ansible_system == "OpenBSD" - name: set short version string shell: echo {{openbsd_version}} | tr -cd '[:digit:]' register: openbsd_version_short - name: set target hostname, arch fact set_fact: openbsd_hostname: obsd{{openbsd_version_short.stdout}} arch_dir: "{{installsets_path}}/{{openbsd_version}}/{{arch}}" - name: set bsd.rd and site{{openbsd_version_short.stdout}}.tgz paths set_fact: bsdrd_dst_path: "{{arch_dir}}/bsd.rd" sitetgz_tmp_path: "{{arch_dir}}/site{{openbsd_version_short.stdout}}.tgz.new" sitetgz_dst_path: "{{arch_dir}}/site{{openbsd_version_short.stdout}}.tgz" - name: install packages (OpenBSD pkg_add) become: yes openbsd_pkg: name: ['rsync--', 'upobsd'] state: present when: ansible_pkg_mgr == "openbsd_pkg" - name: set permissions become: yes file: path: "{{item.p}}" owner: "{{ansible_user_id}}" group: "{{ansible_user_gid}}" mode: "{{item.m}}" state: "{{item.s}}" loop: - {m: "0755", s: absent, p: "{{iso_path}}/" } - {m: "0600", s: absent, p: "{{arch_dir}}/boot.catalog" } - {m: "0600", s: absent, p: "{{sitetgz_dst_path}}" } - {m: "0600", s: absent, p: "{{sitetgz_tmp_path}}" } - {m: "02755", s: absent, p: "{{installsets_path}}/ramdisk" } - {m: "02755", s: directory, p: "{{installsets_path}}/" } - {m: "02755", s: directory, p: "{{installsets_path}}/etc/" } - {m: "02755", s: directory, p: "{{installsets_path}}/{{openbsd_version}}/" } - {m: "02755", s: directory, p: "{{arch_dir}}/" } - {m: "02755", s: directory, p: "{{iso_path}}/" } - {m: "02755", s: directory, p: "{{installsets_path}}/ramdisk.d/" } # rsync notes: # # - {{openbsd_version_url}} *usually* matches {{openbsd_version}}, but could also be "snapshots" # - "--include=[bcgm]*.tgz" fetches install sets but not the x*.tgz sets to save space in the ISO. # - Use "--include=*.tgz" to get every set. - name: rsync install sets to local machine shell: rsync -qrtW --no-motd --delete --include=SHA256* --include=[bcgm]*.tgz --include=bsd --include=bsd.mp --include=bsd.rd --include=cdboot --include=cdbr --include=INSTALL.amd64 --exclude=* {{rsync_url}}/{{openbsd_version_url}}/{{arch}}/ {{arch_dir}}/ # warning: OpenBSD beta snapshots don't always include the openbsd-XX-base.pub signify key - name: rsync fetch openbsd-{{openbsd_version_short.stdout}}-base.pub signify key shell: rsync -qtW --no-motd {{rsync_url}}/{{openbsd_version_url}}/openbsd-{{openbsd_version_short.stdout}}-base.pub {{installsets_path}}/{{openbsd_version}}/ - name: set list of files in {{arch_dir}} shell: ls -1 | grep -v SHA256 | tr "\n" ' ' args: chdir: "{{arch_dir}}/" register: file_list # - name: signify -Cp ../openbsd-{{openbsd_version_short.stdout}}-base.pub -x SHA256.sig shell: signify -Cp ../openbsd-{{openbsd_version_short.stdout}}-base.pub -x SHA256.sig {{file_list.stdout}} args: chdir: "{{arch_dir}}/" register: result - name: fail if signify exits non-zero fail: msg: "{{result.stdout}}" when: not 0 == result.rc - name: add install.site template template: src: "site{{openbsd_version_short.stdout}}.j2" dest: "{{installsets_path}}/install.site" mode: "0755" - name: tar install.site into site{{openbsd_version_short.stdout}}.tgz.new shell: tar cf - install.site | gzip -9 > {{sitetgz_tmp_path}} args: chdir: "{{installsets_path}}/" warn: false - name: mv -f site{{openbsd_version_short.stdout}}.tgz.new site{{openbsd_version_short.stdout}}.tgz shell: mv -f {{sitetgz_tmp_path}} {{sitetgz_dst_path}} - name: remove install.site file: path: "{{installsets_path}}/install.site" state: absent - name: elfrdsetroot -x shell: /usr/local/bin/elfrdsetroot -x {{bsdrd_dst_path}} {{installsets_path}}/ramdisk - name: vnconfig vnd0 {{installsets_path}}/ramdisk become: yes shell: vnconfig vnd0 {{installsets_path}}/ramdisk - name: mount ramdisk become: yes shell: mount -o nodev,nosuid,noexec /dev/vnd0a {{installsets_path}}/ramdisk.d/ args: warn: false - name: add auto_install.conf template become: yes template: src: "conf{{openbsd_version_short.stdout}}.j2" dest: "{{installsets_path}}/ramdisk.d/auto_install.conf" owner: root group: "0" mode: "0644" - name: copy {{openbsd_disklabel_file}} become: yes copy: # can't use "synchronize:" here, ansible bug #5307 src: "{{openbsd_disklabel_file}}" dest: "{{installsets_path}}/ramdisk.d/disklabel.template" owner: root group: "0" mode: 0644 - name: fix newfs -O 1 in install.sub become: yes lineinfile: backup: no dest: "{{installsets_path}}/ramdisk.d/install.sub" regexp: "^\t+newfs.*$" line: "\t\t\tnewfs -q $_opt -O 1 ${_pp##/dev/}" state: present - name: umount ramdisk become: yes shell: umount /dev/vnd0a args: warn: false - name: vnconfig -u become: yes shell: vnconfig -u vnd0 - name: elfrdsetroot shell: /usr/local/bin/elfrdsetroot {{bsdrd_dst_path}} {{installsets_path}}/ramdisk - name: set permissions file: path: "{{item.p}}" state: "{{item.s}}" loop: - {s: absent, p: "{{installsets_path}}/ramdisk" } - {s: absent, p: "{{installsets_path}}/ramdisk.d/" } - name: create {{installsets_path}}/etc/boot.conf shell: echo set image /{{openbsd_version}}/{{arch}}/bsd.rd > {{installsets_path}}/etc/boot.conf - name: make ISO shell: /usr/sbin/mkhybrid -quiet -r -b {{openbsd_version}}/{{arch}}/cdbr -c {{openbsd_version}}/{{arch}}/boot.catalog -o {{iso_path}}/cd{{openbsd_version_short.stdout}}-autoinstall-{{network_interface}}.iso . args: chdir: "{{installsets_path}}/" # END