Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy chacra failed #286

Open
hjwsm1989 opened this issue Aug 6, 2021 · 5 comments
Open

deploy chacra failed #286

hjwsm1989 opened this issue Aug 6, 2021 · 5 comments

Comments

@hjwsm1989
Copy link

hjwsm1989 commented Aug 6, 2021

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
Copy link
Author

@alfredodeza @tchaikov any tips?

@tchaikov
Copy link
Contributor

tchaikov commented Aug 6, 2021

@hjwsm1989 prod_db.py is created by

- name: create the prod_db config file with the db password
template:
src: ../templates/prod_db.py.j2
dest: "{{ app_home }}/src/{{ app_name }}/prod_db.py"
notify:
- restart app

could you check if prod_db.py was created?

@hjwsm1989
Copy link
Author

@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
Copy link
Contributor

tchaikov commented Aug 7, 2021

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

@hjwsm1989
Copy link
Author

@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

tchaikov added a commit to tchaikov/chacra that referenced this issue Aug 7, 2021
so we are able to load the python modules located in the same directory
and be python2 compatible.

Fixes ceph#286
Signed-off-by: Kefu Chai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants