ceph / chacra

A binary/file REST API to aid in multi-distro|arch|release management
9 stars 16 forks source link

deploy chacra failed #286

Open hjwsm1989 opened 2 years ago

hjwsm1989 commented 2 years ago

hosts file is

[test]
chacra1.xsky.com short_hostname=chacra1

deply.yml is

- hosts: test
  user: root
  roles:
    - common
    - repos
    - statsd
  vars:
     app_name: "chacra"
     use_ssl: true
     wsgi_file: wsgi.py
     wsgi_callable: application
     ansible_ssh_port: 22
     binary_root: "/opt/binaries"
     repos_root: "/opt/repos"
     branch: "master"
     development_server: true
     purge_repos: True
     fqdn: "{{ inventory_hostname }}"
     # required for first deploy
     api_user: "admin"
     api_key: "secret"
     # graphite reporting for statsd
     graphite_host: "3.shaman.xsky.com"
     # required
     graphite_api_key: '1234-asdf-1234'
     # callbacks
     callback_url: "https://3.shaman.xsky.com/api/repos/"
     # required for first deploy
     callback_user: "admin"
     callback_key: "secret"
     callback_verify_ssl: False
     health_ping: true
     health_ping_url: "https://3.shaman.xsky.com/api/nodes/"
     # use_letsencrypt: True
     # nginx_ssl_cert_path: "/etc/letsencrypt/live/{{ fqdn }}/fullchain.pem"
     # nginx_ssl_key_path: "/etc/letsencrypt/live/{{ fqdn }}/privkey.pem"
     nginx_ssl_cert_path: "/etc/ssl/certs/{{ fqdn }}-bundled.crt"
     nginx_ssl_key_path: "/etc/ssl/private/{{ fqdn }}.key"
     combine_deb_repos: False

The deploy command is 'ansible-playbook -vvv -i hosts deploy.yml'

it's failed with

