lucasheld / ansible-uptime-kuma

Ansible collection of modules to configure Uptime Kuma
GNU General Public License v3.0
144 stars 19 forks source link

feat: Add 2fa login support #12

Closed larsl-net closed 1 year ago

larsl-net commented 1 year ago

Add 2FA support to the login module.

Usage example:

- name: 'Start maintenance'
  hosts: 'localhost'
  gather_facts: false
  vars:
    uptime_kuma_totp: '{{ lookup("hashi_vault", "secret=totp/code/uptime-kuma", errors="ignore") | default("")}}'
  tasks:
    - name: 'Uptime Kuma login'
      lucasheld.uptime_kuma.login:
        api_url: '{{ uptime_kuma_url }}'
        api_username: '{{ uptime_kuma_user }}'
        api_password: '{{ uptime_kuma_password }}'
        api_2fa: '{{ uptime_kuma_totp.code }}'
      register: result
lucasheld commented 1 year ago

Thank you!

mishac commented 1 year ago

I'm getting "Unsupported parameters for (lucasheld.uptime_kuma.monitor) module: api_2fa." when I try this.

lucasheld commented 1 year ago

You are right. This is implemented for the login module only. So you have to login (with username, password and 2fa) to get the token and with that token you can use the monitor module. I think I should add the api_2fa parameter to all other modules too.

mishac commented 1 year ago

oh that worked! I was lazy and set things up the "easy" way without saving and reusing the token. it works now for me.