tmpfiles.d problem

113 views
Skip to first unread message

rama...@gmail.com

unread,
Dec 4, 2016, 2:02:45 AM12/4/16
to CoreOS User
I'm running CoreOS on diskless station with PXE-boot and cloud config. There is a service unit which requires folders like /var/log/foo/ and /var/run/foo/ to be existed. This service fails to start because these folders do not create.
File /etc/tmpfiles.d/foo.conf creates via cloud config:
  - path: /etc/tmpfiles.d/munge.conf
    permissions: "0644"
    owner: "root"
    content: |
      d /var/run/foo 0755 root root -
      d /var/log/foo 0755 root root -
      d /var/lib/foo 0755 root root -

Service unit defined as:
    - name: foo.service
      command: start
      content: |
        [Unit]
        Description=foo service
        Documentation=man:foo(8)
        After=network.target
        After=syslog.target
        After=time-sync.target

        [Service]
        Type=forking
        ExecStart=/usr/sbin/food
        PIDFile=/var/run/foo/food.pid
        Restart=on-abort

        [Install]
        WantedBy=multi-user.target

If I call directly systemd-tmpfiles --create /etc/tmpfiles.d/foo.conf all folders created.

What I do wrong?
Thank you.

rama...@gmail.com

unread,
Dec 5, 2016, 3:35:44 AM12/5/16
to CoreOS User
It seems that systemd-tmpfiles-setup.service performs prior creating file /etc/tmpfiles.d/foo.conf by cloud init.
Temporary workaround is to add custom service in cloud init like:
    - name: cloud-init-tmpfiles.service
      command: start
      content: |
        [Unit]
        Description=Create Volatile Files and Directories defined in cloud-init
        DefaultDependencies=no
        Conflicts=shutdown.target
        After=local-fs.target systemd-sysusers.service

        [Service]
        ExecStart=/usr/bin/systemd-tmpfiles --create /etc/tmpfiles.d/foo.conf

        [Install]
        WantedBy=multi-user.target


воскресенье, 4 декабря 2016 г., 10:02:45 UTC+3 пользователь rama...@gmail.com написал:

Alex Crawford

unread,
Dec 5, 2016, 2:32:00 PM12/5/16
to rama...@gmail.com, CoreOS User
On 12/05, rama...@gmail.com wrote:
> It seems that systemd-tmpfiles-setup.service performs prior creating file
> /etc/tmpfiles.d/foo.conf by cloud init.
> Temporary workaround is to add custom service in cloud init like:
> - name: cloud-init-tmpfiles.service
> command: start
> content: |
> [Unit]
> Description=Create Volatile Files and Directories defined in
> cloud-init
> DefaultDependencies=no
> Conflicts=shutdown.target
> After=local-fs.target systemd-sysusers.service
>
> [Service]
> ExecStart=/usr/bin/systemd-tmpfiles --create
> /etc/tmpfiles.d/foo.conf
>
> [Install]
> WantedBy=multi-user.target

That is correct. If you use Ignition [1] instead, this workaround isn't
needed. This is due to the fact that Ignition runs before systemd,
allowing you to write the tmpfiles configs before the tmpfiles service
runs. This just isn't possible with coreos-cloudinit.

-Alex

[1]: https://coreos.com/ignition
signature.asc
Reply all
Reply to author
Forward
0 new messages