---
- name: Configure Hosts and Opensesame
  hosts: all
  collections:
    - elektra_initiative.libelektra
  tasks:
    - name: Mount Configuration
      elektra:
        keys:
          - system:
              elektra:
                mountpoints:
                  system:\/hosts:
                    - value: ""
                    - keys:
                        config:
                          - value: ""
                          - keys:
                              glob:
                                set:
                                  "#0":
                                    - value: /ipv4/*
                                    - meta:
                                        check:
                                          ipaddr:
                                            - value: ipv4
                                          validation:
                                            - value: ^[0-9.]+$
                                            - keys:
                                                match:
                                                  - value: LINE
                                                message:
                                                  - value: Character present not suitable for ipv4 address
                                  "#1":
                                    - value: /ipv6/*
                                    - meta:
                                        check:
                                          ipaddr:
                                            - value: ipv6
                                          validation:
                                            - value: ^[0-9A-Fa-f.:]+$
                                            - keys:
                                                match:
                                                  - value: LINE
                                                message:
                                                  - value: Character present not suitable for ipv6 address
                                  "#2":
                                    - value: /ipv4/*/*
                                  "#3":
                                    - value: /ipv6/*/*
                                  "#4":
                                    - value: /*
                                    - meta:
                                        trigger:
                                          error:
                                            - value: 162
                                    - keys:
                                        flags:
                                          - value: ""
                        definition:
                          path:
                            - value: /etc/hosts
                            - keys:
                                absolute:
                                  - value: true
                          positions:
                            get:
                              poststorage:
                                "#0":
                                  - value: glob
                              resolver:
                                - value: resolver
                              storage:
                                - value: hosts
                            set:
                              commit:
                                - value: resolver
                              precommit:
                                "#0":
                                  - value: sync
                              prestorage:
                                "#0":
                                  - value: glob
                                "#1":
                                  - value: error
                                "#2":
                                  - value: network
                              resolver:
                                - value: resolver
                              rollback:
                                - value: resolver
                              storage:
                                - value: hosts
                        plugins:
                          backend:
                            - value: ""
                            - keys:
                                name:
                                  - value: backend
                          error:
                            - value: ""
                            - keys:
                                name:
                                  - value: error
                          glob:
                            - value: ""
                            - keys:
                                name:
                                  - value: glob
                          hosts:
                            - value: ""
                            - keys:
                                name:
                                  - value: hosts
                          network:
                            - value: ""
                            - keys:
                                name:
                                  - value: network
                          resolver:
                            - value: ""
                            - keys:
                                name:
                                  - value: resolver_fm_hpu_b
                          sync:
                            - value: ""
                            - keys:
                                name:
                                  - value: sync
    - name: Set Elektra Keys
      elektra:
        keys:
          - system:
              hosts:
                ipv4:
                  nextcloud.maxirlinger.at:
                    - value: 65.108.157.177
                    - meta:
                        comment:
                          "#0":
                            - value: ""
                        order:
                          - value: 1
              sw:
                libelektra:
                  opensesame:
                    "#0":
                      current:
                        audio:
                          - value: ""
                          - meta:
                              comment:
                                "#1":
                                  space:
                                    - value: ""
                                  start:
                                    - value: ""
                              order:
                                - value: 7
                              tomltype:
                                - value: simpletable
                          - keys:
                              alarm:
                                - value: /home/olimex/alarm.ogg
                                - meta:
                                    order:
                                      - value: 8
                                    tomltype:
                                      - value: string_basic
                                    type:
                                      - value: string
                        environment:
                          - value: ""
                          - meta:
                              comment:
                                "#1":
                                  space:
                                    - value: ""
                                  start:
                                    - value: ""
                              order:
                                - value: 9
                              tomltype:
                                - value: simpletable
                          - keys:
                              name:
                                - value: corporate
                                - meta:
                                    order:
                                      - value: 10
                                    tomltype:
                                      - value: string_basic
                                    type:
                                      - value: string
                        nextcloud:
                          - value: ""
                          - meta:
                              order:
                                - value: 0
                              tomltype:
                                - value: simpletable
                          - keys:
                              chat:
                                - value: '{{ nc_chat }}'
                                - meta:
                                    order:
                                      - value: 2
                                    tomltype:
                                      - value: string_basic
                                    type:
                                      - value: string
                                - keys:
                                    licht:
                                      - value: '{{ nc_chat_licht }}'
                                      - meta:
                                          order:
                                            - value: 3
                                          tomltype:
                                            - value: string_basic
                                          type:
                                            - value: string
                                    ping:
                                      - value: '{{ nc_chat_ping }}'
                                      - meta:
                                          order:
                                            - value: 4
                                          tomltype:
                                            - value: string_basic
                                          type:
                                            - value: string
                              pass:
                                - value: '{{ nc_password }}'
                                - meta:
                                    order:
                                      - value: 6
                                    tomltype:
                                      - value: string_basic
                                    type:
                                      - value: string
                              url:
                                - value: https://nextcloud.maxirlinger.at
                                - meta:
                                    order:
                                      - value: 1
                                    tomltype:
                                      - value: string_basic
                                    type:
                                      - value: string
                              user:
                                - value: '{{ nc_user }}'
                                - meta:
                                    order:
                                      - value: 5
                                    tomltype:
                                      - value: string_basic
                                    type:
                                      - value: string
                        sensors:
                          - value: ""
                          - meta:
                              array:
                                - value: "#1"
                              order:
                                - value: 11
                              tomltype:
                                - value: tablearray
                          - keys:
                              "#0":
                                - value: ""
                                - meta:
                                    comment:
                                      "#1":
                                        space:
                                          - value: ""
                                        start:
                                          - value: ""
                                - keys:
                                    alarm:
                                      - value: 250
                                      - meta:
                                          order:
                                            - value: 13
                                          type:
                                            - value: long_long
                                    chat:
                                      - value: 200
                                      - meta:
                                          order:
                                            - value: 14
                                          type:
                                            - value: long_long
                                    loc:
                                      - value: CO2 sensor
                                      - meta:
                                          order:
                                            - value: 12
                                          tomltype:
                                            - value: string_basic
                                          type:
                                            - value: string
                              "#1":
                                - value: ""
                                - meta:
                                    comment:
                                      "#1":
                                        space:
                                          - value: ""
                                        start:
                                          - value: ""
                                - keys:
                                    alarm:
                                      - value: 100
                                      - meta:
                                          order:
                                            - value: 16
                                          type:
                                            - value: long_long
                                    chat:
                                      - value: 50
                                      - meta:
                                          order:
                                            - value: 17
                                          type:
                                            - value: long_long
                                    loc:
                                      - value: Smoke sensor
                                      - meta:
                                          order:
                                            - value: 15
                                          tomltype:
                                            - value: string_basic
                                          type:
                                            - value: string
...