I have encountered a problem during a deploy of openstack pike.
There's an error running pre-check command.
Kolla-ansible version 6.0.0.0rc2, Ubuntu Server 16 LTS [error][1]
I've found out that the required docker version is >=2.4.6.
My current is 1.12.6.
fatal: [localhost]: FAILED! => {"msg": "The conditional check 'result | failed or result.stdout | regex_replace('.(\\d+\\.\\d+\\.\\d+).', '\\1') | version_compare(docker_version_min, '<')' failed. The error was: template error while templating string: no filter named 'failed'. String: {% if result | failed or result.stdout | regex_replace('.(\\d+\\.\\d+\\.\\d+).', '\\1') | version_compare(docker_version_min, '<') %} True {% else %} False {% endif %}"}
So, I tried to upgrade it by running command
sudo pip install -U docker==2.4.2
But docker version still says it is 1.12.6 and an error occurs.
My question is: do I have to upgrade docker in other way, change something in kolla-ansible playbooks, or maybe something else?
PS I know pike, Ubuntu srv 16 and 6.0.0.0rc2 are a little bit outdated, but its just for my university project :)
failed is not a filter but a test.
Using tests with the filter syntax used to be allowed. It has been deprecated in ansible 2.5 (with warnings) and totally removed in ansible 2.9.
The correct syntax is:
result is failed
Your problem is that you installed the wrong docker.
Kolla needs docker engine. You should install docker-ce by following this:
https://docs.docker.com/install/linux/docker-ce/ubuntu/
And then try again.
Also remove docker from pypi:
pip uninstall docker
And the one from apt:
sudo apt remove docker
The problem was in ansible. Like #Zeitounator said, that script worked only in ansible 2.5 or less, so this one solved my problem:
sudo -H pip install ansible==2.5.6
But another fail is:
TASK [prechecks : Checking docker SDK version] *******************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "cmd": ["/usr/bin/python", "-c", "import docker; print docker.version"], "delta": "0:00:00.014776", "end": "2020-01-21 14:35:06.561138", "failed_when_result": true, "msg": "non-zero return code", "rc": 1, "start": "2020-01-21 14:35:06.546362", "stderr": "Traceback (most recent call last):\n File \"\", line 1, in \nImportError: No module named docker", "stderr_lines": ["Traceback (most recent call last):", " File \"\", line 1, in ", "ImportError: No module named docker"], "stdout": "", "stdout_lines": []}
solution is:
sudo pip install docker
Related
I am trying to deploy the below task via Ansible AWX (Tower) and having some issues with the aws_s3 module.
---
- hosts: all
become: yes
tasks:
- name: Setting host facts for Python interpreter
set_fact:
ansible_python_interpreter: "/usr/bin/python3"
- name: 01 - Download file locally
aws_s3:
bucket: temp-buck-0001
object: /test/quiz.sh
dest: /tmp/quiz.sh
mode: get
- name: 02 - Change the file permissions of the shell scrip to allow for execute
file:
path: /tmp/quiz.sh
mode: "u=x"
- name: 03 - Change the working directory to tmp before executing the command.
shell: quiz.sh >> quizlog.txt
args:
chdir: /tmp
I'm getting the below error when trying to deploy the above ansible play. It seems to have a problem with Python dependencies in particular boto3 and botocore so I attempted to install these manually for testing purposes.
However, I'm receiving the below errors. It concerns dependencies for the aws_s3 module. I'm not sure if I have set up my Python interpreter correctly. Any help would be much appreciated.
Also, if anybody could suggest how to write a task to install Python3x and dependencies which is required for the aws_s3 module that would also be much appreciated.
TASK [01 - Download Metricbeats file locally]
********************************** fatal: [Dev-02]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 20.10.12.114
closed.\r\n", "module_stdout": "/bin/sh: /usr/bin/python3: No such
file or directory\r\n", "msg": "The module failed to execute
correctly, you probably need to set the interpreter.\nSee
stdout/stderr for the exact error", "rc": 127}
and the below output
{ "module_stdout": "/bin/sh: /usr/bin/python3: No such file or
directory\r\n", "module_stderr": "Shared connection to 20.10.12.114
closed.\r\n", "msg": "The module failed to execute correctly, you
probably need to set the interpreter.\nSee stdout/stderr for the exact
error", "rc": 127, "_ansible_no_log": false, "changed": false }
For context, this is the version of Python I have installed:
[ec2-user#ip-20-10-12-114 ~]$ pip --version
pip 21.0.1 from /usr/lib/python3.6/site-packages/pip (python 3.6)
[ec2-user#ip-20-10-12-114 ~]$ which pip
/usr/bin/pip
[ec2-user#ip-20-10-12-114 ~]$ python --version
Python 2.7.18
[ec2-user#ip-20-10-12-114 ~]$ which python
/usr/bin/python
[ec2-user#ip-20-10-12-114 ~]$ python3 --version
Python 3.6.2
[ec2-user#ip-20-10-12-114 ~]$ which python3
/usr/bin/python3
I'm trying to create a virtualenv for nodepool user using ansible but it is failing as outlined below. I want to become nodepool user as it uses python3.5 whereas all others use the server default, 2.7.5. It seems that it cannot source the 3.5 version.
The play is:
- name: Create nodepool venv
become: true
become_user: nodepool
become_method: su
command: virtualenv-3.5 /var/lib/nodepool/npvenv
The error is:
fatal: [ca-o3lscizuul]: FAILED! => {"changed": false, "cmd": "virtualenv-3.5 /var/lib/nodepool/npvenv", "failed": true, "msg": "[Errno 2] No such file or directory", "rc": 2}
It works from shell.
[root#host ~]# su nodepool
[nodepool#host root]$ virtualenv-3.5 /var/lib/nodepool/npvenv
Using base prefix '/opt/rh/rh-python35/root/usr'
New python executable in /var/lib/nodepool/npvenv/bin/python3
Also creating executable in /var/lib/nodepool/npvenv/bin/python
Installing setuptools, pip, wheel...done.
Worked around the issue as follows.
shell: source /var/lib/nodepool/.bashrc && virtualenv-3.5 /var/lib/nodepool/npvenv creates="/var/lib/nodepool/npvenv"
It is not as I'd like to do it but it will do. If anyone knows how I might do like originally posted, please advise. Perhaps it's not possible as it doesn't pickup paths etc.
I threw in the creates option as it prevents redoing if it exists.
I am getting the below error when deploying for the first time to a host using ansible.
I've tried using the default setup (I believe this is using default python 3.6 version on the system). I ve also attempted to add in the inventory a variable to use python 2.6(ansible_python_interpreter = /usr/bin/python2.6)
Same error :
FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared
connection to myserverxx closed.\r\n", "module_stdout": "'import site'
failed; use -v for traceback\r\nTraceback (most recent call last):\r\n File
\"/home/myuser/.ansible/tmp/ansible-tmp-1531332066.08-
249430258979920/setup.py\", line 4, in <module>\r\n import
os\r\nImportError: No module named os\r\n", "msg": "MODULE FAILURE", "rc": 0}
On the host I can login and use python 3.6 interpreter and run import os (no error here).
EDIT :
example of command that fails. I have the issue with a ping, seems configuration issue (with python?).
ansible -m ping dev_myserver -i ansible-hosts
Content of ansible-hosts
[dev_myserver]
servername ansible_user=username
This is caused by python installation on the environment, nothing wrong with ansible (was able to reproduce the error while logged in locally).
I have this playbook:
---
- hosts: all
become: yes
become_user: root
gather_facts: no
pre_tasks:
- name: 'install python2'
raw: sudo apt-get -y install python-simplejson
roles:
- git
...
Sometimes, it works perfectly fine and sometimes it gives me this error:
==> default: Running provisioner: ansible...
default: Running ansible-playbook...
PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i '/var/www/test/.vagrant/machines/default/virtualbox/private_key' -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --extra-vars="ansible_ssh_user='ubuntu'" --limit="all" --inventory-file=ansible/hosts/hosts_linux.txt -v ansible/site.yml
Using /etc/ansible/ansible.cfg as config file
PLAY ***************************************************************************
TASK [install python2] *********************************************************
fatal: [10.0.11.44]: FAILED! => {"changed": false, "failed": true, "rc": 255, "stderr": "", "stdout": "", "stdout_lines": []}
PLAY RECAP *********************************************************************
10.0.11.44 : ok=0 changed=0 unreachable=0 failed=1
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
I am wondering why do I get this error and what does it mean? There is no output on the error and the exactly same code works if I try this many times. It makes no sense. Why is ansible failing to install python?
According to your comments, the problem is with ssh. You can create your own ansible.cfg file in your current working directory and supply openssh options directly as described here: open-ssh options
I suggest you try:
[defaults]
host_key_checking = False
And also during your playbook run, you can manually specify which ssh key to use like:
ansible-playbook --private-key /path/to/ssh_key ...
Finally, make sure there is no IP conflict, because your server's ssh fingerprint should not change. Try manually ssh'ing a few times as well.
I've installed Ansible on Ubuntu and running:
ansible testserver -m linode -a 'state=stopped'
gives the error:
testserver | FAILED >> {
"failed": true,
"msg": "linode-python required for this module"
}
I installed linode-python successfully with pp install linode-python and I can run import linode in Python. So how can I get this module working?
Just to be sure : you have to install linode-python on the distant machine, not on the host.
Actually I realised this should be a local action, because we're not actually trying to run a command on the remote server. Which means I have to run this against localhost. So first I had to ensure I could ssh into localhost:
cd ~/.ssh; cat id_rsa.pub >> authorized_keys
Then I changed the machine to localhost:
ansible localhost -m linode -a 'state=stopped ...'
I'm still having some issues with that, but it seems to be running the module now.
Blogged it.