TASK [common : populate the database for chacra] ***************************************************************************************************************************************************************************************
task path: /opt/chacra/src/chacra/deploy/playbooks/roles/common/tasks/postgresql.yml:81
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/commands/command.py
<chacra1.xsky.com> ESTABLISH SSH CONNECTION FOR USER: root
<chacra1.xsky.com> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/d61856f8b9 chacra1.xsky.com '/bin/sh -c '"'"'ALEMBIC_CONFIG=/opt/chacra/src/chacra/alembic-prod.ini /usr/bin/python && sleep 0'"'"''
<chacra1.xsky.com> (1, '\n{"changed": true, "end": "2021-08-06 16:34:13.372460", "stdout": "==> LOADING ENVIRONMENT\\nbasepath=/opt/chacra/src/chacra,module_name=prod", "cmd": ["/opt/chacra/bin/pecan", "populate", "/opt/chacra/src/chacra/prod.py"], "failed": true, "delta": "0:00:02.304443", "stderr": "Traceback (most recent call last):\\n  File \\"/opt/chacra/bin/pecan\\", line 8, in <module>\\n    sys.exit(CommandRunner.handle_command_line())\\n  File \\"/opt/chacra/lib/python2.7/site-packages/pecan/commands/base.py\\", line 96, in handle_command_line\\n    runner.run(sys.argv[1:])\\n  File \\"/opt/chacra/lib/python2.7/site-packages/pecan/commands/base.py\\", line 91, in run\\n    self.commands[ns.command_name]().run(ns)\\n  File \\"/opt/chacra/lib/python2.7/site-packages/chacra/commands/populate.py\\", line 34, in run\\n    self.load_app()\\n  File \\"/opt/chacra/lib/python2.7/site-packages/pecan/commands/base.py\\", line 162, in load_app\\n    return load_app(self.args.config_file)\\n  File \\"/opt/chacra/lib/python2.7/site-packages/pecan/core.py\\", line 213, in load_app\\n    set_config(config, overwrite=True)\\n  File \\"/opt/chacra/lib/python2.7/site-packages/pecan/configuration.py\\", line 253, in set_config\\n    config = conf_from_file(config)\\n  File \\"/opt/chacra/lib/python2.7/site-packages/pecan/configuration.py\\", line 183, in conf_from_file\\n    *imp.find_module(module_name, [basepath])\\n  File \\"/opt/chacra/src/chacra/prod.py\\", line 5, in <module>\\n    from prod_db import sqlalchemy\\nImportError: No module named prod_db", "rc": 1, "invocation": {"module_args": {"warn": true, "executable": null, "_uses_shell": false, "_raw_params": "/opt/chacra/bin/pecan populate /opt/chacra/src/chacra/prod.py", "removes": null, "creates": null, "chdir": null, "stdin": null}}, "start": "2021-08-06 16:34:11.068017", "msg": "non-zero return code"}\n', '')
fatal: [chacra1.xsky.com]: FAILED! => {
    "changed": true, 
    "cmd": [
        "/opt/chacra/bin/pecan", 
        "populate", 
        "/opt/chacra/src/chacra/prod.py"
    ], 
    "delta": "0:00:02.304443", 
    "end": "2021-08-06 16:34:13.372460", 
    "invocation": {
        "module_args": {
            "_raw_params": "/opt/chacra/bin/pecan populate /opt/chacra/src/chacra/prod.py", 
            "_uses_shell": false, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "stdin": null, 
            "warn": true
        }
    }, 
    "msg": "non-zero return code", 
    "rc": 1, 
    "start": "2021-08-06 16:34:11.068017", 
    "stderr": "Traceback (most recent call last):\n  File \"/opt/chacra/bin/pecan\", line 8, in <module>\n    sys.exit(CommandRunner.handle_command_line())\n  File \"/opt/chacra/lib/python2.7/site-packages/pecan/commands/base.py\", line 96, in handle_command_line\n    runner.run(sys.argv[1:])\n  File \"/opt/chacra/lib/python2.7/site-packages/pecan/commands/base.py\", line 91, in run\n    self.commands[ns.command_name]().run(ns)\n  File \"/opt/chacra/lib/python2.7/site-packages/chacra/commands/populate.py\", line 34, in run\n    self.load_app()\n  File \"/opt/chacra/lib/python2.7/site-packages/pecan/commands/base.py\", line 162, in load_app\n    return load_app(self.args.config_file)\n  File \"/opt/chacra/lib/python2.7/site-packages/pecan/core.py\", line 213, in load_app\n    set_config(config, overwrite=True)\n  File \"/opt/chacra/lib/python2.7/site-packages/pecan/configuration.py\", line 253, in set_config\n    config = conf_from_file(config)\n  File \"/opt/chacra/lib/python2.7/site-packages/pecan/configuration.py\", line 183, in conf_from_file\n    *imp.find_module(module_name, [basepath])\n  File \"/opt/chacra/src/chacra/prod.py\", line 5, in <module>\n    from prod_db import sqlalchemy\nImportError: No module named prod_db", 
    "stderr_lines": [
        "Traceback (most recent call last):", 
        "  File \"/opt/chacra/bin/pecan\", line 8, in <module>", 
        "    sys.exit(CommandRunner.handle_command_line())", 
        "  File \"/opt/chacra/lib/python2.7/site-packages/pecan/commands/base.py\", line 96, in handle_command_line", 
        "    runner.run(sys.argv[1:])", 
        "  File \"/opt/chacra/lib/python2.7/site-packages/pecan/commands/base.py\", line 91, in run", 
        "    self.commands[ns.command_name]().run(ns)", 
        "  File \"/opt/chacra/lib/python2.7/site-packages/chacra/commands/populate.py\", line 34, in run", 
        "    self.load_app()", 
        "  File \"/opt/chacra/lib/python2.7/site-packages/pecan/commands/base.py\", line 162, in load_app", 
        "    return load_app(self.args.config_file)", 
        "  File \"/opt/chacra/lib/python2.7/site-packages/pecan/core.py\", line 213, in load_app", 
        "    set_config(config, overwrite=True)", 
        "  File \"/opt/chacra/lib/python2.7/site-packages/pecan/configuration.py\", line 253, in set_config", 
        "    config = conf_from_file(config)", 
        "  File \"/opt/chacra/lib/python2.7/site-packages/pecan/configuration.py\", line 183, in conf_from_file", 
        "    *imp.find_module(module_name, [basepath])", 
        "  File \"/opt/chacra/src/chacra/prod.py\", line 5, in <module>", 
        "    from prod_db import sqlalchemy", 
        "ImportError: No module named prod_db"
    ], 
    "stdout": "==> LOADING ENVIRONMENT\nbasepath=/opt/chacra/src/chacra,module_name=prod", 
    "stdout_lines": [
        "==> LOADING ENVIRONMENT", 
        "basepath=/opt/chacra/src/chacra,module_name=prod"
    ]
}

RUNNING HANDLER [common : restart app] *************************************************************************************************************************************************************************************************

PLAY RECAP *****************************************************************************************************************************************************************************************************************************
chacra1.xsky.com           : ok=31   changed=7    unreachable=0    failed=1 
hjwsm1989 commented 2 years ago

