New answers tagged

1

Q: "The template contains interpolations and these interpolations must be preserved as they are." A: Declare default variables lbr: '{{ "{{" }}' rbr: '{{ "}}" }}' value1: '{{ lbr }} value1 {{ rbr }}' value2: '{{ lbr }} value2 {{ rbr }}' and create the template shell> cat template.yml.j2 key1: {{ value1 }} ...


0

When you provide a when a list it performs an AND of the two expressions. And here is the standard AND truth table. Cond1 Cont2 | Result False False | False False True | False True False | False True True | True Consider your have os_distribution: "Ubuntu" # variable ansible_facts.distribution: "Ubuntu" # fact The ...


1

You're telling to your task to loop over an object who's representing your files variables but loop require a list. You have to define your var_files like : users: - user1 - user2 And then in your main playbook, removing "item.name" in order to just use the item, and precise inside your varfile what variable you use : - hosts: GrupoPrincipal ...


0

To achieve the goal in Ansible it is recommended in general to use service modules, service, sysvinit or systemd. In example like --- - hosts: localhost become: yes become_method: sudo gather_facts: yes tasks: - name: Gathering Service Facts service_facts: - name: Make sure service is stopped systemd: name: httpd state: ...


2

Convert the dictionary management first - set_fact: mgmt: "{{ mgmt|d({})|combine({item.key: {'Property4': item.value}}) }}" loop: "{{ management|dict2items }}" gives mgmt: server1: Property4: ip1_addr server2: Property4: ip2_addr Then combine the dictionaries - set_fact: servers: "...


1

Replace it with an empty string. - name: Comment Java exclusion replace: path: /etc/yum.conf regexp: '(java\*\s*)' replace: '' Changes to the regex: .* would have removed the exclude= as well, so I removed it The * needs to be escaped, it's a regex modifier added \s* to remove trailing whitespace as well EDIT Even better: - name: Comment ...


0

This should do it: vtarget_backup_folder_in_progress: "{% if node_type == 'master' %}{{ folder }}/{{ target }}/test{{ hostvars['localhost']['tstamp'].stdout }}{{ type }}{% else %}{{ folder }}/{{ target }}/prod{{ hostvars['localhost']['tstamp'].stdout }}_{{ type }}{% endif %}" All in one string, no nested braces, if/else/endif with {% %} You could ...


2

You should use wait_for_connection instead. tasks: - name: Execute the script shell: bash testscript.sh args: chdir: /home/ubuntu - name: wait wait_for_connection: delay: 10 I'd advise to do this in a task, not a handler. The handler is only executed after all tasks have been finished, so if you have tasks following the task ...


3

That's not possible. At some point you need to store something that allows you to decrypt the password. Use credentials that are generated specifically for this process, no personal credentials. Restrict access to the password file to people who have to use it. There is nothing more you can do.


0

Ansible vaults does for same. Ref:https://docs.ansible.com/ansible/2.9/user_guide/vault.html#:~:text=Ansible%20Vault%20is%20a%20feature,or%20placed%20in%20source%20control.


0

Ok finally I found the solution. The problem is that when the partition is not mounted, it have no UUID. When working with data partitions like xfs, extX, etc... The partition is directly mounted by the system, so the partition is getting direclty an UUID. It's not the case for a swap partition, you must first enable it with mkswap for the system can mount ...


1

As far as I understand the scenario and know from own experience, the behavior seems to be intended. The OS must be "forced" to re-read the partition table once changes have been done and before one will be able to get the new device information. Further links Reread partition table without rebooting partprobe usage Ansible Issue #48034 Ansible ...


3

Ansible does not have its own daemon or protocol. Communication with remote hosts is over existing management protocols. Likely SSH for POSIX boxes, WinRM for Windows, or various http or ssh command line APIs for network gear. While I suggest the well-known ports for each, the port number can be changed in most connection plugins. To connect various nets, ...


1

You missed a dash in front of block. Removing all attributes your tasks look like this: tasks: - name: get Cluster state - name: trigger Zero Downtime upgrade API block: # ^-- dash missing - name: "Upgrade {{ ansible_hostname }} atl node." - name: create dir for backup configuration - name: "stop atl service on {{ ...


1

You can place all recurring tasks in a block. Combined with serial: 1 you make sure that only one block is executed at a time. - hosts: nodes serial: 1 tasks: - name: get cluster state shell: "RESTAPI 1 command" run_once: yes - name: put cluster in upgrade mode shell: "RESTAPI 2 command" run_once: yes ...


1

"Doesn't work" is a very vague description of your problem, but this is not a valid task definition: - name: Dict test include_vars: test1.yml debug: msg: "User {{ item.key }} is {{ item.value.name }} ({{ item.value.telephone }})" loop: "{{ lookup('dict', users) }}" include_vars and debug are individual ...


0

Fixed it by checking and installing correct Java version with lean_delivery.java ansible role (var java_major_version: 8)


0

Vars can be defined as expressions referencing other vars. Allows splitting an expression to a reasonable size. The environment keyword can apply to all tasks of a play. This can reference vars defined anywhere. module_defaults can also be used to provide a value to use when none is provided. This tends to be helpful for repetitive things like API creds in ...


1

You can just set a var directly: vars: url: https://{{ username }}:{{ token }}@hosting.com/organization username: "{{ hashivault_secrets.value.data.USERNAME }}" token: "{{ hashivault_secrets.value.data.TOKEN }}" Or you can use set_fact: - set_fact: url: https://{{ username }}:{{ token }}@hosting.com/organization vars: ...


0

You can do this using set_fact. - set_fact: url: "https://{{ hashivault_secrets.value.data.USERNAME }}:{{ hashivault_secrets.value.data.TOKEN }}@hosting.com/organization"


Top 50 recent answers are included