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

Deployment fails #14204

Closed
garrisoneel opened this issue May 12, 2021 · 9 comments · Fixed by #14206
Closed

Deployment fails #14204

garrisoneel opened this issue May 12, 2021 · 9 comments · Fixed by #14206

Comments

@garrisoneel
Copy link

garrisoneel commented May 12, 2021

Describe the bug

Deployment from WSL fails during "TASK [Ensure Ansible is not being run in a world writable directory]" due to "template error while templating string: expected token 'end of statement block', got 'integer'." I am baffled to not see this error anywhere else

To Reproduce

Steps to reproduce the behavior:

  1. Follow WSL instructions
  2. Follow Step 4 from Deploy the Algo Server
  3. Attempt ./algo
  4. Observe error

Alternately:

  1. Open Google Cloud Shell
  2. Follow deployment instructions (Steps 2 & 4)
  3. Follow GCP Setup, entering commands into google cloud shell.
  4. Observe identical error after ./algo -e "provider=gce" -e "gce_credentials_file=$(pwd)/configs/gce.json"

Expected behavior

TASK [Ensure Ansible is not being run in a world writable directory] passes because the directory has correct permissions. Deployment continues.

Additional context

This happens in google cloud shell in addition to WSL, so I don't believe it is related to #1637 despite failing at a similar point.

Output of pip list in both:

WSL GCShell
Package             Version
------------------- --------
ansible             2.9.7
appdirs             1.4.4
cffi                1.14.5
cryptography        3.4.7
distlib             0.3.1
filelock            3.0.12
importlib-metadata  4.0.1
importlib-resources 5.1.2
Jinja2              3.0.0
MarkupSafe          2.0.0
netaddr             0.8.0
pip                 21.1.1
pkg-resources       0.0.0
pycparser           2.20
PyYAML              5.4.1
setuptools          56.2.0
six                 1.16.0
typing-extensions   3.10.0.0
virtualenv          20.4.6
wheel               0.36.2
zipp                3.4.1
Package            Version
------------------ --------
ansible            2.9.7
appdirs            1.4.4
cffi               1.14.5
cryptography       3.4.7
distlib            0.3.1
filelock           3.0.12
importlib-metadata 4.0.1
Jinja2             3.0.0
MarkupSafe         2.0.0
netaddr            0.8.0
pip                21.1.1
pycparser          2.20
PyYAML             5.4.1
setuptools         56.0.0
six                1.16.0
typing-extensions  3.10.0.0
virtualenv         20.4.6
wheel              0.36.2
zipp               3.4.1

Output of ansible --version in WSL:

ansible 2.9.7
  config file = /home/user/algo/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/algo/.env/lib/python3.6/site-packages/ansible
  executable location = /home/user/algo/.env/bin/ansible
  python version = 3.6.9 (default, Jul 17 2020, 12:50:27) [GCC 8.4.0]

Output of ansible --version in GCShell:

ansible 2.9.7
  config file = /home/user/algo/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/algo/.env/lib/python3.7/site-packages/ansible
  executable location = /home/user/algo/.env/bin/ansible
  python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]

Full log

WSL output:

$ ./algo
[WARNING]: Could not match supplied host pattern, ignoring: vpn-host

PLAY [localhost] *****************************************************************************

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

TASK [Playbook dir stat] *********************************************************************
ok: [localhost]

TASK [Ensure Ansible is not being run in a world writable directory] *************************
fatal: [localhost]: FAILED! => {"msg": "The conditional check '_playbook_dir.stat.mode|int <= 0775' failed. The error was: template error while templating string: expected token 'end of statement block', got 'integer'. String: {% if _playbook_dir.stat.mode|int <= 0775 %} True {% else %} False {% endif %}"}

PLAY RECAP ***********************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

GCShell output:

$ ./algo -e "provider=gce" -e "gce_credentials_file=$(pwd)/configs/gce.json"
[WARNING]: Could not match supplied host pattern, ignoring: vpn-host

PLAY [localhost] *************************************************************************************************************************************************************************************

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

TASK [Playbook dir stat] *****************************************************************************************************************************************************************************
ok: [localhost]

TASK [Ensure Ansible is not being run in a world writable directory] *********************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "The conditional check '_playbook_dir.stat.mode|int <= 0775' failed. The error was: template error while templating string: expected token 'end of statement block', got 'integer'. String: {% if _playbook_dir.stat.mode|int <= 0775 %} True {% else %} False {% endif %}"}

PLAY RECAP *******************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
@cjdupreez
Copy link

Seeing the same issue on my end.

@jarrettprosser
Copy link

I'm seeing the same issue today. I deployed another host with an identical config a couple of days ago and it succeeded. I think the release of jinja2 3.0.0 has caused a problem with this step. See the differences in dependencies:

Algo deployed 09/05/2021 Algo deployed 12/05/2021
Package       Version
------------- -------
ansible 2.9.7
appdirs 1.4.4
cffi 1.14.5
cryptography 3.4.7
distlib 0.3.1
filelock 3.0.12
Jinja2 2.8
MarkupSafe 1.1.1
netaddr 0.8.0
pip 21.1.1
pkg-resources 0.0.0
pycparser 2.20
pyOpenSSL 20.0.1
PyYAML 5.4.1
segno 1.3.3
setuptools 44.0.0
six 1.16.0
virtualenv 20.4.6
wheel 0.34.2
Package       Version
------------- -------
ansible 2.9.7
appdirs 1.4.4
cffi 1.14.5
cryptography 3.4.7
distlib 0.3.1
filelock 3.0.12
Jinja2 3.0.0
MarkupSafe 2.0.0
netaddr 0.8.0
pip 21.1.1
pkg-resources 0.0.0
pycparser 2.20
PyYAML 5.4.1
setuptools 44.0.0
six 1.16.0
virtualenv 20.4.6
wheel 0.34.2

To confirm, I tried adding jinja2==2.8 to requirements.txt at the start, and the task succeeds.

TASK [Ensure Ansible is not being run in a world writable directory] *****************************************************************************************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

@davidemyers
Copy link
Contributor

Another thing to try is to just delete the directory permissions check from main.yml.

@mnihal22
Copy link

I tried it after restarting the ssh session. The deployment proceeds without error

@argium
Copy link

argium commented May 14, 2021

I can reproduce this on my machine. I am not connected through SSH. Editing out the check from main.yml does seem to unblock me.

Algo running on: macOS 11.3.1
Created from git clone. Last commit: 70f9f91 Fix typo (#14145)
Python 3.9.5
ll
drwxr-xr-x  38 richard  staff   1.2K 14 May 12:37 algo
~/sources/algo(master*) » ll                                                                                             2 ↵ richard@Timber
total 312
-rw-r--r--   1 richard  staff   7.3K 14 May 12:33 CHANGELOG.md
-rw-r--r--   1 richard  staff   761B 14 May 12:33 CONTRIBUTING.md
-rw-r--r--   1 richard  staff   1.2K 14 May 12:33 Dockerfile
-rw-r--r--   1 richard  staff    34K 14 May 12:33 LICENSE
-rw-r--r--   1 richard  staff   777B 14 May 12:33 Makefile
-rw-r--r--   1 richard  staff   1.3K 14 May 12:33 PULL_REQUEST_TEMPLATE.md
-rw-r--r--   1 richard  staff    17K 14 May 12:33 README.md
-rwxr-xr-x   1 richard  staff   550B 14 May 12:33 algo
-rw-r--r--   1 richard  staff   1.2K 14 May 12:33 algo-docker.sh
-rwxr-xr-x   1 richard  staff   2.4K 14 May 12:33 algo-showenv.sh
-rw-r--r--   1 richard  staff   455B 14 May 12:33 ansible.cfg
-rw-r--r--   1 richard  staff   507B 14 May 12:33 cloud.yml
-rw-r--r--   1 richard  staff   7.5K 14 May 12:46 config.cfg
drwxr-xr-x   3 richard  staff    96B 14 May 12:33 configs
-rw-r--r--   1 richard  staff   673B 14 May 12:33 deploy_client.yml
drwxr-xr-x  33 richard  staff   1.0K 14 May 12:33 docs
drwxr-xr-x   3 richard  staff    96B 14 May 12:33 files
-rw-r--r--   1 richard  staff   5.9K 14 May 12:33 input.yml
-rw-r--r--   1 richard  staff   3.7K 14 May 12:33 install.sh
-rw-r--r--   1 richard  staff    78B 14 May 12:33 inventory
drwxr-xr-x  10 richard  staff   320B 14 May 12:33 library
-rw-r--r--   1 richard  staff    10K 14 May 12:33 logo.png
-rw-r--r--   1 richard  staff   2.2K 14 May 12:33 main.yml
drwxr-xr-x   6 richard  staff   192B 14 May 12:33 playbooks
-rw-r--r--   1 richard  staff    23B 14 May 12:33 requirements.txt
drwxr-xr-x  20 richard  staff   640B 14 May 12:33 roles
-rw-r--r--   1 richard  staff   4.0K 14 May 12:33 server.yml
drwxr-xr-x  12 richard  staff   384B 14 May 12:33 tests
-rw-r--r--   1 richard  staff   3.5K 14 May 12:33 users.yml
drwxr-xr-x   3 richard  staff    96B 14 May 12:33 venvs
~/Sources/algo(master*) » ./algo                                                                                             richard@Timber
[WARNING]: Could not match supplied host pattern, ignoring: vpn-host

PLAY [localhost] ***************************************************************************************************************************

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

TASK [Playbook dir stat] *******************************************************************************************************************
ok: [localhost]

TASK [Ensure Ansible is not being run in a world writable directory] ***********************************************************************
fatal: [localhost]: FAILED! => {"msg": "The conditional check '_playbook_dir.stat.mode|int <= 0775' failed. The error was: template error while templating string: expected token 'end of statement block', got 'integer'. String: {% if _playbook_dir.stat.mode|int <= 0775 %} True {% else %} False {% endif %}"}

PLAY RECAP *********************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

@narendnp
Copy link

Another thing to try is to just delete the directory permissions check from main.yml.

Yup this works for me, though I just commented out line 10-15.

@caewok
Copy link

caewok commented May 15, 2021

Same problem; like others, commenting out lines 10–15 in main.yml works.

@ferasawadi
Copy link

thanks that solves the issue

@jruaaa
Copy link

jruaaa commented May 25, 2021

didn't comment the check out but added jinja2==2.8 to requirements.txt at the start which worked for me it seems

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.

10 participants