@alfredodeza @tchaikov any tips?

tchaikov commented 2 years ago

@hjwsm1989 prod_db.py is created by

https://github.com/ceph/chacra/blob/21f29e465942309204ea239b1f10f58d4c912033/deploy/playbooks/roles/common/tasks/postgresql.yml#L58-L63

could you check if prod_db.py was created?

hjwsm1989 commented 2 years ago

@tchaikov yes, it's created

root@chacra1:/opt/chacra/src/chacra/deploy/playbooks# ls ../../ -alh
total 96K
drwxr-xr-x 8 root root 4.0K Aug  6 16:34 .
drwxr-xr-x 3 root root 4.0K Aug  6 16:03 ..
drwxr-xr-x 3 root root 4.0K Aug  6 16:03 alembic
-rw-r--r-- 1 root root 1.5K Aug  6 16:03 alembic.ini
-rw-r--r-- 1 root root 1.5K Aug  6 16:34 alembic-prod.ini
drwxr-xr-x 9 root root 4.0K Aug  6 16:03 chacra
drwxr-xr-x 2 root root 4.0K Aug  6 16:03 config
drwxr-xr-x 3 root root 4.0K Aug  6 16:03 deploy
drwxr-xr-x 8 root root 4.0K Aug  6 16:30 .git
-rw-r--r-- 1 root root  256 Aug  6 16:03 .gitignore
-rw-r--r-- 1 root root   68 Aug  6 16:31 prod_api_creds.py
-rw-r--r-- 1 root root  382 Aug  6 16:31 prod_callbacks.py
-rw-r--r-- 1 root root  249 Aug  6 16:34 prod_db.py
-rw-r--r-- 1 root root 5.1K Aug  6 16:31 prod.py
-rw-r--r-- 1 root root 3.5K Aug  6 16:31 prod.pyc
-rw-r--r-- 1 root root  14K Aug  6 16:03 README.rst
-rw-r--r-- 1 root root  122 Aug  6 16:04 requirements.txt
drwxr-xr-x 2 root root 4.0K Aug  6 16:03 scripts
-rw-r--r-- 1 root root 1.2K Aug  6 16:03 setup.py
-rw-r--r-- 1 root root  175 Aug  6 16:03 tox.ini
tchaikov commented 2 years ago

@hjwsm1989 i mean it should be put under "{{ app_home }}/src/{{ app_name }}/prod_db.py". could you check that directory also?

hjwsm1989 commented 2 years ago

@hjwsm1989 i mean it should be put under "{{ app_home }}/src/{{ app_name }}/prod_db.py". could you check that directory also?

app_home is /opt/chacra/ app_name is chacra so the path is /opt/chacra/src/chacra/ it exists

root@chacra1:/opt/chacra/src/chacra# ll
total 96
drwxr-xr-x 8 root root  4096 Aug  6 16:34 ./
drwxr-xr-x 3 root root  4096 Aug  6 16:03 ../
drwxr-xr-x 3 root root  4096 Aug  6 16:03 alembic/
-rw-r--r-- 1 root root  1443 Aug  6 16:03 alembic.ini
-rw-r--r-- 1 root root  1528 Aug  6 16:34 alembic-prod.ini
drwxr-xr-x 9 root root  4096 Aug  6 16:03 chacra/
drwxr-xr-x 2 root root  4096 Aug  6 16:03 config/
drwxr-xr-x 3 root root  4096 Aug  6 16:03 deploy/
drwxr-xr-x 8 root root  4096 Aug  6 16:30 .git/
-rw-r--r-- 1 root root   256 Aug  6 16:03 .gitignore
-rw-r--r-- 1 root root    68 Aug  6 16:31 prod_api_creds.py
-rw-r--r-- 1 root root   382 Aug  6 16:31 prod_callbacks.py
-rw-r--r-- 1 root root   249 Aug  6 16:34 prod_db.py
-rw-r--r-- 1 root root  5181 Aug  6 16:31 prod.py
-rw-r--r-- 1 root root  3541 Aug  6 16:31 prod.pyc
-rw-r--r-- 1 root root 13793 Aug  6 16:03 README.rst
-rw-r--r-- 1 root root   122 Aug  6 16:04 requirements.txt
drwxr-xr-x 2 root root  4096 Aug  6 16:03 scripts/
-rw-r--r-- 1 root root  1223 Aug  6 16:03 setup.py
-rw-r--r-- 1 root root   175 Aug  6 16:03 tox.ini