Re: [ansible-project] Combine dictionaries based on a dictionary key value.

2020-06-30 Thread Vladimir Botka
list - set_fact: aggregate_info2: "{{ aggregate_info2|default([]) + [agg[item]|combine(net[item])] }}" loop: "{{ agg.keys()|list }}" HTH, -vlado -- Vladimir Botka -- You received this message because you are subscribed to the Goog

Re: [ansible-project] Combine dictionaries based on a dictionary key value.

2020-06-30 Thread Vladimir Botka
... > }] The values of "node_name" does not correspond. It would be good to test it. For example - fail: msg: Values of node_name(s) do not fit when: aggregate_info|map(attribute='node_name')|list| difference(net_interface|map(attribute='node_name')|list)

Re: [ansible-project] Looping a task until it succeeds

2020-06-26 Thread Vladimir Botka
is tested for success. Hence the default value {"rc": 1} because we always want to run the first iteration. Next iterations evaluate de facto the following expression because "result" was provided by the previous iteration result.rc == 0 HTH, -vlado -- Vladi

Re: [ansible-project] Can’t use dash with numbers as hostname

2020-06-26 Thread Vladimir Botka
"test1": { "ansible_host": 9 }, "test2": { "ansible_host": 9 } } }, "all": { "children": [ "ungrouped" ] }

Re: [ansible-project] Looping a task until it succeeds

2020-06-25 Thread Vladimir Botka
t] => (item=4) skipping: [localhost] => (item=5) ...ignoring -- 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 ansi

Re: [ansible-project] Looping a task until it succeeds

2020-06-25 Thread Vladimir Botka
', '==', 0)| map(attribute='item')| first }}" - debug: var: first gives first: '4' -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this gr

Re: [ansible-project] Looping a task until it succeeds

2020-06-25 Thread Vladimir Botka
/forum/#!topic/ansible-project/uJqSmkKTpZc -- 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...@googlegro

Re: [ansible-project] Loop over list of dicts in ansible

2020-06-24 Thread Vladimir Botka
On Wed, 24 Jun 2020 06:02:02 -0700 (PDT) BIJAY PARIDA wrote: Try this - set_fact: versions: "{{ lv|map(attribute='Version')|list }}" -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group.

Re: [ansible-project] Run a task on only one server in a group in inventory.

2020-06-24 Thread Vladimir Botka
nclude_role: name: my_library_of_tasks tasks_from: task_on_one_server_only.yml run_once: true - hosts: gcp tasks: - include_role: name: my_library_of_tasks tasks_from: task_on_one_server_only.yml run_once: true HTH, -vlado -- Vladi

Re: [ansible-project] Re: how to restrict scope for set_fact variable

2020-06-19 Thread Vladimir Botka
variable (obj_name and item_ip_exists ) and print the correct debug > > messages. > > but when 2nd item executed and there if object is not present so it is > > printing the wrong debug message due to the set_fact variables( obj_name > > and item_ip_exists) which h

Re: [ansible-project] group_by with random key values

2020-06-12 Thread Vladimir Botka
ach of those groups. If the top-down decomposition is too complicated I'd suggest to try bottom-up approach. Let the remote hosts periodically check for updates, including passwords https://docs.ansible.com/ansible/latest/cli/ansible-pull.html -- Vladimir Botka -- You received this message because

Re: [ansible-project] group_by with random key values

2020-06-11 Thread Vladimir Botka
//github.com/vbotka/ansible-linux-postinstall/blob/master/tasks/passwords.yml -- 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 a

Re: [ansible-project] List all variables only defined in hosts file corresponding to a host

2020-06-11 Thread Vladimir Botka
list of user-defined variables plus Ansible "special variables" https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html#special-variables If you want to proceed this way create and subtract the list of special variables (I don't know how to automate this), and fi

Re: [ansible-project] What does the output from the dynamic inventory software look like?

2020-06-10 Thread Vladimir Botka
quot;sw" in the "debug" task works because it was declared in the first play's task "add_host". In your code the variable "pkg" is in the "hostvars" of localhost only. See "hostvars" https://docs.ansible.com/ansible/latest/user_guide/playbooks_var

Re: [ansible-project] What does the output from the dynamic inventory software look like?

2020-06-09 Thread Vladimir Botka
=0 rescued=0 ignored=0 test_01 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=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 fr

Re: [ansible-project] Match two strings in when condition from registered output

2020-06-09 Thread Vladimir Botka
On Mon, 8 Jun 2020 17:52:25 -0400 vinay kumar wrote: >shell: systemctl list-unit-files --all --state=disabled,enabled,unknown > --no-legend --no-pager >register: _service_status > > comment: "tftp service is in enabled" > when: _service_name _expected_state in service_status >

