Re: [ansible-project] display information returned with debug in a more usable layout

2022-07-20 Thread Vladimir Botka
ook - hosts: all tasks: - name: check pgBackRest version ansible.builtin.command: /usr/bin/pgbackrest version register: backrest_version - name: Write the CSV file ansible.builtin.copy: dest: pkg.csv content: "{{ content }}"

Re: [ansible-project] display information returned with debug in a more usable layout

2022-07-20 Thread Vladimir Botka
CSV file > ansible.builtin.copy: > dest: pkg.csv > content: |- > {% for k,v in pkg.items() %} > {{ k }},{{ v }} > {% endfor %} > delegate_to: localhost > run_once: true -- Vladimir Botka -- You received this message because y

Re: [ansible-project] Get list of failed instances

2022-07-19 Thread Vladimir Botka
{ ansible_play_hosts_all| difference(ansible_play_hosts) }}" tasks: - assert: that: ok|bool - debug: var: _failed gives _failed: - host2 - host3 -- Vladimir Botka -- You received this message because you are subscribed to the Google Gr

Re: [ansible-project] display information returned with debug in a more usable layout

2022-07-18 Thread Vladimir Botka
t_11: '2.39' test_12: '2.40' test_13: '2.41' Write the CSV file - copy: dest: pkg.csv content: |- {% for k,v in pkg.items() %} {{ k }},{{ v }} {% endfor %} delegate_to: localhost run_once: true You get shell> cat pkg.

Re: [ansible-project] Create a list from a dictionary cycle

2022-07-12 Thread Vladimir Botka
1, srv04, srv07] - [srv02, srv05, srv08] - [srv03, srv06, srv09] 3) Get the slice list_of_servers[:5]: [srv01, srv04, srv07, srv02, srv05] -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe fr

Re: [ansible-project] Launch task with date in var

2022-07-12 Thread Vladimir Botka
On Tue, 12 Jul 2022 11:29:09 +0200 Vladimir Botka wrote: > - debug: > msg: "Launch task for user {{ item.user }} end date." > loop: "{{ users.list }}" > when: item.end == today > - debug: > msg: "Launch task for use

Re: [ansible-project] Launch task with date in var

2022-07-12 Thread Vladimir Botka
sg: "Launch task for user {{ item.user }} start date." loop: "{{ users.list }}" when: item.start == today gives (abridged) msg: Launch task for user alice end date. msg: Launch task for user bob start date. -- Vladimir Botka -- You received this message bec

Re: [ansible-project] How to correctly print a multiline stdout?

2022-07-09 Thread Vladimir Botka
bug: var: result.stdout gives (abridged) shell> ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook pb.yml ok: [localhost] => result.stdout: |- line1 line2 line3 -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups

Re: [ansible-project] ansible playbook ssh-keygen

2022-06-28 Thread Vladimir Botka
On Tue, 28 Jun 2022 06:46:20 -0700 (PDT) Tony Wong wrote: > is there a module to run ssh-keygen on remote hosts? Yes. Module *user* is able to generate a SSH key. See https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html#parameter-generate_ssh_key -- Vladi

Re: [ansible-project] How can I match `\s` or `\t` in a `search` test?

2022-06-20 Thread Vladimir Botka
- debug: msg: "{{ _list is search('bt') }}" vars: _list: ['a', 'b\t'] All tasks above return True. -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this gro

Re: [ansible-project] How can I match `\s` or `\t` in a `search` test?

2022-06-20 Thread Vladimir Botka
{{ regex }} is present in the list." when: ql|select('search', regex)|length > 0 vars: regex: 'abc\\tx' ql: - 'abc\tx' - 123 gives msg: Regex abc\\tx is present in the list. -- Vladimir Botka -- You received this message because yo

Re: [ansible-project] File date/time stamps

2022-06-17 Thread Vladimir Botka
To move on, it will be necessary to learn details. -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@

Re: [ansible-project] Creation date playbook with correct json query in yml file

