[
  {
    "name": "Deploy panproto API servers",
    "hosts": "api_servers",
    "become": true,
    "vars": {
      "app_version": "0.2.0",
      "app_user": "panproto",
      "app_dir": "/opt/panproto"
    },
    "tasks": [
      {
        "name": "Create application user",
        "ansible.builtin.user": {
          "name": "{{ app_user }}",
          "system": true,
          "shell": "/usr/sbin/nologin"
        }
      },
      {
        "name": "Download release binary",
        "ansible.builtin.get_url": {
          "url": "https://github.com/aaronstevenwhite/panproto/releases/download/v{{ app_version }}/panproto-api-linux-amd64",
          "dest": "{{ app_dir }}/panproto-api",
          "mode": "0755"
        }
      },
      {
        "name": "Deploy systemd unit",
        "ansible.builtin.template": {
          "src": "panproto-api.service.j2",
          "dest": "/etc/systemd/system/panproto-api.service"
        },
        "notify": "restart panproto"
      }
    ],
    "handlers": [
      {
        "name": "restart panproto",
        "ansible.builtin.systemd": {
          "name": "panproto-api",
          "state": "restarted",
          "daemon_reload": true
        }
      }
    ]
  }
]