Re: [ansible-project] Match two strings in when condition from registered output

2020-06-08 Thread Vladimir Botka
On Tue, 9 Jun 2020 06:27:41 +0200 Dick Visser wrote: > OK... and what would you DO with this information..? Nothing. Why are you asking? -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe fr

Re: [ansible-project] Match two strings in when condition from registered output

2020-06-08 Thread Vladimir Botka
- "'httpd' in item" - "'disabled' in item" should give ok: [localhost] => (item=1: httpd disabled) => { "ansible_loop_var": "item", "item": "1: httpd disabled" } skipping: [localhost] => (item=2: tftp

Re: [ansible-project] disable_service_controls is not working

2020-06-07 Thread Vladimir Botka
> > > when: "{{ disable_service_controls| > > > default(false) }}" == false > > when: disable_service_controls| > > default(false)| > > bool On Sun, 7 Jun 2020 12:29:48 -0400 Vishwas Govekar wrote: > Does the script look good > [...] > when:

Re: [ansible-project] disable_service_controls is not working

2020-06-06 Thread Vladimir Botka
.. update your conditional statements so they accept only boolean values." In addition to this, try --extra-vars. Extra vars pass the values always as strings. The explicit conversion to boolean is necessary. shell> ansible-playbook pb.yml -e "disable_service_controls=true" HTH,

Re: [ansible-project] Can we use Ansible to deploy tasks on hardware level e.g., firmware upgrade on dell server

2020-06-05 Thread Vladimir Botka
role search --galaxy-tags dell bios shell> ansible-galaxy role search --galaxy-tags hp bios shell> ansible-galaxy role search --galaxy-tags ibm bios -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To

Re: [ansible-project] Issue while parsing Complex Regular expression in YAML file

2020-06-04 Thread Vladimir Botka
"msg": "OK" } ok: [localhost] => (item=!) => { "msg": "OK" } skipping: [localhost] => (item=}) HTH, -vlado -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups

Re: [ansible-project] Issue while parsing Complex Regular expression in YAML file

2020-06-04 Thread Vladimir Botka
"msg": "OK" } ok: [localhost] => (item=+) => { "msg": "OK" } skipping: [localhost] => (item=}) HTH, -vlado -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project

Re: [ansible-project] How can i get ip addresses of group hostnames

2020-06-02 Thread Vladimir Botka
On Tue, 2 Jun 2020 03:57:57 -0700 (PDT) Arko Köst wrote: > So what should i do? Collect facts from all hosts and find items that fit the purpose. -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To uns

Re: [ansible-project] How can i get ip addresses of group hostnames

2020-06-02 Thread Vladimir Botka
onment. -- 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

Re: [ansible-project] How can i get ip addresses of group hostnames

2020-06-02 Thread Vladimir Botka
g_hba.conf.j2 dest: /tmp/pg_hba.conf delegate_to: localhost run_once: true Take a look at the facts collected by "setup" and fit the template to your needs. See what facts are available shell> ansible remote_host -m setup HTH, -vlado -- Vladimir B

Re: [ansible-project] src module not working as mentioned/expected.

2020-06-01 Thread Vladimir Botka
On Mon, 1 Jun 2020 13:05:18 -0700 (PDT) "SUNU ." wrote: > As per the definition src module There is no src module. https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html -- Vladimir Botka -- You received this message because you are subscribed to the

Re: [ansible-project] loop query

2020-05-30 Thread Vladimir Botka
precated the use of with_ - that syntax will still be valid for the foreseeable future." -- 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, se

Re: [ansible-project] reuse of paramter value inside configuration file

2020-05-29 Thread Vladimir Botka
On Fri, 29 May 2020 13:20:22 -0700 (PDT) דודו דודו wrote: > user_details: > - {username: user3, > uid: 2001, > user_domain_password: 1234@WSX, > keytab_name: {{ username }}.keytab } Referencing a key in a dictionary doesn't work.

Re: [ansible-project] Issue with lineinfile module #69739

2020-05-29 Thread Vladimir Botka
On Thu, 28 May 2020 22:14:35 -0700 (PDT) Amith sha wrote: > Tried to write a line using lineinfule module sequentially were observed > that the random lines are missed to write on the file. > > serial: 100 > > - name: Write Disks Data to file > lineinfile: ... > delegate_to:

Re: [ansible-project] Re: Parsing results

2020-05-26 Thread Vladimir Botka
On Tue, 26 May 2020 16:47:22 -0700 (PDT) ChrisV wrote: > `network_interfaces` is a list. You will need to include the index of the > interface, which is 0 in your example. > > Ex. "{{ ec2_facts.instances.network_interfaces[0] }}" The loop below would work in this case. > > - name: setting

Re: [ansible-project] Parsing results

