Managing Files, Directories and Links

You can use Ignition to create, replace or update files, directories or links.

This example creates a directory with the default mode (set to 0755: readable and recurseable by all), and writable only by the owner (by default root).

Example to create a directory with default ownership and permissions
variant: fcos
version: 1.5.0
storage:
  directories:
  - path: /opt/tools
    overwrite: true

This example creates a file named /var/helloworld with some content defined in-line. It also sets the file mode to 0644 (readable by all, writable by the owner) and sets ownership to dnsmasq:dnsmasq.

Example to create a file with in-line content
variant: fcos
version: 1.5.0
storage:
  files:
    - path: /var/helloworld
      overwrite: true
      contents:
        inline: Hello, world!
      mode: 0644
      user:
        name: dnsmasq
      group:
        name: dnsmasq

This example creates a file with its content fetched from a remote location. In this case, it fetches an HTTPS URL and expects the file to be compressed with gzip and will decompress it before writing it on the disk. The decompressed content is checked against the hash value specified in the config. The format is sha512- followed by the 128 hex characters given by the sha512sum command. The resulting file is made readable and executable by all.

Example to create a files from a remote source
variant: fcos
version: 1.5.0
storage:
  files:
    - path: /opt/tools/transmogrifier
      overwrite: true
      contents:
        source: https://mytools.example.com/path/to/archive.gz
        compression: gzip
        verification:
          hash: sha512-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
      mode: 0555

This example creates a symbolic link in /usr/local/bin to a path in /opt. This is useful to let local processes invoke a program without altering their PATH environment variable.

Example to create a symbolic link
variant: fcos
version: 1.5.0
storage:
  links:
    - path: /usr/local/bin/transmogrifier
      overwrite: true
      target: /opt/tools/transmogrifier
      hard: false

If you need a directory and some of its parents to be owned by a specific user, you currently have to explicitly list them in your Butane config. See butane#380 for the tracking issue in Butane for a future better syntax for this case.

Example to create directories with specific ownership
variant: fcos
version: 1.5.0
storage:
  directories:
    - path: /home/builder/.config
      user:
        name: builder
      group:
        name: builder
    - path: /home/builder/.config/systemd
      user:
        name: builder
      group:
        name: builder
    - path: /home/builder/.config/systemd/user
      user:
        name: builder
      group:
        name: builder
    - path: /home/builder/.config/systemd/user/default.target.wants
      user:
        name: builder
      group:
        name: builder
    - path: /home/builder/.config/systemd/user/timers.target.wants
      user:
        name: builder
      group:
        name: builder
    - path: /home/builder/.config/systemd/user/sockets.target.wants
      user:
        name: builder
      group:
        name: builder