2018-02-03 16:20:27 +00:00
---
# TODO: for now we take the PXE environment for granted, so won't install and configure DHCP and TFTP servers; that should become another block defaulting not to be processed
2018-02-03 17:38:09 +00:00
- name : prepare current SmartOS platform image for netbooting on a PXE server
2018-02-03 16:20:27 +00:00
hosts :
- pxe_server
gather_facts : no
vars :
2018-02-03 17:38:09 +00:00
download : False # prior download
2018-02-03 16:20:27 +00:00
notification_recipient : tamas@gerczei.eu
smarthost : mail
2018-07-09 12:34:56 +00:00
smarthost_port : 25
2018-02-03 16:20:27 +00:00
tftp_dir : /data/tftproot
2020-04-14 05:38:46 +00:00
smarthost_user : "{{ notification_recipient }}"
smarthost_pw : !vault |
$ANSIBLE_VAULT;1.1;AES256
34613034663131326532666239633964353161363662323531623161383262303630616163346662
3436633337346164383335333437303131313662633936310a376230613533393963633661333263
35366530333134633661643662646638663438643466333362323235653034643636663434396363
6562393836613165320a303436343535303362366335383132346636323037623634636161316437
6564
2018-02-03 16:20:27 +00:00
image_dir : "{{ tftp_dir }}/smartos"
2018-05-12 06:30:55 +00:00
tftp_user : nobody
tftp_group : nogroup
2018-02-03 16:20:27 +00:00
tasks :
- name : fetch platform image
get_url :
2020-04-14 05:38:46 +00:00
url : https://us-east.manta.joyent.com/Joyent_Dev/public/SmartOS/platform-latest.tgz # no Manta at eu-ams-1
2018-02-03 16:20:27 +00:00
dest : /var/tmp/
when : download
- name : obtain provided platform image
copy :
src : /var/tmp/platform-latest.tgz
dest : /tmp/
remote_src : yes
register : tarball
2018-05-12 06:29:59 +00:00
- name : ensure directories exist
file :
path : "{{ image_dir }}"
state : directory
become : yes
2018-02-03 16:20:27 +00:00
- name : process new tarball
block :
- name : extract new platform image
unarchive :
src : /tmp/platform-latest.tgz
dest : "{{ image_dir }}"
extra_opts :
- --transform
- 's/^platform-//;s/i86pc/platform\/i86pc/'
remote_src : yes
owner : "{{ tftp_user }}"
group : "{{ tftp_group }}"
become : yes
- name : find images
find :
paths : "{{ image_dir }}"
file_type : directory
register : found_images
- name : determine latest release
set_fact :
last_release : "{{ ( found_images.files | sort(attribute='mtime',reverse=true) | first )['path'] | basename }}"
- name : generate iPXE configuration
template :
src : smartos_ipxe.j2
dest : "{{ tftp_dir }}/smartos.ipxe"
owner : "{{ tftp_user }}"
group : "{{ tftp_group }}"
backup : yes
become : yes
- name : send e-mail notification
mail :
host : "{{ smarthost }}"
2018-07-09 12:34:56 +00:00
port : "{{ smarthost_port }}"
2020-04-14 05:38:46 +00:00
secure : starttls
username : "{{ smarthost_user }}"
password : "{{ smarthost_pw }}"
from : "Ansible <noreply@fejezd.be>"
2018-02-03 16:20:27 +00:00
to : "{{ notification_recipient }}"
subject : "SmartOS update ({{ last_release }}) available"
body : "created {{ image_dir }}/{{ last_release }} and {{ tftp_dir }}/smartos.ipxe"
2018-05-12 06:31:28 +00:00
when : tarball is changed