roots / trellis

WordPress LEMP stack with PHP 8.2, Composer, WP-CLI and more
https://roots.io/trellis/
MIT License
2.51k stars 607 forks source link

Python 3 Incompatibility? #1273

Closed broskees closed 3 years ago

broskees commented 3 years ago

Description

Getting the following error during server provisioning:

TASK [logrotate : nickhammond.logrotate | Setup logrotate.d scripts] ************************************************************************************************************
task path: /Users/josephroberts/localdev/papasteamstores.com/trellis/vendor/roles/logrotate/tasks/main.yml:8
<67.205.169.5> ESTABLISH SSH CONNECTION FOR USER: root
<67.205.169.5> SSH: EXEC ssh -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/josephroberts/.ansible/cp/1eb7617cc8 67.205.169.5 '/bin/sh -c '"'"'echo ~root && sleep 0'"'"''
<67.205.169.5> (0, b'/root\n', b'OpenSSH_7.9p1, LibreSSL 2.7.3\r\ndebug1: Reading configuration data /Users/josephroberts/.ssh/config\r\ndebug1: /Users/josephroberts/.ssh/config line 2: Applying options for *\r\ndebug1: /Users/josephroberts/.ssh/config line 45: Applying options for 67.205.169.5\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 48: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 67.205.169.5 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 49562\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<67.205.169.5> ESTABLISH SSH CONNECTION FOR USER: root
<67.205.169.5> SSH: EXEC ssh -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/josephroberts/.ansible/cp/1eb7617cc8 67.205.169.5 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1612997587.654769-50736-237756151622196 `" && echo ansible-tmp-1612997587.654769-50736-237756151622196="` echo /root/.ansible/tmp/ansible-tmp-1612997587.654769-50736-237756151622196 `" ) && sleep 0'"'"''
<67.205.169.5> (0, b'ansible-tmp-1612997587.654769-50736-237756151622196=/root/.ansible/tmp/ansible-tmp-1612997587.654769-50736-237756151622196\n', b'OpenSSH_7.9p1, LibreSSL 2.7.3\r\ndebug1: Reading configuration data /Users/josephroberts/.ssh/config\r\ndebug1: /Users/josephroberts/.ssh/config line 2: Applying options for *\r\ndebug1: /Users/josephroberts/.ssh/config line 45: Applying options for 67.205.169.5\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 48: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 67.205.169.5 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 49562\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<67.205.169.5> ESTABLISH SSH CONNECTION FOR USER: root
<67.205.169.5> SSH: EXEC ssh -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/josephroberts/.ansible/cp/1eb7617cc8 67.205.169.5 '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1612997587.654769-50736-237756151622196/ > /dev/null 2>&1 && sleep 0'"'"''
<67.205.169.5> (0, b'', b'OpenSSH_7.9p1, LibreSSL 2.7.3\r\ndebug1: Reading configuration data /Users/josephroberts/.ssh/config\r\ndebug1: /Users/josephroberts/.ssh/config line 2: Applying options for *\r\ndebug1: /Users/josephroberts/.ssh/config line 45: Applying options for 67.205.169.5\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 48: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 67.205.169.5 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 49562\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
System info:
  Ansible 2.10.5; Darwin
  Trellis version (per changelog): "Use Python 3 for `ansible_local` Vagrant provisioner"
---------------------------------------------------
AnsibleUndefinedVariable: 'dict object' has no attribute 'iteritems'
failed: [67.205.169.5] (item={'name': 'wordpress-sites', 'path': '/srv/www/**/logs/*.log', 'options': ['weekly', 'maxsize 50M', 'missingok', 'rotate 8', 'compress', 'delaycompress', 'notifempty', 'create 0640 web www-data', 'sharedscripts'], 'scripts': {'prerotate': 'if [ -d /etc/logrotate.d/httpd-prerotate ]; then \\\n      run-parts /etc/logrotate.d/httpd-prerotate; \\\n    fi \\\n', 'postrotate': 'service nginx rotate'}}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "name": "wordpress-sites",
        "options": [
            "weekly",
            "maxsize 50M",
            "missingok",
            "rotate 8",
            "compress",
            "delaycompress",
            "notifempty",
            "create 0640 web www-data",
            "sharedscripts"
        ],
        "path": "/srv/www/**/logs/*.log",
        "scripts": {
            "postrotate": "service nginx rotate",
            "prerotate": "if [ -d /etc/logrotate.d/httpd-prerotate ]; then \\\n      run-parts /etc/logrotate.d/httpd-prerotate; \\\n    fi \\\n"
        }
    }
}

PLAY RECAP **********************************************************************************************************************************************************************
67.205.169.5               : ok=77   changed=1    unreachable=0    failed=1    skipped=30   rescued=0    ignored=0   
localhost                  : ok=0    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

Using python3, from what I can tell there is no section of trellis’ code that uses iteritems without first including from ansible.module_utils.six import iteritems so not sure what the issue is.

Perhaps a dependency is? I believe this is a bug because as far as I understand this is a python3 error and trellis is python compatible

Deploys run fine.

Steps to reproduce

  1. Update Trellis to Latest
  2. Update Ubuntu 'DO' Droplet to latest
  3. run server provisioning script (server.yml)

Expected behavior: Server provisioning script to complete without errors

Actual behavior: It fails with AnsibleUndefinedVariable: 'dict object' has no attribute 'iteritems'

Reproduces how often: 100%

Versions

Here’s my system:

software version
ansible 2.10.5
python 3.9.1
OS mac OS Mojave 10.14.6 (18G4032)
Trellis 1.7.1

Additional information

N/A

broskees commented 3 years ago

Quick update. I've tried this now on a fresh DO droplet and have the same error.

swalkinshaw commented 3 years ago

🤔 this is coming from the logrotate galaxy role. I found https://github.com/nickhammond/ansible-logrotate/pull/34

Maybe you haven't updated logrotate in a while? Make sure your galaxy.yml has this version: https://github.com/roots/trellis/blob/a81c10b5b0bc01c5ffb61891dd7c6b82c166278a/galaxy.yml#L11 (I updated it 2 years ago)

And need to ensure that you've updated the roles with ansible-galaxy install -rf galaxy.yml

robrecord commented 3 years ago

Just to add that you can also use trellis-cli to update:

trellis galaxy install