Ansible: no hosts matched

You need to define a host inventory. The default path for this is /etc/ansible/hosts (as also stated by helloV). For a minimal example you can also specify an inventory in the command line: ansible-playbook setup.yml -i 192.168.10.1, The trailing comma makes it a list, such that ansible parses it directy. Otherwise you can run ansible-playbook … Read more

Conflicting action statement in ansible

Here is the problem, you have mixed up two tasks into one: — – hosts: webhost sudo: yes connection: ssh tasks: – name: debuging module shell: ps aux register: output – name: show the value of output debug: var=output And out put of the playbook will be like this: PLAY [all] ********************************************************************* TASK [setup] ******************************************************************* … Read more

How to run docker-compose commands with ansible?

Updated answer 02/2024: docker_compose_v2 is out since community.docker v3.6.0. You can copy docker-compose.yml and run Compose such as: – name: copy Docker Compose files copy: src: files/{{ item }} dest: /somewhere/yourproject/{{ item }} loop: – docker-compose.yml – docker-compose.prod.yml # use files parameter to use multiple docker-compose.yml files # mind the _v2 suffix – name: deploy … Read more

How can I manage keyring files in trusted.gpg.d with ansible playbook since apt-key is deprecated?

In short, you need to put the GPG key with the correct extension into a separate directory that is not searched by default, and point your repository configuration at that specific file. For more info on why you need a separate directory, see this answer to “Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d … Read more

How to compare kernel, software, etc. versions numbers in Ansible?

There is a version test for it: {{ ansible_distribution_version is version(‘12.04’, ‘>=’) }} {{ sample_version_var is version(‘1.0’, operator=”lt”, strict=True) }} Prior to Ansible 2.5, all tests were also provided as filters, so, the same was achievable with a filter, named version_compare, but in current versions of Ansible, the test was renamed and, overall, the tests … Read more

Copy a file with Ansible if it doesn’t exist

Assuming index.php exists in the role’s files subdirectory: – copy: src: index.php dest: /var/www/index.php force: no The decisive property is force. As the documentation explains, the default is yes, which will replace the remote file when contents are different than the source. If no, the file will only be transferred if the destination does not … Read more

System specific variables in ansible

Well you can set in three ways http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters ansible_python_interpreter=/usr/bin/python2 this will set it per host Set it host_vars/ ansible_python_interpreter: “/usr/bin/python2” this will set it per host set it for all nodes in the file group_vars/all (you may need to create the directory group_vars and the file all) as ansible_python_interpreter: “/usr/bin/python2” Hope that helps

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