Your playbook should look like so: — – hosts: XYZ become: yes pre_tasks: – name: Add repository for old PHP apt_repository: repo: ppa:ondrej/php update_cache: yes state: present roles: – role: geerlingguy.apache … – role: geerlingguy.php php_webserver_daemon: apache2 php_default_version_debian: "7.1" php_version:… Read More
How to convert a string to int in Jinja2?
Simple: MYSTRING | int I work as a freelancer, so if you don’t want to do that kind of things yourself or don’t have the time, just drop me a line to hire me.
How to extract an object from a list based on attribute value in Jinja2?
Use the `selectattr()` filter. For example: – set_fact: myobj: "{{ hostvars[inventory_hostname].ansible_mounts | selectattr(‘mount’, ‘equalto’, ‘/’) | list }}" – debug: var=myobj I work as a freelancer, so if you don’t want to do that kind of things yourself or don’t… Read More
How to loop over a role in Ansible?
Don’t use “roles:” but “tasks:” and use the include_role module. For example: — # roles/myrole/tasks/main.yml – debug: var=bla — # playbook – hosts: localhost connection: local gather_facts: no tasks: – name: Loop over role include_role: name: myrole vars: bla:… Read More
How to install the latest version of Ansible on Ubuntu?
From here, the steps are: $ sudo apt update $ sudo apt install software-properties-common $ sudo apt-add-repository ppa:ansible/ansible $ sudo apt update $ sudo apt install ansible I work as a freelancer, so if you don’t want to do that… Read More
Jinja2: How to iterate over a dictionary?
{% for key, value in MYDICT.items() %} … {% endfor %} I work as a freelancer, so if you don’t want to do that kind of things yourself or don’t have the time, just drop me a line to hire… Read More
How to generate a comma-separated list in Jinja2?
From a list directly: {{ somelist|join(",") }} From a list of objects: {% for x in somelist %}{{ x.xyz }}{% if not loop.last %},{% endif %}{% endfor %} I work as a freelancer, so if you don’t want or don’t… Read More