2022-06-16 Thread Vladimir Botka
ut_day|int vars: days: "{{ (ec2_f_date|to_datetime - item.creation_date| to_datetime('%Y-%m-%dT%H:%M:%S.000Z')).days }}" will display the first image. The other two will be skipped msg: Age of app1 is greater than or equal 2 day(s) --

Re: [ansible-project] data conversion question

2022-06-15 Thread Vladimir Botka
group }}: {{ values|map(attribute='name')|join(',') }} {% endfor %} to get the expected result g1: n1,n2 g2: c1 -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop r

Re: [ansible-project] data conversion question

2022-06-14 Thread Vladimir Botka
p')|map('first')|list| zip(_list|groupby('group')|map('last')| map('map', attribute='name')|list)) }}" -- Vladimir Botka -- You received this message because you are subsc

Re: [ansible-project] data conversion question

2022-06-14 Thread Vladimir Botka
e='name')|list }}" gives _keys: [g1, g2] _vals: - [n1, n2] - [c1] * Create the dictionary _dict: "{{ dict(_keys|zip(_vals)) }}" gives _dict: g1: [n1, n2] g2: [c1] -- Vladimir Botka -- You received this message because you are subscribed to the

Re: [ansible-project] How to convert a dictionary to a list of dictionaries

2022-06-14 Thread Vladimir Botka
[var] + [var] }}" gives var2: - key_1: value_11 key_2: value_21 key_3: value_31 - key_1: value_11 key_2: value_21 key_3: value_31 -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" gro

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-06 Thread Vladimir Botka
n that it does sometimes. When it does, you can run the > playbook with `force_remove_versions` set to true, and it will > remove all the matching lines - both good and bad - before the > second task puts the single entries back in the file, properly > commented or not as the case may be.

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-05 Thread Vladimir Botka
****** localhost: ok=1changed=0unreachable=0 failed=0skipped=1rescued=0ignored=0 -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubsc

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-05 Thread Vladimir Botka
** localhost : ok=2changed=2unreachable=0 failed=0skipped=0rescued=0ignored=0 shell> cat docker-compose #image: graylog/graylog4.2.5 image: graylog/graylog4.2.8 Set the variable *force_remove_versions* as appropriate (for the scenario t

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-05 Thread Vladimir Botka
s is the reason why the first line wasn't replaced. Instead, the second line was added. -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-04 Thread Vladimir Botka
*** localhost: ok=1changed=1unreachable=0 failed=0skipped=0rescued=0ignored=0 shell> cat docker-compose #image: graylog/graylog4.2.5 image: graylog/graylog4.2.8 -- Vladimir Botka -- You received this message because you are subscribed to the

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-03 Thread Vladimir Botka
path: docker-compose regex: '^\s*#*\s*image: graylog/graylog{{ item.key }}\s*$' line: '{{ hash }}image: graylog/graylog{{ item.key }}' loop: "{{ versions|dict2items }}" vars: hash: "{{ item.value|ternary('', '#') }}" -- Vladimir Botka --

Re: [ansible-project] Reading in extra files, as or into dicts?

2022-04-16 Thread Vladimir Botka
flsdkjflsdjflkdjl richard@foo user_vars: alice: gecos: Alice Beatrice,,, name: alice shell: /bin/bash ssh_keys: - alice@foo - alice@bar richard: gecos: Richard Hector,,, name: richard shell: /bin/bash ssh_ke

Re: [ansible-project] Ansible Asynchronous actions

2022-03-17 Thread Vladimir Botka
d delay: 10 retries: 25920 vars: ansible_callback_diy_runner_retry_msg: "" To see details run shell> ansible-doc -t callback community.general.diy -- Vladimir Botka -- You received this message because you are subscribed to the Google Group

Re: [ansible-project] How to stop fileglob lookup warning for not existing paths

2022-03-08 Thread Vladimir Botka
each iteration. In your case, *with_fileglob* must evaluate the list before the condition is applied. *block* is irrelevant here. The condition is applied to all tasks. Try for example - block: - debug: msg: OK1 - debug: msg: OK2 when: false Instead of

