Providing Data Persisence on Prometheus Containers with NFS on Synology

Made some progress on one of my distraction projects over the past couple days. I’d been working on creating an Ansible role to deploy a Prometheus container with persistent data backed by NFS on my rPi cluster. Getting the NFS mount to work with Prometheus was a challenge. Relevant stanzas from the role’s main.yml:

      - name: "Creates named docker volume for prometheus persistent data" 
            volume_name: prometheus_persist
            state: present
                type: nfs
                o: "addr={{ nfs_server }},rw"
                device: ":{{ prometheus_nfs_path }}"
      - name: "Deploy prometheus container"
            name: prometheus
            hostname: prometheus
            image: prom/prometheus
            restart_policy: always
            state: started
            ports: 9090:9090
              - "{{ prometheus_config_path }}:/etc/prometheus"
              - source: prometheus_persist
                target: /prometheus
                read_only: no
                type: volume        
                env: strict

However I was getting permission denied on /prometheus when deploying the container. A redditor pointed me in the direction of the solution. Since NFS is provided by my Synology, I can’t set no_root_squash, but by mapping all users to admin in the share’s squashing settings, I could allow the container to set permissions appropriately. Progress!

Written on