variant: flatcar
version: 1.0.0
passwd:
  users:
    - name: core
      password_hash: "$y$j9T$m46VXzNc1zu0uyjDS.upy/$.MbgKF58KYtxv2V23bRUcgqjcDzh5Xi6DBHyJKesQ.4"
systemd:
  units:
    - name: update-engine.service
      mask: true
    - name: locksmithd.service
      mask: true
    - name: docker.service
      enabled: true
    - name: zfs-mount.service
      contents: |
        [Unit]
        Description=ZFS mount all pools to default mountpoints
        Wants=zfs.target
        
        [Service]
        Type=oneshot
        RemainAfterExit=true
        # ExecStart=/usr/sbin/zfs mount -a
        ExecStart=/sbin/zpool import -a -o cachefile=none
        
        [Install]
        WantedBy=multi-user.target
    - name: smb-docker-container.service
      enabled: true
      contents: |
        [Unit]
        Description=SMB docker container
        After=docker.service zfs-mount.service
        Requires=docker.service zfs-mount.service
        
        [Service]
        TimeoutStartSec=0
        ExecStartPre=-/usr/bin/docker rm --force smb
        ExecStart=/usr/bin/docker run -e USERID=65534 -e GROUPID=65533 --name smb -p 445:445 --pull always -v /stdrive:/m1 -v /todrive:/m2 dperson/samba:latest -r -s "stdrive;/m1;yes;no" -s "todrive;/m2;yes;no" -g "ea support = no" -g "store dos attributes = no"
        ExecStop=/usr/bin/docker stop smb
        Restart=always
        RestartSec=5s
        
        [Install]
        WantedBy=multi-user.target
    - name: portainer-agent.service
      enabled: true
      contents: |
        [Unit]
        Description=Portainer agent container
        After=docker.service zfs-mount.service
        Requires=docker.service zfs-mount.service

        [Service]
        TimeoutStartSec=0
        ExecStartPre=-/usr/bin/docker rm --force portainer_agent
        ExecStart=/usr/bin/docker run -p 9001:9001 --name portainer_agent --pull=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -v /:/host portainer/agent:latest
        ExecStop=/usr/bin/docker stop portainer_agent
        Restart=always
        RestartSec=5s

        [Install]
        WantedBy=multi-user.target
storage:
  links:
  - path: /etc/systemd/system/multi-user.target.wants/docker.service
    target: /usr/lib/systemd/system/docker.service
    hard: false
    overwrite: true
  #- path: /etc/systemd/system/zfs-import.target.wants/zfs-import-cache.service
    #target: /dev/null
    #overwrite: true
  #- path: /etc/systemd/system/zfs-import.target.wants/zfs-import-scan.service
    #target: /usr/lib/systemd/system/zfs-import-scan.service
    #hard: false
    #overwrite: true
  files:
  - contents:
      inline: |-
        zfs
    mode: 384
    path: "/etc/flatcar/enabled-sysext.conf"
  - contents:
      source: http://192.168.1.121/flatcar-zfs-4081.2.1.raw
      verification:
        hash: sha512-5da9219ee4bb1a59757c6166a701b33f3f4f1be8a3c00464bfd3f0df745c11431d691d212a7ed418b8ff3a5c0900017b9adcfe01c147617d7a045be8c39f1370
    path: "/etc/flatcar/sysext/flatcar-zfs-4081.2.1.raw"