Re: [ansible-project] ansible list in dict (need to understand how it works)

2022-03-08 Thread Vladimir Botka
ok['name2,London']: 04-45-67 You'll have to stick with the lists if you are not able to create unique keys. -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails f

Re: [ansible-project] How to stop fileglob lookup warning for not existing paths

2022-03-08 Thread Vladimir Botka
On Tue, 8 Mar 2022 06:20:10 -0800 (PST) "cl...@netsandbox.de" wrote: > That's not really a solution if I have 100 playbook hosts and 5 hosts where > I will deploy files in this way. In this case, it would be more efficient to select those 5 hosts instead of looping all 100. --

Re: [ansible-project] How to stop fileglob lookup warning for not existing paths

2022-03-08 Thread Vladimir Botka
t;{{ item }}" dest: /tmp/ with_fileglob: "files/tmp/{{ inventory_hostname }}/*.yaml" -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving em

Re: [ansible-project] Get memory info using Ansible

2022-02-08 Thread Vladimir Botka
.io/en/stable/intro/#performance-data-collection-settings-for-runner "Runner is capable of collecting performance data (namely cpu usage, memory usage, and pid count) during the execution of a playbook run. Resource profiling is made possible by the use of control groups ..." -

Re: [ansible-project] issue in installation of ansible

2022-02-03 Thread Vladimir Botka
On Thu, 3 Feb 2022 18:08:25 -0800 (PST) Kevin Y wrote: > admin1@Le:~$ ansible -v The option '-v' means verbose. Try '--version' instead. You should see the paths (e.g. ansible 5.2.0 installed by *apt*) ansible python module location = /usr/lib/python3/dist-packages/ansible -- Vladimir Bo

Re: [ansible-project] issue in installation of ansible

2022-02-03 Thread Vladimir Botka
all *pip* and *apt* ansible packages and reinstall them by *apt*. You can find more details in https://askubuntu.com/questions/431780/apt-get-install-vs-pip-install -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" gr

Re: [ansible-project] when condition based on software version

2022-01-30 Thread Vladimir Botka
installed you get, e.g. > ansible-playbook test.yml -e my_pkg=yamllintXY -e my_version=1.20 msg: yamllintXY NOT found If the package is installed but the version is lower you get, e.g. > ansible-playbook test.yml -e my_pkg=yamllint -e my_version=1.21 msg: yamllint NOT found -- Vlad

Re: [ansible-project] Parse a variable using a regex and use parsed variable in a "when"

2022-01-28 Thread Vladimir Botka
ual to, "8.0.28". See "Comparing versions" https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#comparing-versions Test it first, e.g. - debug: msg: Install additional dependency when: play_mysql_version is version ('8.0.28','>=') --

Re: [ansible-project] Add/substract to list items - but without a loop

2022-01-21 Thread Vladimir Botka
On Fri, 21 Jan 2022 09:10:52 -0500 Todd Lewis wrote: > debug: msg: "{{ selection| zip_longest([-1], fillvalue=-1) | map('sum') }}" | You can use *product* instead of *zip*, e.g. selection | product([-1]) | map('sum') -- Vladimir Botka -- You received this messag

Re: [ansible-project] roles - apply variable values from /defaults/main.yml

2022-01-20 Thread Vladimir Botka
e" https://en.wikipedia.org/wiki/Minimal_working_example -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googl

Re: [ansible-project] Literal scalar expands to a dictionary

2022-01-05 Thread Vladimir Botka
How do you decide what looks like python data structure? For example, only the second string below is converted to dictionary, despite the fact that both are valid YAML dictionaries - set_fact: _var3: '{"key1": {{ val1 }}}' _var4: '{"key1": "{{ val1

Re: [ansible-project] Literal scalar expands to a dictionary

2022-01-05 Thread Vladimir Botka
a dictionary but *_var2* expands to a string. Is it > > a feature or a bug? > b. Because jinja2 has historically only had the ability to template > strings, we do some magic to try and convert strings that look like python > data structures to python data structures Why don't you

[ansible-project] Literal scalar expands to a dictionary

2022-01-05 Thread Vladimir Botka
ype_debug: dict _var2|type_debug: AnsibleUnicode *_var1* expands to a dictionary but *_var2* expands to a string. Is it a feature or a bug? Thank you, -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubsc

Re: [ansible-project] Clean up debug output

2021-12-23 Thread Vladimir Botka
single/double quotes of the results are reversed. If this is a problem you'll have to escape them. ok: [localhost] => (item=sshd) => msg: 'ansible_facts.services["sshd.service"]["state"]: active' -- Vladimir Botka -- You received this message because you are subs

Re: [ansible-project] Formatting date in Ansible

2021-12-16 Thread Vladimir Botka
) }}" gives msg: user1 / us...@example.com / 20210715141027Z / 2021-10-13 msg: user2 / us...@example.com / 20210716141027Z / 2021-10-14 msg: user3 / us...@example.com / 20210717141027Z / 2021-10-15 -- Vladimir Botka -- You received this message because you are subscribed to the

Re: [ansible-project] Formatting date in Ansible

2021-12-15 Thread Vladimir Botka
On Thu, 16 Dec 2021 01:24:41 +0100 Vladimir Botka wrote: > On Wed, 15 Dec 2021 12:36:30 -0800 (PST) > "lift...@gmail.com" wrote: > > > password expiration date/value is 20210715141027Z ... how to add 90 days to > > the expiration date. > > For ex

Re: [ansible-project] Formatting date in Ansible

2021-12-15 Thread Vladimir Botka
4:6] }}-{{ pwdexp[6:8] }}" _sec: "{{ (_date|to_datetime('%Y-%m-%d')).strftime('%s')|int + 90 * 24 * 60 * 60 }}" _date90: "{{ '%Y-%m-%d'|strftime(_sec) }}" gives _date90: '2021-10-13' -- Vladimir Botka -- You received this message b

Re: [ansible-project] Re: Problem with delegate_to to group in inventory

2021-12-14 Thread Vladimir Botka
run_once: true - shell: echo OK delegate_to: zabbixslave run_once: true should work as expected TASK [shell] * changed: [zabbixprimary -> zabbixprimary] TASK [shell] * changed: [zabbixprimary -> zabbixslave] -- V

Re: [ansible-project] Remove CRON entry not created with Ansible

2021-11-13 Thread Vladimir Botka
* * admin /sbin/shutdown -r now >/dev/null 2>&1 These two tasks are idempotent. You'll have to run such playbook twice, at least for the first time to add missing descriptions to enabled items. Then you can keep the *lineinfile* task in the playbook to make sure the descriptions are present.

Re: [ansible-project] Clarification on module

2021-11-12 Thread Vladimir Botka
https://docs.ansible.com/ansible/latest/user_guide/become.html#risks-of-becoming-an-unprivileged-user -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it,

Re: [ansible-project] How to append the new group to the existing AllowGroups line in /etc/ssh/sshd_config

2021-10-28 Thread Vladimir Botka
variable, e.g. - lineinfile: path: /etc/ssh/sshd_config backrefs: true regexp: '^\s*AllowGroups\s+(.*?)(\s+{{ add_groups }})*$' line: 'AllowGroups \1 {{ add_groups }}' -- Vladimir Botka -- You received this message because you are subscribed to the Google

Re: [ansible-project] How to append the new group to the existing AllowGroups line in /etc/ssh/sshd_config

2021-10-28 Thread Vladimir Botka
s idempotent. Quoting from *regexp* https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html#parameter-regexp "When modifying a line the regexp should typically match both the initial state of the line as well as its state after replacement by line to ens

Re: [ansible-project] tell 'service' module to continue with playbook, if service isn't found

2021-10-17 Thread Vladimir Botka
postgresql.service state: stopped become: true register: psql_result when: "'postgresql.service' in services" -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe fr

Re: [ansible-project] Template expansion

2021-10-15 Thread Vladimir Botka
completed at the controller. In fact, the modules *stat* and *file* are used behind the scene to write the file at the client. Short answer would be: Is Jinja package needed at the client? -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible

Re: [ansible-project] lineinfile - how to hit them all?

2021-10-11 Thread Vladimir Botka
c/ssh/sshd_config regexp: '^(#*)PasswordAuthentication yes' replace: '\1PasswordAuthentication no' -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it,

Re: [ansible-project] Excluding items from debug output

2021-10-05 Thread Vladimir Botka
ot;/home/jdxadmin") >or (user_list != "/home/test2") Remove the items from the list loop: "{{ user_list|difference(deny) }}" vars: deny: [/home/admin, /home/jdxadmin, /home/test2] -- Vladimir Botka -- You received this message be

Re: [ansible-project] package_facts module

2021-09-29 Thread Vladimir Botka
Jinja https://jinja.palletsprojects.com/en/latest/ YAML specification explains the details https://yaml.org/spec/1.2/spec.html -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group a

Re: [ansible-project] package_facts module

2021-09-29 Thread Vladimir Botka
.name }} {{ p.version }} {% endfor %} {% endfor %} -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubs

Re: [ansible-project] setup module is failing

2021-09-21 Thread Vladimir Botka
connect to the remote host? $ ssh admin@host 2) Are you able to ping it? $ ansible host -u admin -m ping 3) Are you able to run setup? $ ansible host -u admin -m setup 4) Try with Python >= 3.6 ... -- Vladimir Botka -- You received this message because you are subscribed to the Google Gr

Re: [ansible-project] setup module is failing

2021-09-21 Thread Vladimir Botka
On Tue, 21 Sep 2021 01:59:16 -0700 (PDT) Altif wrote: > fatal: [zsdev-nrt-smca2]: FAILED! => { > ... > "msg": "The following modules failed to execute: setup\n" > } > ... > > [zsdev] > zsdev-nrt-smca2 ansible_host=X.X.X.X > > [zsdev:vars] > ansible_ssh_extra_args='-o

Re: [ansible-project] Stop execution on hosts with errors, keep running on hosts where it's fine?

2021-07-28 Thread Vladimir Botka
On Wed, 28 Jul 2021 02:22:03 -0700 (PDT) Mihail T wrote: > stop playbook execution on hosts that faced errors Try block/rescue - block: - command: "cmd_that_may_fail" rescue: - meta: end_host -- Vladimir Botka -- You received this message because you a

Re: [ansible-project] how to use register as a key in yaml?

2021-07-10 Thread Vladimir Botka
he data https://github.com/vbotka/ansible-linux-postinstall/blob/master/vars/main.yml.sample#L304 the template https://github.com/vbotka/ansible-linux-postinstall/blob/master/templates/netplan-conf.j2 and the task to configure Netplan https://github.com/vbotka/ansible-linux-postinstall/blob/maste

Re: [ansible-project] ansible - J2 template

2021-07-01 Thread Vladimir Botka
This string must be included {% endif %} -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.co

Re: [ansible-project] How to get a list of unreachable hosts

2021-06-30 Thread Vladimir Botka
ps://en.wikipedia.org/wiki/Minimal_working_example -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr..

Re: [ansible-project] How to get a list of unreachable hosts

2021-06-30 Thread Vladimir Botka
) }}" 1) Use the filter *join* to create the variable *params* given the list "down=[server1, server2]" 2) Use *delegate_to* and *run_once* instead of the condition 3) The braces {{ }} in the condition is the reason of the syntax error. -- Vladimir Botka -- You rece

Re: [ansible-project] Ansible vault without temp files

2021-06-30 Thread Vladimir Botka
: true gives mp_add: alpha: XSLWBxbxPyDOhYs beta: CdCXIQWsMqpRDao charlie: vPvFieykftXzppi _mp_dict: alpha: XSLWBxbxPyDOhYs beta: CdCXIQWsMqpRDao charlie: vPvFieykftXzppi dummy: dummy Now the file my-pass-dict.vault comprises encrypted dictionary of the hosts and

Re: [ansible-project] How to get a list of unreachable hosts

2021-06-29 Thread Vladimir Botka
sible_play_hosts_all|difference(ansible_play_hosts) }}" - debug: var: down run_once: true gives when the host alpha is down ansible_play_hosts_all: - alpha - beta - charlie ansible_play_hosts: - beta - charlie down: - alpha -- Vladimir Botka -- You receive

Re: [ansible-project] How to break a loop, and return the searched item to the outer callink task?

2021-06-22 Thread Vladimir Botka
*json_query*. The task below gives the same result - set_fact: x: "{{ _list|json_query(query)|first }}" vars: query: "[?a1 == 'A']| [?a2 == `2`]" A custom filter might be the next option to improve the efficiency of searching large lists.

Re: [ansible-project] Block of include_tasks with handler/notify

2021-06-22 Thread Vladimir Botka
-r notify /scratch/ansible-release-notes/ | grep block /scratch/ansible-release-notes/CHANGELOG-v2.11.rst:- notify keyword is not ignored anymore on import_tasks, also able to apply to blocks now. -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "

Re: [ansible-project] Block of include_tasks with handler/notify

2021-06-22 Thread Vladimir Botka
in 2.10 - hosts: localhost tasks: - block: - command: 'true' changed_when: true notify: test handlers: - name: test debug: msg: Handler test running. gives ok: [localhost] => msg: Handler test running. -- Vladimir Botka -- You received t

Re: [ansible-project] Ansible best practices: idempotance

2021-06-18 Thread Vladimir Botka
d. See the structures of copy, template, ... , ini_file. https://ansible-config-light.readthedocs.io/en/latest/guide-variables-files.html#files -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe

Re: [ansible-project] Ansible best practices: idempotance

2021-06-18 Thread Vladimir Botka
latest/guide-variables-files-lineinfile.html#lineinfile The role will collect the data and create the handlers. See https://ansible-config-light.readthedocs.io/en/latest/guide.html#setup -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansib

Re: [ansible-project] Based on vendor have to execute playbook

2021-06-16 Thread Vladimir Botka
_roles gives msg: 'Dell is in in my_roles: True' msg: Runing on Dell -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an em

Re: [ansible-project] How to change password

2021-06-16 Thread Vladimir Botka
On Wed, 16 Jun 2021 18:35:50 +0530 Komal Suthar wrote: > Any approach to change the existing users password on 200 plus machines in > a safe way. Where do you keep the passwords? -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansi

Re: [ansible-project] Help Reading through nested output

2021-06-15 Thread Vladimir Botka
es ips: - 192.168.100.14 Then test the presence of the address in the list, e.g. - debug: msg: "[OK] 192.168.100.14" when: "'192.168.100.15' in ips" vars: ips: "{{ ansible_net_interfaces.GigabitEthernet1.ipv4| m

Re: [ansible-project] help with yaml file

2021-06-08 Thread Vladimir Botka
ok: [localhost] TASK [replace] ** --- before: etc/file1 +++ after: etc/file1 @@ -1,3 +1,3 @@ 10.1.3.50 -10.1.3.51 +10.2.3.54 10.1.3.52 changed: [localhost] => (item=etc/file1) -- Vladimir Botka -- You received this message because you ar

Re: [ansible-project] Opportunity to use signed playbook.

2021-06-07 Thread Vladimir Botka
priate. Use get_url if the signatures are stored remotely https://docs.ansible.com/ansible/latest/collections/ansible/builtin/get_url_module.html -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from

Re: [ansible-project] Opportunity to use signed playbook.

2021-06-07 Thread Vladimir Botka
d If the hash differs the playbook will fail TASK [assert] * fatal: [test_11]: FAILED! => changed=false assertion: result.stat.checksum == my_hash evaluated_to: false msg: Assertion failed -- Vladimir Botka -- You received this message b

Re: [ansible-project] How to run 2 tasks simultaneously in playbook?

2021-06-01 Thread Vladimir Botka
On Tue, 1 Jun 2021 13:31:34 -0700 (PDT) Vikram S wrote: > Asynchronous actions closely matches my requirements but not exactly. What requirement doesn't match the functionality of asynchronous actions? -- Vladimir Botka -- You received this message because you are subscribed to the Goo

Re: [ansible-project] Re: Register variable using {{ item }}

2021-05-28 Thread Vladimir Botka
vars: _arr: "{{ item.0.1.split() }}" - debug: msg: "{{ interfaces[item] }}" loop: - GigabitEthernet0/0/0 - Loopback0 gives msg: 42.151.182.42 msg: 172.31.246.246 -- Vladimir Botka -- You received this message because you are sub

Re: [ansible-project] Re: Register variable using {{ item }}

2021-05-28 Thread Vladimir Botka
ot; should give interfaces: GigabitEthernet0/0/0: 42.151.182.42 Loopback0: 172.31.246.246 -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails fr

Re: [ansible-project] Parsing json files with ansible

2021-05-19 Thread Vladimir Botka
reate a list of *portgroups*, e.g. - set_fact: portgroups: "{{ dvs.dvs_portgroup_info['DVS-Dev-Ork2']| map(attribute='key')|list }}" -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-18 Thread Vladimir Botka
y_dict: a: test value b: "{{ undefined_var }}" gives my_dict.a: VARIABLE IS NOT DEFINED! -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Vladimir Botka
On Sun, 16 May 2021 22:51:02 +0200 Vladimir Botka wrote: > On Sun, 16 May 2021 01:35:46 -0700 > Scott Mcdermott wrote: > > > I cannot use a default because this whole thing is relying > > on whether it's defined or not later to take different actions. > > the fuller

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Vladimir Botka
project == project_bake > or hostvars[target].ipnet is defined > set_fact: > subnet: '{{ > (project == project_bake) | ternary( > subnet_bake, determined_subnet > )}}' What value of *subnet* do you want to set when '(project != project_bake) and (determined_s

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Vladimir Botka
On Sun, 16 May 2021 08:54:29 +0200 Vladimir Botka wrote: > On Sat, 15 May 2021 16:55:24 -0700 > Scott Mcdermott wrote: > > > Hello, why does short circuit only works for the first two cases: > > > > - hosts: localhost > > become: false >

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Vladimir Botka
ion of host vars is the exact same in cases > 2 and 3, it's only going through an indirect variable in case 3. > > This seems to happen regardless of the source of variables ie > extra vars, vars_files, etc. > > Is this a bug, or what am I missing? Why don't you start debugg

Re: [ansible-project] Ansible License Requirements

2021-05-12 Thread Vladimir Botka
https://en.wikipedia.org/wiki/Ansible_(software)#References It seems that the question is rather "How are they supposed to know that source code is the right place to look for a license?" -- Vladimir Botka -- You received this message because you are subscribed to the Google Group

Re: [ansible-project] Ansible License Requirements

2021-05-12 Thread Vladimir Botka
ot;github awx" https://github.com/ansible/ansible https://github.com/ansible/awx -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send a

Re: [ansible-project] using lookup(csvfile) with and encrypted file with vault fails

2021-05-07 Thread Vladimir Botka
to set the variables - set_fact: user: "{{ hpe_sut_cred[inventory_hostname]['user'] }}" pwd: "{{ hpe_sut_cred[inventory_hostname]['pwd'] }}" -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project"

Re: [ansible-project] select/reject filter parameters

2021-05-04 Thread Vladimir Botka
details see https://jinja.palletsprojects.com/en/master/ -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsu

Re: [ansible-project] select/reject filter parameters

2021-05-04 Thread Vladimir Botka
On Tue, 4 May 2021 12:05:36 +0200 Vladimir Botka wrote: On Tue, 4 May 2021 05:27:53 -0400 Dimitri Yioulos wrote: > - local_action: > module: copy > content: | > {% for host in ansible_play_hosts %} > {{ host }} > {{ hostva

Re: [ansible-project] select/reject filter parameters

2021-05-03 Thread Vladimir Botka
found when: list_of_lines| select('search', 'OpenJDK|Java\(TM\)')| list| length > 0 -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from

Re: [ansible-project] Use ansible to get all the servers with specific package

2021-04-29 Thread Vladimir Botka
g)) }}" vars: _mypkg: "{{ ansible_play_hosts_all| map('extract', hostvars, 'mypkg_installed')| list }}" run_once: true gives mypkg_hosts: srv1: true srv2: false -- Vladimir Botka -- You received this message because you

Re: [ansible-project] with-items

2021-04-11 Thread Vladimir Botka
uot;{{ groups_name| default([])| map('extract', d1)| list }}" The command shell> ansible-playbook pb.yml -e '{"groups_name": ["G1","G2"]}' should give msg: A msg: B If you have to keep the data in the lists

Re: [ansible-project] when will the variable substitution happen?

2021-03-31 Thread Vladimir Botka
; > } Use *set_fact* when you want to keep the "current" aka "instantiated" (I'm not sure the wording is correct) value of the variable in hostvars, e.g. - set_fact: testvar02: "{{ testvar02 }}" - debug: var: hostvars[ansible_host

Re: [ansible-project] Inject vault password with plugin

2021-03-17 Thread Vladimir Botka
asswd" src: my_vault_passwd.j2 mode: "0600" - include_vars: vault.yml - template: dest: "{{ playbook_dir }}/my_vault_passwd" src: dummy_vault_passwd.j2 mode: "0600" -- Vladimir Botka -- You received this messa

Re: [ansible-project] Retrieve a value from a dictionary in stderr

2021-03-15 Thread Vladimir Botka
What type is the attribute *stderr*? Try - debug: msg: "{{ sql_delete.stderr|type_debug }}" If the type is string convert it to dictionary first, e.g - debug: msg: "{{ _stderr.xmlhint }}" vars: _stderr: "{{ sql_delete.stderr|from_yaml }}"

Re: [ansible-project] How can I use with_items twice in a single tasks?

2021-03-08 Thread Vladimir Botka
ession to look for in every line of the file ... Only the last line found will be replaced." You might want to mark the blocks and use *blockinfile* if you can't use *template*. -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project

Re: [ansible-project] How can I use with_items twice in a single tasks?

2021-03-08 Thread Vladimir Botka
path: "{{ item.0 }}" regexp: "{{ item.1.from }}" line: "{{ item.1.replace_with }}" with_nested: - - “/opt/file1” - “/opt/file2” - - {from: parameter1=, replace_with: parameter1=test1} - {from: parameter1=, replace_w

Re: [ansible-project] update hots file - the default inventory file

2021-03-03 Thread Vladimir Botka
odule.html - ini_file: dest: /etc/ansible/hosts section: MyServers option: "{{ item }}" allow_no_value: true loop: "{{ servers }}" -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups

Re: [ansible-project] escape square bracket in ansible

2021-03-01 Thread Vladimir Botka
ant. -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web

Re: [ansible-project] escape square bracket in ansible

2021-03-01 Thread Vladimir Botka
'file', 'ip_list.txt').split('\n')| map('from_yaml')|list }}" should give ip_list: - [ipadd1, ipadd2, ipadd3, ipadd4] - [ipadd5, ipadd6, ipadd7, ipadd8] Select the items, e.g. the third item from the second list - debug: var: ip_list[1][2] should give ip

Re: [ansible-project] set custom ssh port when using delegate_to

2021-02-26 Thread Vladimir Botka
> > On Fri, Feb 26, 2021 at 10:28 PM Vladimir Botka wrote: > > Intuitively, I'd expect `delegate_facts: True` is needed to change the > > port of rhel8. > On Fri, 26 Feb 2021 22:55:56 +0100 > Juerg Ritter wrote: > I'm not sure what you are getting at... The above exa

<    1   2   3   4   5   6   7   >