2020-05-26 Thread Vladimir Botka
On Mon, 25 May 2020 17:20:35 -0700 (PDT) Andrew Morgan wrote: > - name: setting fact for subnet ID >set_fact: SUBNETID="{{ item.subnet_id }}" >with_items: "{{ ec2_facts.instances.network_interfaces }}" This one looks promising. To move forward simple debug must work first - debug:

Re: [ansible-project] Merge Dictionary

2020-05-25 Thread Vladimir Botka
On Sun, 24 May 2020 07:10:36 -0700 (PDT) Shaun Rampersad wrote: > PS: I'm part of Isa's team :) I'll also take a look at the ansible plugin Let me know if this might meet the high standards of the code. -- You received this message because you are subscribed to the Google Groups "Ansible

Re: [ansible-project] ansible shell variable

2020-05-24 Thread Vladimir Botka
On Sun, 24 May 2020 20:31:12 -0700 (PDT) Andrew Morgan wrote: > > > 1) get the mac address > > > 2) get the subnet > > > > > > --- > > > - hosts: dev > > > become: true > > > #connection: local > > > gather_facts: true > > Run the command below a see what "facts" are available

Re: [ansible-project] ansible shell variable

2020-05-24 Thread Vladimir Botka
On Sun, 24 May 2020 16:55:52 -0700 (PDT) Andrew Morgan wrote: > 1) get the mac address > 2) get the subnet > > --- > - hosts: dev > become: true > #connection: local > gather_facts: true Run the command below a see what "facts" are available when "gather_facts: true" is enabled.

Re: [ansible-project] [WARNING]: provided hosts list is empty, only localhost is available

2020-05-24 Thread Vladimir Botka
On Sun, 24 May 2020 16:13:56 -0700 Tony Wong wrote: > [WARNING]: provided hosts list is empty, only localhost is available. Note > that the implicit localhost does not match 'all' Run the command below a see what's going on shell> ansible-inventory -vvv --graph -- You received this message

Re: [ansible-project] Merge Dictionary

2020-05-22 Thread Vladimir Botka
(list in the loop) On Fri, 22 May 2020 23:58:06 +0200 Vladimir Botka wrote: > > > > > - set_fact: > > > > > my_users: "{{ my_users|default([]) + my_vars.users }}" > > > > > loop: > > > > >

Re: [ansible-project] Merge Dictionary

2020-05-22 Thread Vladimir Botka
On Fri, 22 May 2020 09:58:10 -0700 (PDT) Isa wrote: > Thanks that works , I wish it was cleaner though. Appreciate the help > > > > - set_fact: > > my_users: "{{ my_users|default([]) + my_vars.users }}" > > loop: > > - group_vars/all > > -

Re: [ansible-project] Merge Dictionary

2020-05-22 Thread Vladimir Botka
On Fri, 22 May 2020 04:23:51 -0700 (PDT) Isa wrote: > How can I merge dictionary with the same name. > > *groups_vars/all* > users: > - name: jsmith > comment: 'John Smith' > shell: /bin/bash > groups: wheel > > > *group_vars/postgresql.yml* > users: > - name: tdoe >

Re: [ansible-project] Process Monitoring in Ansible

2020-05-21 Thread Vladimir Botka
On Thu, 21 May 2020 17:59:15 -0700 (PDT) Jenisha T wrote: > Is there a way in Ansible to find if process complete. I m running an > os-copy process. How to check if the process completed. The hard way is to > wait for 2hrs and read logs to find the word in the log is there a > sentence "OS

Re: [ansible-project] How to check process running time

2020-05-20 Thread Vladimir Botka
On Wed, 20 May 2020 00:29:19 -0700 (PDT) Jenisha T wrote: > I need to kill a process if its older than 1 hour. I have process id how > to check if its older than 1 hour There is no such Ansible module. It'll be necessary to use 'command'. For example, in Linux or *BSD, get elapsed time of the

Re: [ansible-project] Copy a folder from remote host to local using Ansible.

2020-05-19 Thread Vladimir Botka
On Tue, 19 May 2020 05:41:30 -0700 (PDT) Divya Punna wrote: > copy a folder from remote host to local Try - hosts: remote_host tasks: - synchronize: mode: pull src: "{{ dir_on_remote_host }}" dest: "{{ dir_on_localhost }}" -- You received this

Re: [ansible-project] Create folder using command line

2020-05-18 Thread Vladimir Botka
> companies: > - company_folder_name: /ibm >department: > - it > - logistic > - company_folder_name: /hp >department: > - company_folder_name: /dell >department: > - it > ## Createing the main folders - working fine ## >

Re: [ansible-project] How to pass 'hosts' value to an imported or included playbook?

