systemd_mount role for OpenStack-Ansible

tags

openstack, systemd_mount, cloud, ansible

category

*nix

This role will configure Systemd units:

Default variables

# Any optioned required to make the mount point work. If no options are
#  provided the default will be used. This list is comma separted.
#  https://www.freedesktop.org/software/systemd/man/systemd.mount.html#Options=
systemd_default_mount_options: 'defaults'

# The systemd mounts dictionary is a set of mounts that will be created. The
#  dictionary can contain the following options:
#  `config_overrides` -- (optional) used to inject extra configuration options into the mount file.
#  `what` -- (required) Define what will be mounted. This can be a network target.
#  `where` -- (required) Where will the "what" be mounted. Required when type is not swap.
#  `type` -- (required) The type of file system that will be mounted.
#  `options` -- (optional) Any optioned required to make the mount point work.
#                          If no options are provided the default will be used.
#                          This list is comma separted. See
#                          `systemd_default_mount_options` for more details.
#  `state` -- (optional) system state of the mount point. The default will omit
#                        the state so that it is not started or stopped
#                        unessisarily. If it is desirable for this role to
#                        start/stop the mount immediately this can be done by
#                        setting the state to ["started", "stopped", "absent"].
#                        If the state is absent the mount will be stopped and
#                        unit file deleted.
#  `enabled` -- (optional) Set a Boolean to enable or disable the mount, the
#                          default is set to "true".

# systemd_mounts:
#   - what: '/var/lib/machines.raw'
#     where: '/var/lib/machines'
#     type: 'btrfs'
#     options: 'loop'

#     state: 'started'
#     enabled: true
#   - config_overrides: {}
#     What: "10.1.10.1:/srv/nfs"
#     Where: "/var/lib/glance/images"
#     type: "nfs"
#     options: "_netdev,auto"

#   - what: "/openstack/swap.img"
#     priority: "0"
#     options: "%%"
#     type: "swap"
#     state: 'started'
#     enabled: true

systemd_mounts: []

Example playbook

.. code-block:: yaml

    - name: Create a systemd mount file for Mount1 and 2
      hosts: localhost
      become: true
      roles:
        - role: "systemd_mount"
          systemd_mounts:
            machines:
              what: '/var/lib/machines.raw'
              where: '/var/lib/machines'
              type: 'btrfs'
              options: 'loop'
              unit:
                ConditionPathExists:
                  - '/var/lib/machines.raw'
              state: 'started'
              enabled: true
            glance_images:
              config_overrides: {}
              What: "10.1.10.1:/srv/nfs"
              Where: "/var/lib/glance/images"
              type: "nfs"
              options: "_netdev,auto"
              unit:
                After:
                  - network.target

Tags

This role supports one tag: systemd-init.