FreeTAKTeam / FreeTAKHub-Installation

FreeTAKHub-Installation
Eclipse Public License 2.0
33 stars 29 forks source link

ZTI: UI login fails, Ansible picks up IPv6 #105

Closed mighkel closed 5 months ago

mighkel commented 6 months ago

Installed FTS-UI via Zero-Touch on Ubuntu 22.04 on SSDNodes VPS wget -qO - bit.ly/freetakhub2 | sudo bash Per: https://freetakteam.github.io/FreeTAKServer-User-Docs/Installation/Ansible/ZeroTouchInstall/

After install, entered [IPv4 address]:5000, and UI login displays. Attempt to login (admin:password) Result:

  File "/usr/lib/python3/dist-packages/requests/models.py", line 382, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
                                                      ^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/urllib3/util/url.py", line 394, in parse_url
    return six.raise_from(LocationParseError(source_url), None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 3, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: http://2602:blah:b:l:a:hbl:a:h:19023/AuthenticateUser

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/eventlet/wsgi.py", line 569, in handle_one_response
    result = self.application(self.environ, start_response)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
                                                ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.11/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
                                                ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.11/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/FreeTAKServer-UI/app/base/routes.py", line 42, in login
    user = requests.get(f"{app.config['PROTOCOL']}://{app.config['IP']}:{app.config['PORT']}/AuthenticateUser", params={"username": username, "password": password}, headers={"Authorization": f"{app.config['APIKEY']}"})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 530, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 458, in prepare_request
    p.prepare(
  File "/usr/lib/python3/dist-packages/requests/models.py", line 316, in prepare
    self.prepare_url(url, params)
  File "/usr/lib/python3/dist-packages/requests/models.py", line 384, in prepare_url
    raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: http://2602:blah:b:l:a:hbl:a:h:19023/AuthenticateUser

Ansible Log:


PLAY [Install FreeTAKServer and all components] ***************************************************************

TASK [Gathering Facts] ****************************************************************************************
ok: [localhost]

TASK [cleanup /tmp/*] *****************************************************************************************
changed: [localhost]

TASK [common : Include Ubuntu-specific variables] *************************************************************
ok: [localhost]

TASK [common : Setup] *****************************************************************************************
included: /root/FreeTAKHub-Installation/roles/common/tasks/setup-Ubuntu.yml for localhost

TASK [common : Update apt] ************************************************************************************
ok: [localhost]

TASK [common : Detect systemctl file] *************************************************************************
ok: [localhost]

TASK [common : Create systemctl backup] ***********************************************************************
skipping: [localhost]

TASK [common : Use systemctl workaround] **********************************************************************
changed: [localhost]

TASK [python3 : Setup] ****************************************************************************************
included: /root/FreeTAKHub-Installation/roles/python3/tasks/setup-Ubuntu.yml for localhost

TASK [python3 : Include Ubuntu-specific variables] ************************************************************
ok: [localhost]

TASK [python3 : Install apt packages] *************************************************************************
ok: [localhost]

TASK [python3 : Install pip packages] *************************************************************************
changed: [localhost]

TASK [freetakserver : Include Ubuntu-specific variables] ******************************************************
ok: [localhost]

TASK [freetakserver : Include FTSConfig variables] ************************************************************
ok: [localhost]

TASK [freetakserver : Get public IPv4] ************************************************************************
ok: [localhost]

TASK [freetakserver : Set public IPv4] ************************************************************************
ok: [localhost]

TASK [freetakserver : Print IPv4] *****************************************************************************
ok: [localhost] => {
    "msg": "fts_public_ipv4 = 2602:blah:b:l:a:hbl:a:h"
}

TASK [freetakserver : Set localhost IPv4] *********************************************************************
ok: [localhost]

TASK [freetakserver : Get the latest freetakserver version] ***************************************************
skipping: [localhost]

TASK [freetakserver : Set fts_version] ************************************************************************
skipping: [localhost]

TASK [freetakserver : Setup] **********************************************************************************
included: /root/FreeTAKHub-Installation/roles/freetakserver/tasks/setup-Ubuntu.yml for localhost

TASK [freetakserver : Delete PyYAML] **************************************************************************
changed: [localhost] => (item=rm -rf /usr/lib/python3/dist-packages/yaml)
changed: [localhost] => (item=rm -rf /usr/lib/python3/dist-packages/PyYAML-*)
changed: [localhost] => (item=rm -rf /usr/lib/python3.11/site-packages/PyYAML-*)

TASK [freetakserver : Install apt dependencies] ***************************************************************
changed: [localhost]

TASK [freetakserver : Install FreeTAKServer] ******************************************************************
changed: [localhost]

TASK [freetakserver : Configure] ******************************************************************************
included: /root/FreeTAKHub-Installation/roles/freetakserver/tasks/configure-Ubuntu.yml for localhost

TASK [freetakserver : Template FTSConfig.yaml config file] ****************************************************
changed: [localhost]

TASK [freetakserver : Change FirstStart to False in MainConfig.py] ********************************************
ok: [localhost]

TASK [freetakserver : Template unit file] *********************************************************************
changed: [localhost]

TASK [freetakserver : Kill any currently running processes] ***************************************************
included: /root/FreeTAKHub-Installation/roles/freetakserver/tasks/../../common/tasks/kill.yml for localhost

TASK [freetakserver : Get running processes] ******************************************************************
changed: [localhost]

TASK [freetakserver : Kill running processes] *****************************************************************
skipping: [localhost]

TASK [freetakserver : wait_for] *******************************************************************************
skipping: [localhost]

TASK [freetakserver : Force kill stuck processes] *************************************************************
skipping: [localhost]

TASK [freetakserver : Enable and set service] *****************************************************************
included: /root/FreeTAKHub-Installation/roles/freetakserver/tasks/../../common/tasks/service.yml for localhost

TASK [freetakserver : Enable service] *************************************************************************
changed: [localhost]

TASK [freetakserver : Set service state] **********************************************************************
changed: [localhost]

TASK [freetakserver_ui : Include Ubuntu-specific variables] ***************************************************
ok: [localhost]

TASK [freetakserver_ui : Set IPv4] ****************************************************************************
ok: [localhost]

TASK [freetakserver_ui : Print IPv4] **************************************************************************
ok: [localhost] => {
    "msg": "fts_ui_ipv4 = 127.0.0.1"
}

TASK [freetakserver_ui : Setup] *******************************************************************************
included: /root/FreeTAKHub-Installation/roles/freetakserver_ui/tasks/setup-Ubuntu.yml for localhost

TASK [freetakserver_ui : Delete PyYAML] ***********************************************************************
changed: [localhost] => (item=rm -rf /usr/lib/python3/dist-packages/yaml)
changed: [localhost] => (item=rm -rf /usr/lib/python3/dist-packages/PyYAML-*)
changed: [localhost] => (item=rm -rf /usr/lib/python3.11/site-packages/PyYAML-*)

TASK [freetakserver_ui : Install apt packages] ****************************************************************
ok: [localhost]

TASK [freetakserver_ui : Install pip packages] ****************************************************************
ok: [localhost]

TASK [freetakserver_ui : Install FreeTAKServer-UI] ************************************************************
changed: [localhost]

TASK [freetakserver_ui : Configure] ***************************************************************************
included: /root/FreeTAKHub-Installation/roles/freetakserver_ui/tasks/configure-Ubuntu.yml for localhost

TASK [freetakserver_ui : Template config file] ****************************************************************
changed: [localhost]

TASK [freetakserver_ui : Template unit file] ******************************************************************
changed: [localhost]

TASK [freetakserver_ui : Kill any currently running processes] ************************************************
included: /root/FreeTAKHub-Installation/roles/freetakserver_ui/tasks/../../common/tasks/kill.yml for localhost

TASK [freetakserver_ui : Get running processes] ***************************************************************
changed: [localhost]

TASK [freetakserver_ui : Kill running processes] **************************************************************
skipping: [localhost]

TASK [freetakserver_ui : wait_for] ****************************************************************************
skipping: [localhost]

TASK [freetakserver_ui : Force kill stuck processes] **********************************************************
skipping: [localhost]

TASK [freetakserver_ui : Enable service] **********************************************************************
changed: [localhost]

TASK [freetakserver_ui : Set service state] *******************************************************************
changed: [localhost]

TASK [freetakserver_ui : Notify handlers to print at the end] *************************************************
changed: [localhost]

TASK [murmur : Include Ubuntu-specific variables] *************************************************************
ok: [localhost]

TASK [murmur : Get public IPv4] *******************************************************************************
ok: [localhost]

TASK [murmur : Set public IPv4] *******************************************************************************
ok: [localhost]

TASK [murmur : Print IPv4] ************************************************************************************
ok: [localhost] => {
    "msg": "murmur_ipv4 = 2602:blah:b:l:a:hbl:a:h"
}

TASK [murmur : Setup] *****************************************************************************************
included: /root/FreeTAKHub-Installation/roles/murmur/tasks/setup-Ubuntu.yml for localhost

TASK [murmur : Install Mumur (Mumble Server)] *****************************************************************
changed: [localhost]

TASK [murmur : Configure] *************************************************************************************
included: /root/FreeTAKHub-Installation/roles/murmur/tasks/configure-Ubuntu.yml for localhost

TASK [murmur : generate the Murmur config file] ***************************************************************
changed: [localhost]

TASK [murmur : Enable and set service] ************************************************************************
included: /root/FreeTAKHub-Installation/roles/murmur/tasks/../../common/tasks/service.yml for localhost

TASK [murmur : Enable service] ********************************************************************************
changed: [localhost]

TASK [murmur : Set service state] *****************************************************************************
changed: [localhost]

TASK [murmur : Generate random superuser password] ************************************************************
ok: [localhost]

TASK [murmur : Write superuser password] **********************************************************************
changed: [localhost]

TASK [murmur : set superuser password] ************************************************************************
changed: [localhost]

TASK [murmur : restart murmur] ********************************************************************************
changed: [localhost]

TASK [murmur : Notify handlers] *******************************************************************************
changed: [localhost]

TASK [videoserver : Include Ubuntu-specific variables] ********************************************************
ok: [localhost]

TASK [videoserver : Get public IPv4] **************************************************************************
ok: [localhost]

TASK [videoserver : Set public IPv4] **************************************************************************
ok: [localhost]

TASK [videoserver : Print IPv4] *******************************************************************************
ok: [localhost] => {
    "msg": "videoserver_public_ipv4 = 2602:blah:b:l:a:hbl:a:h"
}

TASK [videoserver : Set localhost IPv4] ***********************************************************************
ok: [localhost]

TASK [videoserver : Include x86_64-specific variables] ********************************************************
ok: [localhost]

TASK [videoserver : Setup] ************************************************************************************
included: /root/FreeTAKHub-Installation/roles/videoserver/tasks/setup-Ubuntu.yml for localhost

TASK [videoserver : Determine CPU architecture] ***************************************************************
ok: [localhost]

TASK [videoserver : Translate CPU architecture if x86_64] *****************************************************
ok: [localhost]

TASK [videoserver : Set rtsp-simple-server package name] ******************************************************
ok: [localhost]

TASK [videoserver : Get RTSP Simple Server release information with GitHub API] *******************************
ok: [localhost]

TASK [videoserver : Set facts from GitHub API release information] ********************************************
ok: [localhost]

TASK [videoserver : Download rtsp-simple-server package to /tmp] **********************************************
changed: [localhost]

TASK [videoserver : Unarchive rtsp-simple-server_v0.18.0_linux_amd64.tar.gz to /tmp] **************************
changed: [localhost]

TASK [videoserver : Copy /tmp/rtsp-simple-server to /usr/local/bin/rtsp-simple-server] ************************
changed: [localhost]

TASK [videoserver : Configure] ********************************************************************************
included: /root/FreeTAKHub-Installation/roles/videoserver/tasks/configure-Ubuntu.yml for localhost

TASK [videoserver : Template config file] *********************************************************************
changed: [localhost]

TASK [videoserver : Template unit file] ***********************************************************************
changed: [localhost]

TASK [videoserver : Kill any currently running processes] *****************************************************
included: /root/FreeTAKHub-Installation/roles/videoserver/tasks/../../common/tasks/kill.yml for localhost

TASK [videoserver : Get running processes] ********************************************************************
changed: [localhost]

TASK [videoserver : Kill running processes] *******************************************************************
skipping: [localhost]

TASK [videoserver : wait_for] *********************************************************************************
skipping: [localhost]

TASK [videoserver : Force kill stuck processes] ***************************************************************
skipping: [localhost]

TASK [videoserver : Enable and set service] *******************************************************************
included: /root/FreeTAKHub-Installation/roles/videoserver/tasks/../../common/tasks/service.yml for localhost

TASK [videoserver : Enable service] ***************************************************************************
changed: [localhost]

TASK [videoserver : Set service state] ************************************************************************
changed: [localhost]

TASK [videoserver : Notify handlers to print at the end] ******************************************************
changed: [localhost]

TASK [nodered : Include Ubuntu-specific variables] ************************************************************
ok: [localhost]

TASK [nodered : Set IPv4] *************************************************************************************
ok: [localhost]

TASK [nodered : Print IPv4] ***********************************************************************************
ok: [localhost] => {
    "msg": "noderedserver_ipv4 = 127.0.0.1"
}

TASK [nodered : Get public IPv4] ******************************************************************************
ok: [localhost]

TASK [nodered : Set public IPv4] ******************************************************************************
ok: [localhost]

TASK [nodered : Install] **************************************************************************************
included: /root/FreeTAKHub-Installation/roles/nodered/tasks/setup-Ubuntu.yml for localhost

TASK [nodered : wait for lock-frontend release] ***************************************************************
ok: [localhost]

TASK [nodered : Install apt dependencies] *********************************************************************
changed: [localhost] => (item=npm)
ok: [localhost] => (item=nodejs)

TASK [nodered : Install packages with npm] ********************************************************************
changed: [localhost] => (item=node-red@v2-maintenance)
changed: [localhost] => (item=node-red-admin)
changed: [localhost] => (item=node-red-contrib-web-worldmap)

TASK [nodered : Install Node-RED nodes with npm] **************************************************************
changed: [localhost] => (item=node-red-contrib-config)
changed: [localhost] => (item=node-red-dashboard)
changed: [localhost] => (item=node-red-contrib-credentials)

TASK [nodered : Create flows directory] ***********************************************************************
changed: [localhost]

TASK [nodered : Template unit file] ***************************************************************************
changed: [localhost]

TASK [nodered : Enable service] *******************************************************************************
changed: [localhost]

TASK [nodered : Template settings file] ***********************************************************************
changed: [localhost]

TASK [nodered : Set service state] ****************************************************************************
FAILED - RETRYING: [localhost]: Set service state (20 retries left).
changed: [localhost]

TASK [nodered : Template backup Node-RED flows] ***************************************************************
changed: [localhost] => (item=salute.json)
changed: [localhost] => (item=videochecker.json)
changed: [localhost] => (item=webmap.json)

TASK [nodered : Template flows.json to /tmp/flows.json] *******************************************************
changed: [localhost]

TASK [nodered : Configure] ************************************************************************************
included: /root/FreeTAKHub-Installation/roles/nodered/tasks/configure-Ubuntu.yml for localhost

TASK [nodered : Ensure nodered group exists] ******************************************************************
changed: [localhost]

TASK [nodered : Ensure nodered user is in nodered group] ******************************************************
changed: [localhost]

TASK [nodered : Restart NodeRed Unit] *************************************************************************
changed: [localhost]

TASK [nodered : Wait for NodeRed service to start] ************************************************************
FAILED - RETRYING: [localhost]: Wait for NodeRed service to start (6 retries left).
ok: [localhost]

TASK [nodered : Clone FreeTAKHub_VideoChecker repository] *****************************************************
changed: [localhost]

TASK [nodered : Clone FreeTAKHub_SALUTE repository] ***********************************************************
changed: [localhost]

TASK [nodered : Clone FreeTAKHub_Webmap repository] ***********************************************************
changed: [localhost]

TASK [nodered : Authenticate to NodeRed Admin API] ************************************************************
ok: [localhost]

TASK [nodered : Make available NodeRed Admin Token] ***********************************************************
ok: [localhost]

TASK [nodered : Wait until Node-RED import port is open] ******************************************************
ok: [localhost]

TASK [nodered : Import Node-RED FTH Config flow via HTTP POST] ************************************************
ok: [localhost]

TASK [nodered : Import FTH Videochecker flow via HTTP POST] ***************************************************
ok: [localhost]

TASK [nodered : Import FTH SALUTE flow via HTTP POST] *********************************************************
ok: [localhost]

TASK [nodered : Import FTH Webmap flow via HTTP POST] *********************************************************
ok: [localhost]

TASK [nodered : Wait for Video Server to be available] ********************************************************
skipping: [localhost]

TASK [nodered : Reload Node-RED flows] ************************************************************************
skipping: [localhost]

TASK [nodered : Notify handlers to print at the end] **********************************************************
changed: [localhost]

RUNNING HANDLER [freetakserver_ui : print fts_ui url] *********************************************************
ok: [localhost] => {
    "msg": "FreeTAKServer-UI URL: http://127.0.0.1:5000/"
}

RUNNING HANDLER [freetakserver_ui : print fts_ui credentials] *************************************************
ok: [localhost] => {
    "msg": "username: admin     password: password"
}

RUNNING HANDLER [murmur : print murmur ip] ********************************************************************
ok: [localhost] => {
    "msg": "Murmur (Mumble Server) IP: 2602:blah:b:l:a:hbl:a:h"
}

RUNNING HANDLER [murmur : print murmur credentials] ***********************************************************
ok: [localhost] => {
    "msg": "username: SuperUser     password: blahblahblah"
}

RUNNING HANDLER [murmur : print reconfigure message] **********************************************************
ok: [localhost] => {
    "msg": "to reconfigure murmur (mumble server) enter: sudo dpkg-reconfigure mumble-server"
}

RUNNING HANDLER [videoserver : print videoserver url] *********************************************************
ok: [localhost] => {
    "msg": "Video Server URL: http://127.0.0.1:9997/v1/config/get"
}

RUNNING HANDLER [nodered : print nodered url] *****************************************************************
ok: [localhost] => {
    "msg": "Node-RED Server URL: http://127.0.0.1:1880/"
}

RUNNING HANDLER [nodered : print nodered token] ***************************************************************
ok: [localhost] => {
    "msg": "Node-RED Server Token: blahblahblah"
}
phreed commented 5 months ago

This problem is related to ZTI getting an inappropriate IP addr for the use case. The default IP address is obtained via http://ifconfig.me/ip.

We could use alternate ansible roles or environment variables to distinguish between the use cases:

mighkel commented 5 months ago

I wouldn't suggest to compromise the nature of "ZeroTouch" by making it "Well, maybe a couple of touches..." but the Custom Deployment (Advanced) Ansible install, while asking for user input for package selection, could prompt the user to input the desired IP, be it the public IP, or their VPN IP.
Taking it a step further: "Do you have VPN installed?" Y "Enter the public (non-VPN) IPv4 address:" 123.456.0.91 "Enter the VPN IPv4 address:" 123.987.0.42 "Route all FTS traffic through VPN [123.987.0.42] ?" Y If Y, then config firewall to allow all FTS ports in/out VPN IP, and only allow SSH in on public IP. User can close that later.

phreed commented 4 months ago

@mighkel I made a fix that should accommodate most of the use cases. The easy_install.sh takes an additional argument --ip-addr which can be used to suppress guessing of the IP address and provide the address to be used. The user documentation has a corresponding PR which describes the revised approach for installing which should be committed soon.

wget -qO - bit.ly/freetakhub2 | sudo bash -s -- --ip-addr 123.456.0.91