Ansible create a virtualenv using the venv module

I ran into the same issue tonight and found that specifying the full path to the interpreter, including the arguments, worked for me (at least it does in ansible==2.2.2.0): – pip: requirements: /website/requirements.txt virtualenv: /opt/website-venv virtualenv_command: /usr/bin/python3.6 -m venv or – pip: requirements: /opt/project/requirements_prod.txt virtualenv: /opt/.virtualenv/project_env virtualenv_python: python3

How to nicely split on multiple lines long conditionals with OR on ansible?

Use the YAML folding operator > when: > ansible_user_dir is not defined or ansible_python is not defined or ansible_processor_vcpus is not defined As the ansible documentation states: Values can span multiple lines using | or >. Spanning multiple lines using a Literal Block Scalar | will include the newlines and any trailing spaces. Using a … Read more

ansible returns with “Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6))

It appears that you don’t have the docker module installed. You will need to install it via your system package manager (apt install python-docker, for example), or using pip (pip install docker). If you have multiple Python versions, make sure that you’ve installed the docker module into the version that Ansible is using.

How to add spaces at beginning of block in Ansible’s blockinfile?

You can use a YAML feature called “Block Indentation Indicator”: – name: Added a block of lines in the file blockinfile: dest: /path/some_file.yml insertafter: ‘authc:’ block: |2 line0 line1 line2 line3 line4 It’s all about the 2 after the | References: https://groups.google.com/forum/#!topic/ansible-project/mmXvhTh6Omo How do I break a string in YAML over multiple lines? http://www.yaml.org/spec/1.2/spec.html#id2793979 Update: … Read more

How to create a file locally with ansible templates on the development machine

You can delegate tasks with the param delegate_to to any host you like, for example: – name: create some file template: src=~/workspace/ansible_templates/somefile_template.j2 dest=/etc/somefile/apps-available/someproject.ini delegate_to: localhost See Playbook Delegation in the docs. If your playbook should in general run locally and no external hosts are involved though, you can simply create a group which contains localhost … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)