New answers tagged

0

I would recommend you to store your tokens in a safe place and utilize the power of Ansible to populate data based upon your environment. Example of setting the keyvault variable by a variable value defined via the command line when executing the playbook: - set_fact: effective_env: '{% if env_class == "production" %}prod{% else %}dev{% endif %}' -...


0

The best way is of course (like Zeitounator comments) to use a inventory var. Either you use the version number in the docker-compose task as a variable or you create a Jinja2 template docker-compose.yml.j2 and use the variable there. That's what I do. Example: all: hosts: host1.prod: image: "xyz/12" host2.dev: image: "xyz/latest" ...


1

The registered variable smm_output is a dict object and you can correctly dive into it. But you cannot use smm_output.results.stdout_lines because smm_output.results is a list. You need to iterate over it or filter the first element of results. So, if you know its only one element in the list, you should use smm_output.results.0.stdout_lines.


1

Q: "Is it possible to change ansible temp dir for one playbook only? I have VMs with r/o root." A: Yes. It's possible. Configure the variable ansible_remote_tmp. In some cases, a better solution to this problem is ANSIBLE_PIPELINING. Quoting from Risks and limitations of become: Use pipelining. When pipelining is enabled, Ansible does not save the ...


1

Q: "Is it possible to use ansible to manage the order of programs?" A: Yes. It's possible. For example, the playbook below does the job - hosts: HostA tasks: - include_role: name: startprogram - hosts: HostB tasks: - include_role: name: runcommand when: hostvars.HostA.HostAprogram_started|default(false) - hosts: HostC ...


0

Use the following source code for copy multiple files on your client machine. --- - name: Copy data to the client machine hosts: hostname become_method: sudo become_user: root become: true tasks: # Copy twice as sometimes files get skipped (mostly only one file skipped from a folder if the folder does not exist) - name: ...


0

Following you comment: no I cannot reproduce your problem. Since you did not provide the rest of your files (inventory, etc...) and I cannot guess where is your problem, here is a quick proof by example using the php:7.0-apache image. The inventory (inventories/docker_test/hosts.yml) --- all: hosts: docker_test: ansible_connection: docker ...


1

This is how I managed to test your scenario manually against the php:7.0-apache docker image. Note that this image is based on debian:stretch. In your question, you are following the install guide for ubuntu which will fail anyway in debian stretch. I'm using the correct scenario below. See the ansible install documentation for more details. I also kept the ...


2

It is a totally expected result. You define the same variables in different places and ansible applies its variable precedence First of all, remember that variables passed as extra vars always win: you can never change them in any other place or during the run (i.e. set_fact). Now let's decompose what happens. The schema is basically the same for all vars ...


3

As it says, No such file or directory: 'gpg', so you probably need to install gnupg before adding the PPA repository: apt-get install gnupg


Top 50 recent answers are included