2020-05-18 Thread Vladimir Botka
On Mon, 18 May 2020 11:44:13 -0700 (PDT) Peter Bi wrote: > ... make A to work dynamically with different hosts depending on the > playbooks (B/C/D/E/etc.) IMHO, this is easier manageable from outside of the playbook. See for example

Re: [ansible-project] Re: Exit with_items loop after first success?

2020-05-18 Thread Vladimir Botka
On Sun, 17 May 2020 02:19:26 -0700 (PDT) Nikolay Dimov wrote: > I ended up using the following hack: > > - name: shell test > shell: "{{ item }}" > with_items: > - /bin/true > - /bin/false > - /bin/true > when: r_shell.rc|default(0)==0 > register: r_shell > > This exits on first failure.

Re: [ansible-project] Remove items from a variable with reject

2020-05-17 Thread Vladimir Botka
On Sun, 17 May 2020 13:57:57 -0700 (PDT) Kernel Panic wrote: > List ... contains contains item1, item2, item3, item4, item5. I want to > remove item1 and 2 (from myvar) > > - set_fact: > list_of_items: "{{ list.stdout_lines| >reject('search', item )| >

Re: [ansible-project] What are the possible setups for ansible in the cloud to configure on premise devices?

2020-05-17 Thread Vladimir Botka
On Sun, 17 May 2020 08:13:16 -0700 (PDT) Nicolas Charalambous wrote: > "How do I use Ansible in a production environment to configure a large > number of on-premise devices via a cloud environment?" An elegant and flexible solution would be to build the architecture on "ansible-pull" (similar

Re: [ansible-project] Setting an intial cron job and leaving it alone on later plays

2020-05-17 Thread Vladimir Botka
On Sun, 17 May 2020 05:37:10 -0400 Ben Coleman wrote: > ... prepping a cron job that can be completed and enabled > > - name: Create cron job > cron: > name: Drupal cron job > disabled: true > minute: "*/15" > job: curl --silent --compressed url > user: "{{ username }}" >

Re: [ansible-project] Is there a better way to search through a list using when and regex_search

2020-05-15 Thread Vladimir Botka
On Fri, 15 May 2020 08:25:40 -0700 (PDT) Scott Fella wrote: > ... The changes works well, except when there is a host that has failed FWIW. See how to create a group of reachable hosts first. https://github.com/vbotka/ansible-lib/blob/master/tasks/al_hosts_reachable.yml -- You received this

Re: [ansible-project] Is there a better way to search through a list using when and regex_search

2020-05-15 Thread Vladimir Botka
On Thu, 14 May 2020 15:58:08 -0700 (PDT) Scott Fella wrote: > gist: https://gist.github.com/fella5/6842043ccc35f013c9092c6520dfb593 See https://gist.github.com/vbotka/32616e8d896ef22d985bdb707915c9f0 Split the playbook search_snmp_v1.yml to two plays. Collect the data in the first play. Then

Re: [ansible-project] Is there a better way to search through a list using when and regex_search

2020-05-14 Thread Vladimir Botka
On Thu, 14 May 2020 13:16:53 -0700 (PDT) Scott Fella wrote: > When trying to use the jinja2 template and running this playbook over > multiple hosts, the file gets overwritten. This works for a single device > if there is a match. > > {{ inventory_hostname }} > > {% for line in

Re: [ansible-project] escaping curly braces in lineinfile module

2020-05-14 Thread Vladimir Botka
On Thu, 14 May 2020 08:16:20 -0700 (PDT) Laci wrote: > Another task I'm working on is a conditional blockinfile, something like: > if OS=BSD do this, if Linux do that. > > I need this because there is a slightly different configuration for them: > > BSD: > Job { > Name= "serverX"

Re: [ansible-project] Is there a better way to search through a list using when and regex_search

2020-05-14 Thread Vladimir Botka
On Thu, 14 May 2020 09:58:22 +0200 Vladimir Botka wrote: > - name: Create list of search results > set_fact: > my_search: "{{ my_search|default([]) + >[preOutputSummary.stdout is search(item)] }}" >

Re: [ansible-project] Is there a better way to search through a list using when and regex_search

2020-05-14 Thread Vladimir Botka
On Wed, 13 May 2020 15:16:30 -0700 (PDT) Scott Fella wrote: > .. how to integrate your feedback to my playbook. Searching "preOutputSummary.stdout[0]" doesn't make sense. To clarify the difference between ".stdout" and ".stdout_lines" of registered output. ".stdout" is a string and

Re: [ansible-project] Is there a better way to search through a list using when and regex_search

2020-05-13 Thread Vladimir Botka
On Wed, 13 May 2020 10:44:18 -0700 (PDT) Scott Fella wrote: > ... can I simplify the when? > (when one of the items in the list is found in the output?) It's possible to create a list of the "search" results and use the test "any". For example the playbook

Re: [ansible-project] escaping curly braces in lineinfile module

2020-05-12 Thread Vladimir Botka
On Tue, 12 May 2020 13:42:00 -0700 (PDT) Laci wrote: > Thank you vlado, this worked for me: > > blockinfile: > path: /conf.d/jobs.inc > marker: " " > block: | > Job { > Name= "{{ remote_shorthost }}" > Client = "{{ remote_shorthost }}-fd" >

Re: [ansible-project] escaping curly braces in lineinfile module

2020-05-12 Thread Vladimir Botka
On Tue, 12 May 2020 12:32:11 -0700 (PDT) Laci wrote: > % cat jobs.inc > Job { > Name= "server1" > Client = "server1-fd" > JobDefs = "DefaultJob" > } > Job { > Name= "server2" > Client = "server2-fd" > JobDefs = "DefaultJob" > } > > How would I add server3? The best option

Re: [ansible-project] Re: Ansible is ignoring my group vars, hoping I'm doing something obviously wrong...

2020-05-10 Thread Vladimir Botka
Hi David, On Sun, 10 May 2020 11:21:18 -0700 (PDT) David Sudia wrote: > My understanding was that group_vars needed to be in the same directory as > the inventory to work, but in your example it looks like group_vars is one > directory up, is that correct? Yes. It is correct. Ansible loads

Re: [ansible-project] Ansible lininfile behavior

2020-05-10 Thread Vladimir Botka
On Tue, 5 May 2020 22:06:04 +0200 Kai Stian Olstad wrote: > On Mon, May 04, 2020 at 11:55:14PM +0200, Vladimir Botka wrote: > > Well, I tried and it's working properly with Python3. There is no problem > > with > > Ansible 2.9.6 and Python 3.8 on the controller > &g

Re: [ansible-project] Ansible is ignoring my group vars, hoping I'm doing something obviously wrong...

2020-05-09 Thread Vladimir Botka
On Sat, 9 May 2020 16:32:49 -0700 (PDT) David Sudia wrote: > dba.yml (a playbook) > inventory/ > union.gcp.yml (a dynamic gcp inventory) > group_vars/ > all/ > vars.yml > vault.yml > dba/ > vars.yml > roles/ > someroleshere/ > > $ ansible-playbook -i inventory

Re: [ansible-project] Range function in Ansible?

2020-05-08 Thread Vladimir Botka
On Fri, 8 May 2020 08:49:14 -0700 (PDT) Albert Short wrote: > Scenario: > Variables I am using > access_hostname: > - name: dariusz_access1 > nodeid_access: 1001 > from_port: '04' > vlanid: > - 201-204,500-510 > podid: 1 > int_mode: regular >

Re: [ansible-project] Adding task output to a file in a loop

2020-05-07 Thread Vladimir Botka
On Wed, 6 May 2020 12:41:54 -0700 (PDT) harry devine wrote: > for uid in {1000..6500} > user = ipa user-find --uid=$uid --raw |grep uid: | awk '{print $2}' > echo "user,uid" >> uid.csv > do This is the Ansible equivalent, I think. The module "getent" creates the dictionary "getent_passwd".

Re: [ansible-project] Problem using when condition for empty variable

2020-05-07 Thread Vladimir Botka
On Thu, 7 May 2020 02:25:16 -0700 (PDT) דודו דודו wrote: > Using domain_name | default("") == "" skip the task no matter if i have > value or not This is not what I see. Both the comparison to an empty string and testing the length should work. For example hosts: localhost tasks: -

Re: [ansible-project] Problem using when condition for empty variable

2020-05-07 Thread Vladimir Botka
On Thu, 7 May 2020 02:25:16 -0700 (PDT) דודו דודו wrote: > Using domain_name | default("") == "" skip the task no matter if i have > value or not Compare the lenght to 0 then when: domain_name|default("")|length == 0 -- You received this message because you are subscribed to the

Re: [ansible-project] Problem using when condition for empty variable

2020-05-07 Thread Vladimir Botka
> when: domain_name | default("") == "" Don't compare to empty string. Test the length instead https://github.com/ansible/ansible-lint/blob/master/lib/ansiblelint/rules/ComparisonToEmptyStringRule.py when: domain_name|default("")|length > 0 -- You received this message because you are

Re: [ansible-project] ansible include_role syntax problem

2020-05-06 Thread Vladimir Botka
On Wed, 6 May 2020 03:20:30 -0700 (PDT) Meir Yanovich wrote: > --- > - name: check if exsist > hosts: localhost > gather_facts: false > tasks: > - name: this is test >include_role: > static: no > name: utilities >

Re: [ansible-project] add_host scope from inside roles

2020-05-05 Thread Vladimir Botka
On Tue, 5 May 2020 09:48:44 -0700 (PDT) Nicola Limongi wrote: > THIS WORKS (from the playbook) > --- > - name: "provision Ec2" > hosts: localhost > connection: local > gather_facts: false > tasks: > - ec2_instance: > name: "{{ ec2_name }}" > security_groups: > [ecc

Re: [ansible-project] Ansible lininfile behavior

2020-05-05 Thread Vladimir Botka
On Tue, 5 May 2020 00:47:10 +0200 Vladimir Botka wrote: > On Tue, 5 May 2020 00:02:40 +0200 > Kai Stian Olstad wrote: > > > On Mon, May 04, 2020 at 11:19:53PM +0200, Vladimir Botka wrote: > > > There is no such problem with Ansible running on

Re: [ansible-project] Ansible lininfile behavior

2020-05-04 Thread Vladimir Botka
On Tue, 5 May 2020 00:02:40 +0200 Kai Stian Olstad wrote: > On Mon, May 04, 2020 at 11:19:53PM +0200, Vladimir Botka wrote: > > There is no such problem with Ansible running on controller with Python 3 > > That's just not true, your test method is flawed, you need to test it m

Re: [ansible-project] Ansible lininfile behavior

2020-05-04 Thread Vladimir Botka
On Mon, 4 May 2020 23:06:50 +0200 Kai Stian Olstad wrote: > > > Add "throttle: 1" to you lineinfile task and it will work. > > > > I don't need "throttle" with 2.9.6. The playbook > > That is just pure luck, try running it 100 times and count how many times it > fails. Well, I tried and

Re: [ansible-project] Ansible lininfile behavior

2020-05-04 Thread Vladimir Botka
On Mon, 4 May 2020 13:26:41 -0700 (PDT) Justin Nelson wrote: > The file contents after that pass are: > > 1 macs: > 2 test-host222: ab:09:87:65:43:21 > > With the file contents now the following: > > 1 macs: > 2 test-host222: ab:09:87:65:43:21 > 3 test-host111:

Re: [ansible-project] Ansible lininfile behavior

2020-05-04 Thread Vladimir Botka
On Mon, 4 May 2020 13:26:41 -0700 (PDT) Justin Nelson wrote: > The file contents after that pass are: > > 1 macs: > 2 test-host222: ab:09:87:65:43:21 > > And when I run it a second time: > > 1 macs: > 2 test-host222: ab:09:87:65:43:21 > 3 test-host111: 12:34:56:78:90:ab It's

Re: [ansible-project] Ansible lininfile behavior

2020-05-04 Thread Vladimir Botka
On Mon, 4 May 2020 22:31:49 +0200 Kai Stian Olstad wrote: > > [test_group] > > host1 > > host2 > > Since you have two host you will have two tasks that tries to write to the > same > file at the same time, and only one of them will win. > > Add "throttle: 1" to you lineinfile task and it

Re: [ansible-project] Ansible lininfile behavior

2020-05-04 Thread Vladimir Botka
On Mon, 4 May 2020 11:55:19 -0700 (PDT) Justin Nelson wrote: > - name: Update File > hosts: test_group > ... > tasks: > ... > - name: Update test file > lineinfile: > path: /var/tmp/test.yaml > regexp: "^\ \ test[.-]{{ test_string|lower }}:.*" >

Re: [ansible-project] Ansible lininfile behavior

2020-05-04 Thread Vladimir Botka
On Mon, 4 May 2020 11:55:19 -0700 (PDT) Justin Nelson wrote: > - name: Update File > hosts: test_group > ... > tasks: > ... > - name: Update test file > lineinfile: > path: /var/tmp/test.yaml > regexp: "^\ \ test[.-]{{ test_string|lower }}:.*" >

Re: [ansible-project] Ansible lininfile behavior

2020-05-04 Thread Vladimir Botka
On Mon, 4 May 2020 11:55:19 -0700 (PDT) Justin Nelson wrote: > ... When I run my playbook I can only seem to get one of my two hosts ... > > - name: Update File > hosts: > - test_group > connection: local > > [...] > > [test_group] > host1 > host2 > > [...] > > What am I missing to make

Re: [ansible-project] Re: ansible until with number of retries

2020-04-29 Thread Vladimir Botka
On Wed, 29 Apr 2020 05:21:02 -0700 (PDT) Ivo Hechmann wrote: > ... it looks like there is no suitable solution in ansible Well, this is how Ansible works. A task is sent from the controller to the remote host and the remote host will return the results to the controller after the task will have

Re: [ansible-project] ansible until with number of retries

2020-04-29 Thread Vladimir Botka
On Wed, 29 Apr 2020 01:52:47 -0700 (PDT) Ivo Hechmann wrote: > ansible should retry the command, lets say 5 tries: > > - name: process something, fail if not 5 files in tmpdir > shell: "/home/ivo/workspace/splunk-envs/scripts/retry/run.sh" > ignore_errors: True > register: status_var >

Re: [ansible-project] Jinja template error while using with copy module

2020-04-28 Thread Vladimir Botka
On Tue, 28 Apr 2020 12:45:14 -0700 (PDT) Suresh Karpurapu wrote: > - name: makeing file backup as vfstab.bkp in /tmp > copy: |- > {% if ansible_os_family == "Solaris" %} > src=/etc/vfstab dest=/tmp/vfstab.bkp remote_src=yes > {%- else %} > src=/etc/fstab dest=/tmp/fstab.bkp

Re: [ansible-project] Need to pass variable and hostname to a playbook from CSV file.

2020-04-27 Thread Vladimir Botka
Errata: > - name: mounting the volume in the fstab file > mount: > fstype: nfs > ... > src: "{{ item.0 }}" > path: "{{ item.1 }}" > state: mounted > with_together: > - "{{ var1 }}" > - "{{ var2 }}" -- You received this

Re: [ansible-project] Need to pass variable and hostname to a playbook from CSV file.

2020-04-27 Thread Vladimir Botka
On Mon, 20 Apr 2020 21:58:34 +0530 Suresh Karpurapu wrote: > ... to achieve my goal as iteration[*have multiple nfs volume in > CSV for each host*] is failing with add_host module due to *BYPASS_HOST_LOOP > = True* in module destination. ... > [...] > - name: list the volumes > hosts: nfsgroup

Re: [ansible-project] condition based on register match

2020-04-27 Thread Vladimir Botka
On Mon, 27 Apr 2020 09:05:26 +0200 Vladimir Botka wrote: Errata 2: > The code implicates a loop > >- name: Mount task 1 - create directory > file: >path: "{{ item.mount_path }}" >state: directory > loop: "{{ my_list_of_mountpoin

Re: [ansible-project] condition based on register match

2020-04-27 Thread Vladimir Botka
On Mon, 27 Apr 2020 09:05:26 +0200 Vladimir Botka wrote: Errata: > Correct syntax is below > >- name: Mount task 1 - create directory > file: >path: /dev/sdb1 path: "{{ mount_point_of_dev_sdb1 }}" >state: direct

Re: [ansible-project] condition based on register match

2020-04-27 Thread Vladimir Botka
On Sun, 26 Apr 2020 23:18:40 -0700 (PDT) דודו דודו wrote: > The task is running even that /dev/sdb1 is included in the register > > *Playbook:* > > - name: check mount > shell: mount | awk '{print $1}' > register: mount > > - debug: > msg: " {{ mount.stdout_lines }}" > >

Re: [ansible-project] condition based on register match

2020-04-27 Thread Vladimir Botka
On Sun, 26 Apr 2020 23:18:40 -0700 (PDT) דודו דודו wrote: > I have a task that mounts devices in a Linux machine. > I wish to run the task only if the device is not mounted, therefore I'm > running a mount command and save the output in a register. > > On the mount task, I'm trying to use

Re: [ansible-project] Playbook that takes IP address of host machines and store these IPs

2020-04-24 Thread Vladimir Botka
On Fri, 24 Apr 2020 00:43:14 -0700 (PDT) PMP wrote: > Can anyone help me to get the playbook that collects the IP addresses of > different host machines and store the output to a file. The playbook and the template below stores first IP found of all hosts into the file my_ips.txt in the

Re: [ansible-project] Playbook hang when running reboot on 16 servers

2020-04-23 Thread Vladimir Botka
> all 16 servers were rebooted, but the playbook hang after the last reported > server. I needed to use CTRL + C in order to release the shell > [...] > - name: Server reboot > reboot: > - name: Verify that all hosts are reachable > ping: > [...] > <10.201.55.18> (0,

Re: [ansible-project] json_query & regular expression

2020-04-12 Thread Vladimir Botka
On Sun, 12 Apr 2020 00:26:39 -0700 (PDT) Kiran Kumar wrote: > { > "attributes": {}, > "cluster": "xx", > "esxi_hostname": "xx", > "guest_fullname": "Microsoftxx", > "guest_name": "xx", >

Re: [ansible-project] json_query & regular expression

2020-04-12 Thread Vladimir Botka
no attribute > 'guest_name'"} Take a look at the structure of "vm_fact" and fix it. If you still have issues post: - debug: var: vm_fact > On Saturday, April 11, 2020 at 10:02:06 PM UTC-7, Vladimir Botka wrote: > > > > - debug: > &g

Re: [ansible-project] json_query & regular expression

2020-04-11 Thread Vladimir Botka
On Sat, 11 Apr 2020 21:26:28 -0700 (PDT) Kiran Kumar wrote: > In jason query how can i add regular expression ? eg if have vm1, vm2,vm3 > below query can be adjusted ? eg query: "[?guest_name == 'vm*' ]" , > seems does not work in below case > > > tasks: > > - name: Gather all VMs

Re: [ansible-project] Need to pass variable and hostname to a playbook from CSV file.

2020-04-09 Thread Vladimir Botka
Hi Suresh, On Thu, 9 Apr 2020 17:46:42 +0530 Suresh Karpurapu wrote: > Hi Vladimir, > > I have one more last question on the same request as we have different > python interpreter on some hosts. Is it possible to read the python > interpreter variable from CSV file while connecting the

Re: [ansible-project] Need to pass variable and hostname to a playbook from CSV file.

2020-04-08 Thread Vladimir Botka
On Wed, 8 Apr 2020 19:55:04 +0530 Suresh Karpurapu wrote: > ... i would like to display all the entries. > > # cat mounts.csv > host,remote_path,mnt_path > host1,nfsvol1,mount1 > host1,nfsvol2,mount2 > host1,nfsvol3,mount3 > host2,nfsvol1,mount1 > host2,nfsvol2,mount2 > host2,nfsvol3,mount3 >

Re: [ansible-project] newbie to ansible

2020-04-07 Thread Vladimir Botka
On Tue, 7 Apr 2020 18:08:48 +0530 mahesh g o wrote: > can this be created alternatively like > vol1: rw > vol2: dp > vol3:rw > vol4:dp > . > . > vol29:rw > vol30:dp Yes. It's possible. Fit the condition to your needs. For example type: "{{ (volume_item|int is odd)|ternary('rw', 'dp') }}"

Re: [ansible-project] newbie to ansible

2020-04-06 Thread Vladimir Botka
On Mon, 6 Apr 2020 21:59:36 -0700 (PDT) mahesh g o wrote: > i have parameter called *type *which has 2 values [ rw and dp]. > How to create 10 volumes with type rw and 10 volumes type dp in > one playbook. An option would be the "ternary" filter. For example

Re: [ansible-project] Abort playbook in case ping task failed

2020-04-06 Thread Vladimir Botka
On Mon, 6 Apr 2020 14:10:18 -0700 (PDT) דודו דודו wrote: > I'm checking ping on a few of my groups. I wish to abort the playbook if > one of the IPs is not reachable > > - hosts: > - postgres1 > - kafka > - repository > become: true > gather_facts: False > tasks: >

Re: Private message regarding: [ansible-project] handle backslash in ansible

2020-04-03 Thread Vladimir Botka
On Fri, 3 Apr 2020 00:36:31 -0700 (PDT) Himanshu Pupneja wrote: > It worked when domain user is inside the playbook. but it doesn't work when > passed at runtime. > > ansible-playbook play.yml -e dname='domain\namam' > > On Friday, 3 April 2020 12:39:50 UTC+5:30, Vl

Re: [ansible-project] handle backslash in ansible

2020-04-03 Thread Vladimir Botka
On Thu, 2 Apr 2020 21:01:45 -0700 (PDT) Himanshu Pupneja wrote: > I have a variable which has value: "domain\user". I am trying to split to > get the user name > > tasks: > - name: handle escape character in domain user > set_fact: > username: "{{

Re: [ansible-project] set_fact moudle error ansible

2020-03-31 Thread Vladimir Botka
On Mon, 30 Mar 2020 20:55:10 -0700 (PDT) Sandy Hung wrote: > fatal: [localhost]: FAILED! => { > "msg": "The task includes an option with an undefined variable. The > error was: 'dict object' has no attribute 'ansible_facts' > [...] > - local_action: > module: efs_info >

Re: [ansible-project] AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_fqdn'

2020-03-31 Thread Vladimir Botka
On Mon, 30 Mar 2020 19:28:13 -0700 (PDT) Rajesh wrote: > - hosts: all > [...] > template: > src: templates/server_list.j2 > dest: /etc/server_list.txt > owner: automation > mode: '0600' > setype: net_conf_t > when: ansible_fqdn in

Re: [ansible-project] nfs client ansible

2020-03-27 Thread Vladimir Botka
On Fri, 27 Mar 2020 09:15:38 + Mark Whaite wrote: > Are you missing a : from the src? > > On Fri, 27 Mar 2020 at 09:08, Sandy Hung wrote: > > fatal: [192.168.1.120]: FAILED! => { > > [...] > > "msg": "Unsupported parameters for (mount) module: sate Supported > > parameters include:

<    1   2   3   4   5   6   7   >