Skip to content

Ansible Role linuxfabrik.lfops.grav

This role installs Grav (a simple file-based flat-file CMS platform) using PHP composer. For keeping Grav, Plugins and Themes up to date the role configures the Grav Package Manager (GPM).

It is possible to configure whether the Grav Admin Panel should be installed (it is installed by default). By default, you can access the admin by pointing your browser to http://grav.example.com/admin. You can simply log in with the username and password set in the role variables.

Available since LFOps 2.0.0.

Known Limitations

There might be more to implement:

  • https://learn.getgrav.org/17/security/configuration

Dependent Roles

Any LFOps playbook that installs this role runs these for you. Optional ones can be disabled via the playbook's skip variables.

Post-Installation Steps

  • Behind a reverse proxy that terminates TLS, set session.secure in the site's user/config/system.yaml. Grav otherwise sets the Secure flag on its session cookies only on requests it sees arriving over HTTPS, and the proxy talks plain HTTP to it. The role does not touch this file, since it belongs to the site content. Leave it unset for a site that browsers reach over plain HTTP, which could otherwise not log anyone in to the Admin Panel.

    yaml session: secure: true

Tags

grav

  • Install unzip.
  • Test if Grav is already installed.
  • composer create-project getgrav/grav {{ grav__install_dir }}.
  • chown -R apache:apache {{ grav__install_dir }}.
  • find {{ grav__install_dir }} -type f -exec chmod --changes 664 {} \;.
  • find {{ grav__install_dir }}/bin -type f -exec chmod --changes 775 {} \;.
  • find {{ grav__install_dir }} -type d -exec chmod --changes 775 {} \;.
  • find {{ grav__install_dir }} -type d -exec chmod --changes +s {} \;.
  • Deploy /etc/systemd/system/grav-selfupgrade.service.
  • Deploy /etc/systemd/system/grav-selfupgrade.timer.
  • Deploy /etc/systemd/system/grav-update.service.
  • Deploy /etc/systemd/system/grav-update.timer.
  • systemctl enable/disable grav-selfupgrade.timer --now.
  • systemctl enable/disable grav-update.timer --now.
  • Install the Administration Panel plugin for Grav.
  • Create Grav User Accounts.
  • Triggers: none.

grav:state

  • systemctl enable/disable grav-selfupgrade.timer --now.
  • systemctl enable/disable grav-update.timer --now.
  • Triggers: none.

grav:users

  • Install the Administration Panel plugin for Grav.
  • Create Grav User Accounts.
  • Triggers: none.

Mandatory Role Variables

grav__url

  • The Grav URL, without http:// or https://.
  • Type: String.

grav__users

  • Mandatory if using the Grav Admin Panel. Have a look at the example below for defining a user. The permissions key can be either a for Admin access only, s for Site access only and b for both Admin and Site access.
  • Type: List of dictionaries.

Example:

# mandatory
grav__url: 'grav.example.com'
grav__users:
  - user: 'firstname_lastname'
    fullname: 'Firstname Lastname'
    password: 'linuxfabrik'
    email: 'firstname.lastname@example.com'
    permissions: 'b'

Optional Role Variables

grav__install_dir

  • Grav installation directory.
  • Type: String.
  • Default: '/var/www/html/{{ grav__url }}'

grav__on_calendar_selfupgrade

  • Time to upgrading Grav CMS (Systemd-Timer notation).
  • Type: String.
  • Default: '22:{{ 59 | random(seed=inventory_hostname) }}'

grav__on_calendar_update

  • Time to update Grav Plugins and Themes (Systemd-Timer notation).
  • Type: String.
  • Default: '23:{{ 59 | random(seed=inventory_hostname) }}'

grav__skip_admin

  • If set to true, installation of the Admin Panel plugin will be skipped.
  • Type: Bool.
  • Default: false

grav__timer_selfupgrade_enabled

  • Enables/disables Systemd-Timer for upgrading Grav CMS.
  • Type: Bool.
  • Default: true

grav__timer_update_enabled

  • Enables/disables Systemd-Timer for updating Grav Plugins and Themes.
  • Type: Bool.
  • Default: true

Example:

# optional
grav__install_dir: '/var/www/html/grav'
grav__on_calendar_selfupgrade: '22:30'
grav__on_calendar_update: '23:30'
grav__skip_admin: false
grav__timer_selfupgrade_enabled: true
grav__timer_update_enabled: true

License

The Unlicense

Author Information

Linuxfabrik GmbH, Zurich