---
- name: YNAB
  hosts: servers
  gather_facts: false
  tasks:
    - name: Create dir
      ansible.builtin.file:
        path: "{{ dir }}"
        state: directory
        mode: "0775"
    - name: Write files
      ansible.builtin.copy:
        src: "{{ item }}"
        dest: "{{ dir }}/"
        mode: preserve
      with_fileglob:
        - files/{{ app_name }}/*
        - files/{{ app_name }}/.*
    - name: Template ynab files
      ansible.builtin.template:
        src: "{{ item }}"
        dest: /mnt/data/ynab/{{ item | basename | regex_replace('\.j2$', '') }}
        mode: preserve
      with_fileglob:
        - templates/ynab/*.j2
      loop_control:
        label: "{{ item | basename }}"

  vars:
    app_name: ynab
    dir: /mnt/data/{{ app_name }}
    lcl_identifier: !vault |
      $ANSIBLE_VAULT;1.1;AES256
      61656566333163306638626338653665326238363861363166636434386237646332376466356239
      3232316637313266303438376563633363323838613035360a343032643239636539636264306536
      65323734393563643065383663313033643733666365653539346239396461643136343835333334
      3564346563386337610a353538393862353438613233373661353631326139663065366463626132
      6537
    lcl_password: !vault |
      $ANSIBLE_VAULT;1.1;AES256
      62363534396534663536316461666565356462666564643162643364663835356230323233386165
      3639393736303662346135353236623363306264636561650a393063346239363030363130636137
      33343039643932613834376131626665643737306433316562373238663332326231643830396539
      6465613462623065370a376439336338306333613038353865323537303439333831373062626537
      6563
    ynab_token: !vault |
      $ANSIBLE_VAULT;1.1;AES256
      38663565353834633363303766613132663963353863373837616634643430653732383139316432
      3862616565373734363330353464383064333235316534330a303638383062336165613030666231
      36376331623231663466323065623030666133616130376639363430623065303663633361353764
      3366373866343638630a383466396662383632396238626466616239333632633362393366626365
      31393332613134363037363931306465646230356634353539366438643336643363333133626434
      35333932663865316438393932373332623434653431356264336566613834376139616662616434
      61656639333036333539316361353032313239613331386266353764343363656438306462323338
      38386238343131383338
    ynab_account_id: !vault |
      $ANSIBLE_VAULT;1.1;AES256
      63646338376535393861353732333262336630363935646239303232313337386134393632626431
      3433623138613366616662643764353266643061393739370a663839616265356462656166636137
      31653534613565323336653161613361396635326361313562313764353262636333306263613232
      3831643861666536340a393861363032616663383062333535633636363538303332666563346363
      61666135613264356335326364366631646165323661656530393166383165353562646564306432
      3162663936653930306361343465383331633436653431653765
    ynab_budget_id: !vault |
      $ANSIBLE_VAULT;1.1;AES256
      30616437653535643734303064636436313330653430326137616533616634643762613636613737
      3035626137636434303236353261623939386364383739610a363536633230343564386333363465
      35373963376238363837383165626366363739356337353039343662626438343336353533636537
      6634393231313632350a366432666137396264393933363062613430633133393835663765663861
      36373833656562393830323535653337383135613538356262323033643930343564396461666462
      6331393437306161383537626462393239313363346163343765
    webhook_url: !vault |
      $ANSIBLE_VAULT;1.1;AES256
      33373335313163346635663038613063366439326665643164313132626664373066313966333762
      3662616230353165386235323938373430636131633565320a353366616463363435363637656633
      32636336613635353935396435633631396463303563333166666566373238376332626262663163
      6232363435393337630a373034383165366333316436386131646336633331636434663463363866
      39343635393139613638303439393133663566336566376266303761326666306432306262336563
      32656461353530353230366436623233626364316536383939646238323630346261306264656264
      34376162633764376637613136363731643162393864643565326235363838626231363936316462
      65616534633964613864