Gestione di file, directory e collegamenti

Puoi usare Ignition per creare, sostituire o aggiornare file, directory o collegamenti.

Questo esempio crea una directory con il modo predefinito (impostato su 0755: leggibile e ricorsiva per tutti), e scrivibile solo dal proprietario (per impostazione predefinita root).

Esempio per creare una directory con proprietà e permessi predefiniti
variante: fcos
versione: 1.6.0
archiviazione:
  directory:
  - percorso: /opt/tools
    sovrascrivi: 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.6.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.6.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

Questo esempio crea un collegamento simbolico in /usr/local/bin a un percorso in /opt. Questo è utile per permettere ai processi locali di invocare un programma senza modificare la variabile d’ambiente PATH.

Example to create a symbolic link
variant: fcos
version: 1.6.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.6.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