Re: [ansible-project] Looping through a register variable

2024-05-28 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Very subtle but very different. Great catch Todd. In the first instance you create a list that contains a single item – another list called known.stdout_lines. loop: - '{{ known.stdout_lines }}' In the second instance you provide a list called known.stdout_lines as the list for the loop:

Re: [ansible-project] Looping through a register variable

2024-05-28 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Here is an illustration of the difference for those interested. - name: test loop constructs hosts: localhost gather_facts: false become: false vars: my_list: [ one, two, three ] tasks: - name: construct 1 debug: var=item loop: - '{{ my_list }}'

Re: [ansible-project] Create a variable based on a variable

2024-05-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
A dictionary would solve this using the guest name as the key. vcenter: host1: { datacenter: datacenter1, vcenter: vcenter2 } host2: { datacenter: datacenter1, vcenter: vcenter1 } host3: { datacenter: datacenter2, vcenter: vcenter2 } host4: { datacenter: datacenter2, vcenter: vcenter1 }

Re: [ansible-project] Ansible plugin by Pycharm

2024-04-15 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I use vscode for playbook development. It has lots of great plugins, has git built into it for version control, and has an app for every os platform (windows, macOS, linux). Walter -- Walter Rowe, Division Chief Infrastructure Services Division Mobile: 202.355.4123 On Apr 15, 2024, at 7:58 AM,

Re: [ansible-project] interpolation of loop variables

2024-03-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
ot;changed": false, "msg": "All assertions passed" } TASK [an undefined variable] ** fatal: [localhost]: FAILED! => { "assertion": "varA is defined", "changed": false, "evalua

Re: [ansible-project] interpolation of loop variables

2024-03-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I sense that "with templating" does as expected? % ansible --version ansible [core 2.16.4] config file = None configured module search path = ['/Users/wrowe/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location =

Re: [ansible-project] Connection timed out

2024-03-07 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
The failure is due to connect timeout meaning it took too long to establish the SSH session. It could be bad SSH key, sshd not responding, network issue causing dropped packets, asymmetric routing, intelligent firewalls thinking the connection is malicious and dropping it, unknown route to the

Re: [ansible-project] Set variable based on a file's string search

2024-03-07 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
- name: Collect server location ansible.builtin.shell: "/bin/awk '$1 ~ /{{ inventory_hostname }}/ { print $3 }' {{ server_list_file }}" register: grep_result changed_when: ( grep_result.rc != 0 ) You don't need grep AND awk. Learn to use awk's expressions to find what you need in a single

[ansible-project] jinja2_native behavior

2024-03-04 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Is this expected behavior? % ANSIBLE_JINJA2_NATIVE=true ansible -i localhost, localhost -m debug -a var=this -e "this='None'" localhost | SUCCESS => { "this": null } % ANSIBLE_JINJA2_NATIVE=false ansible -i localhost, localhost -m debug -a var=this -e "this='None'" localhost |

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
{{ user_show.results | json_query('[*].json.result.result.{uid: uid[0], pwdchg: krblastpwdchange[0].__datetime__}') }} I would display this info in a debug to see what the resulting data stream looks like. Maybe the selectattr('pwdchg') is in inaccurate reference to pwdchg? Walter -- Walter

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
pwd_expire_soon: "{{ user_show.results | json_query('[*].json.result.result.{uid: uid[0], pwdchg: krblastpwdchange[0].__datetime__}') | selectattr('pwdchg', 'lessthan', 'expire_date') | list }}" What are you expecting this red portion to do? I don't think it is valid in json_query. Walter --

Re: [ansible-project] vars_prompt variables carry over into next tasks

2024-02-21 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
This works. The set_fact makes a global variable for the entire playbook. - hosts: localhost connection: local gather_facts: false become: false vars_prompt: - name: "pemno" prompt: "Enter the number of the created pems" private: no tasks: -

Re: [ansible-project] 'dict object' has no attribute....

2024-02-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
What if you don't place the vars file in a groups_vars subdirectory. What if you place it in the directory of the playbook that runs the roles. vars_files: - my_vars.yml Where my_vars.yml exists next to the playbook? Walter -- Walter Rowe, Division Chief Infrastructure Services Division

Re: [ansible-project] 'dict object' has no attribute....

2024-02-13 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
The error appears to be in '/work/armory/roles/xxx/tasks/xxx.yml': line 266, column 3, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - name: Save new iptables - IPv4 ^ here The error is being reported by a role. Is the

Re: [ansible-project] variable misunderstanding

2024-02-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
kups.postgresql": [ "sonarqube", "other" ] } PLAY RECAP * localhost : ok=2changed=0unreachable=0failed=0 skipped=0rescued=0ignored=0 Walter -- Walter Rowe, Division Chief Infrastructure Services Divis

Re: [ansible-project] variable misunderstanding

2024-02-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
It is important to understand the structure of the data. Your backups variable defines a list, not a dictionary. % cat foo.yml --- - name: list to dict hosts: localhost become: false gather_facts: false vars: backups: - mongodb - postgresql: -

Re: [ansible-project] outputs to a multivalue with_items list.

2024-02-05 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_loops.html#with-items with_items is replaced by "loop" and simply iterates over a list. In the task you can reference any of the dictionary elements of the specific list entry. debug: msg: "{{ item.name }} - {{ item.disabled }}

Re: [ansible-project] [ansible project] VM snapshot capture using VMware

2024-01-22 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Adding to my earlier message .. we use these playbooks in a patching workflow. Snapshot, Patch, if patching fails, revert snapshot. Walter -- Walter Rowe, Division Chief Infrastructure Services Division Mobile: 202.355.4123 On Jan 22, 2024, at 7:22 AM, 'Rowe, Walter P. (Fed)' via Ansible

Re: [ansible-project] [ansible project] VM snapshot capture using VMware

2024-01-22 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
We have these playbooks we use to create a snapshot and to revert a snapshot. The go into an ansible automation platform workflow. The esx-vars.yml has a dictionary you will need to modify for your environment. The dictionary key is a vcenter ID you create. We pass in an extravar for datacenter

Re: [ansible-project] Incomprehensible error message

2024-01-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
: On Thu, 18 Jan 2024 at 13:22, 'Rowe, Walter P. (Fed)' via Ansible Project mailto:ansible-project@googlegroups.com>> wrote: This raises a good observation. It is easy to keep ansible updated. It is not so evident how one can keep their collections updated. How do others keep their colle

Re: [ansible-project] Incomprehensible error message

2024-01-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
This raises a good observation. It is easy to keep ansible updated. It is not so evident how one can keep their collections updated. How do others keep their collections current? Walter -- Walter Rowe, Division Chief Infrastructure Services Division Mobile: 202.355.4123 On Jan 18, 2024, at

Re: [ansible-project] Trying to replace single quote with regex_replace

2024-01-10 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Even better! Brilliant! Walter -- Walter Rowe, Division Chief Infrastructure Services Division Mobile: 202.355.4123 On Jan 10, 2024, at 12:16 PM, Vladimir Botka wrote: "['/First Datacenter/vm/Prod-SRM']" The problem is [' and ']. They can't be part pf the folder name. FWIW, convert the string

Re: [ansible-project] Trying to replace single quote with regex_replace

2024-01-10 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
In plain terms it is really this: [[]'] The outside square brackets define a character set. The characters in between mean "any of these". Since square brackets define a character set we have to escape the inside square brackets to be see as characters in the set. [\[\]'] Since this is

Re: [ansible-project] Trying to replace single quote with regex_replace

2024-01-10 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
This works. regex_replace(\"([\\[\\]'])\",'') Escaping the double quotes that define the search regex gets around needing to escape the single quote. Also note that I collapsed your search into a single character set. --- - name: test hosts: localhost become: false gather_facts:

Re: [ansible-project] Trying to replace single quote with regex_replace

2024-01-10 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Have you tried: regex_replace('(\\[)|(\\])|(\\')', '') Walter -- Walter Rowe, Division Chief Infrastructure Services Division Mobile: 202.355.4123 On Jan 10, 2024, at 9:08 AM, Dimitri Yioulos wrote: Hello, all. I'm working with VMware modules in removing snapshots across all vCenter

Re: [ansible-project] backslashes in regex_replace filter

2024-01-09 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
need to be double-backslashed? Backslash-d is regex for matching on a digit. I just don’t get why doubling the backslash is needed on the 1 but not on the d. On Jan 9, 2024, at 7:53 AM, 'Rowe, Walter P. (Fed)' via Ansible Project wrote:  The \\1 must be double-backslashed because

Re: [ansible-project] backslashes in regex_replace filter

2024-01-09 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
regex_replace('^p(\d+).*$', '\\1') '\\1' in the second argument is a "backref" (backwards reference) to the (\d+) in the first argument. It seems it is looking for an expression with digits and extracting the digits. Your list 't' has names with p1_xyz, p2_xyz, p4_xyx so this regex would

Re: [ansible-project] backslashes in regex_replace filter

2024-01-09 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
The \\1 must be double-backslashed because the backref needs to be backslash-digit (\1). Doubling the backslash escapes the backslash. Walter -- Walter Rowe, Division Chief Infrastructure Services Division Mobile: 202.355.4123 On Jan 8, 2024, at 6:57 PM, Rob Wagner wrote: Thanks Matt, but I

Re: [ansible-project] AD Module

2024-01-02 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
There is the sssd service for Linux that joins a Linux host to an AD domain. With that you can use properly credentialed adcli commands to manipulate AD objects. Walter -- Walter Rowe, Division Chief Infrastructure Services Division On Jan 2, 2024, at 3:06 PM, Todd Lewis wrote: I'm slightly

Re: [ansible-project] execute Synchronize module in AAP 2.3

2023-12-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Chief Infrastructure Services Division Mobile: 202.355.4123 On Dec 13, 2023, at 8:17 PM, Prady A wrote: Thanks a Ton Walter and dick Delegate option filnlally worked.. I wonder how copy module works even though the concept are same. Regards PD On Thu, 14 Dec 2023 at 00:24, 'Rowe, Walter P. (Fed

Re: [ansible-project] execute Synchronize module in AAP 2.3

2023-12-13 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
If the files to sync are part of the project that includes the playbook then it is present inside the container. If the files / folder to sync reside elsewhere, you need to delegate that task(s) to that source system where they reside that you want to sync. Walter -- Walter Rowe, Division

Re: [ansible-project] execute Synchronize module in AAP 2.3

2023-12-13 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
AAP uses execution environments which are containers. If /tmp/memo.txt is not known to the container the task will fail. Walter -- Walter Rowe, Division Chief Infrastructure Services Division Mobile: 202.355.4123 On Dec 13, 2023, at 5:56 AM, Prady A wrote: Hello experts I ve simple piece of

Re: [ansible-project] Regarding file changes in Ansible

2023-11-16 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I agree. This is a version control system action. That action could run an ansible playbook to push the changed file to an inventory of systems. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Nov 16, 2023, at 11:09 AM, Evan Hisey wrote: Honestly

Re: [ansible-project] ansible looking for templates in previous role

2023-10-26 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
You would only call the chrony role. Something like this. - include_role: name: yum_role.yaml - include_role: name: chrony_role.yaml The role would use the template module which should find the template in the chrony role's templates folder. Walter -- Walter Rowe, Division Chief

Re: [ansible-project] ansible looking for templates in previous role

2023-10-26 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Please provide the code that is executing the roles. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Oct 26, 2023, at 7:22 AM, Kathy L wrote: Good morning. I have two roles in a multi-role playbook, for yum, then chrony. The yum module works fine,

Re: [ansible-project] what is ansible.builtin.file vs just file module

2023-10-20 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
It is now recommended that all modules be called by their FQCN (fully qualified community name). These ansible.builtin.file and file are the same, but ansible.builtin.file will always guarantee which file module you mean to reference in case some other community package also has a module named

Re: [ansible-project] Trying to write PB to look at FS 5800 using AAP and gets error

2023-10-13 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Adding to Todd's question .. NFS often does NOT permit root so its permissions are converted to "nobody" unless otherwise specified (if this is really an NFS volume you are copying into). Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Oct 12, 2023,

Re: [ansible-project] using a variable from one task in the next

2023-09-21 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Brian / Todd .. good eyes! Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Sep 21, 2023, at 10:22 AM, Brian Coca wrote: You are confusing scopes, `set_fact` is PER HOST, not a global. So you defined the variable on server1 but are trying to read it

Re: [ansible-project] using a variable from one task in the next

2023-09-21 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
If you gather facts you can reference inventory_hostname_short vs running a shell command. https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html#term-inventory_hostname_short Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123

Re: [ansible-project] using a variable from one task in the next

2023-09-21 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Works for me .. % ansible --version ansible [core 2.15.4] % cat foo.yml --- - name: play 1 hosts: all become: no gather_facts: no tasks: - set_fact: my_fact: "this is a fact" - name: play 2 hosts: all become: no gather_facts: no

Re: [ansible-project] access particular values gathered with stat

2023-09-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
TASK [what is postgres] ok: [localhost] => { "postgres": { "changed": false, "msg": "All items completed", "results": [ {

Re: [ansible-project] access particular values gathered with stat

2023-09-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
You are using "loop". This places the results in a list called "results" (ie postgres.results). Use the literal path in stat and you will get the reference you seek in the debug task. - name: Get stats of a file ansible.builtin.stat: path: /opt/db/data register: postgres - name: return

Re: [ansible-project] using with_sequence with a block

2023-09-05 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
a block? I forgot to put this last part of the code I'd like to use in. - name: Add users user: name: "{{ username }}" password: {{ "passwd" }} shell: /bin/bash On Tue, Sep 5, 2023 at 8:37 AM 'Rowe, Walter P. (Fed)' via Ansible Project wrote: You have to a

Re: [ansible-project] using with_sequence with a block

2023-09-05 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
You have to apply it to each task. Blocks have almost no options. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Sep 5, 2023, at 8:22 AM, Kathy L wrote: We have a variable num_users_to add. I am trying to run a block of commands to generate users

Re: [ansible-project] Need to validate the Service Now Change Request through Ansible tower while deploying any production deployment through Ansible

2023-08-28 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
You are asking us to write your playbook. We can help debug a playbook you have written. We are not going to write it for you. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Aug 28, 2023, at 2:09 AM, srinu talari wrote: Hi, I need a help to

Re: [ansible-project] Shell module commands runs on Local Controller

2023-08-17 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
If the F5 is returning structured data (ie. JSON), then set_fact tasks with filters can help you get to what you need. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Aug 17, 2023, at 10:32 AM, Harry Clendening wrote: I can get the basic disk space

Re: [ansible-project] Shell module commands runs on Local Controller

2023-08-17 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Just remove it, 99% of the time you do not need to specify `connection`. .. and you still can delegate individual tasks to localhost when needed .. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Aug 17, 2023, at 9:59 AM, Brian Coca wrote: That is

Re: [ansible-project] Ansible playbook undefined variable

2023-08-10 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Are you setting herlit_semaphore? If not, how is it being declared? Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Aug 9, 2023, at 4:05 PM, Hernan Sal wrote: Hi, I'm running an ansible playbook called create_admin_user.yml and I'm getting this error

Re: [ansible-project] Variable to be selected from the options

2023-07-26 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Using ansible's order of precedence you can set the default value in the playbook and override it with extra_vars. override.yaml: --- - name: test overriding playbook variable hosts: all become: false gather_facts: false vars: rebootSetting: "ifRequired" tasks: -

Re: [ansible-project] how to install window patches on Multiple Servers thru Ansible

2023-07-25 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
You are asking us to write your playbook. This group is focused more on addressing a specific playbook error. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jul 25, 2023, at 10:25 AM, DushYant Parmar wrote: How to install window patches on multiple

Re: [ansible-project] issue while runing script

2023-07-24 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Use the 'package' module instead of 'yum'. It will do the right thing on each OS. Also, pass all the packages in a single task. - hosts: all become: true vars: ansible_become_pass: pkgs: - vim - ntp tasks: - name: "install packages {{ pkgs }}" package:

Re: [ansible-project] builtin.expect question

2023-07-24 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Are you certain your install.sh script produces that literal string as the prompt? 'Do you want to change your default shell to zsh? \[Y/n\]:': "Y\n" You can use a regex in the key side of the dictionary. '.*change your default shell to zsh.*': "Y\n" Maybe your string isn't matching so it

Re: [ansible-project] ansible loop with when condition a register variable for more then one match string instance

2023-07-20 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
This is not "python in ansible". This is jinja2 templating which is a fully supported feature of ansible. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jul 20, 2023, at 7:53 AM, Deepak B K wrote: I appreciate the immediate help . But my client

Re: [ansible-project] Ansible - variable to select artifact

2023-07-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
value associated with the key that my_var provides. If my_var is oracle, the debug prints /apps/oracle/some/file/path. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jul 18, 2023, at 9:14 AM, 'Rowe, Walter P. (Fed)' via Ansible Project wrote: If y

Re: [ansible-project] Ansible - variable to select artifact

2023-07-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
then the playbook continues to the next task. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jul 18, 2023, at 8:51 AM, 'Rowe, Walter P. (Fed)' via Ansible Project wrote: Todd's dictionary lookup is elegant and flexible. I'd go with that model. It suppo

Re: [ansible-project] Ansible - variable to select artifact

2023-07-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Todd's dictionary lookup is elegant and flexible. I'd go with that model. It supports any number of choices and gracefully gives a default value. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jul 17, 2023, at 10:29 PM, Todd Lewis wrote: Hello,

Re: [ansible-project] [ansible-project ] getting unsafe ansible text when I trying to parse ansible register variable

2023-07-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Look at your quoting here ... name: set fact specific VM group ansible.builtin.set_fact: vm_groups: “{{ group_info.drs_group_info[vcenter_env.cluster] | selectattr('type', '==', "vm" ) | list }}” That first and last quote are a "smart quotes" (leaning quotes). Your quotes around

Re: [ansible-project] [ansible-project ] getting unsafe ansible text when I trying to parse ansible register variable

2023-07-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Adding to Todd's request for more details .. also look at json_query vs selectattr if you are just filtering a JSON list on attribute value. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jul 14, 2023, at 6:50 AM, Todd Lewis wrote: Please show us

Re: [ansible-project] command/shell module warn deprecation

2023-07-12 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I think you can place an ansible.cfg file in the folder where your ansible is running. We do this for our packer image management service that also uses ansible in the provisioner stage. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jul 12, 2023,

Re: [ansible-project] Configuration Drift

2023-06-28 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Good point. I should add that all our Linux servers also have aide installed and configured for performing file integrity checking. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jun 28, 2023, at 11:45 AM, Brian Coca wrote: Ansible CAN do many

Re: [ansible-project] checking to see if cron entry exists

2023-06-28 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
lineinfile wants to add the line if it is not "present". You can collapse these two tasks into a single task using just linieinfile. Remember that each task is describing an "desired state". In a single task you can look for and add the line if missing. If it is present the task will make no

Re: [ansible-project] Configuration Drift

2023-06-27 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
We have an ansible role that applies the CIS Distro Independent Linux 2 baseline when we launch new machines. We also have an ansible tower workflow for regularly scheduled patching. At the end of the patching workflow we again run the CIS baseline role to ensure we are maintaining compliance

Re: [ansible-project] create VM from template with customiation spec

2023-06-02 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
That pull request is still open. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jun 1, 2023, at 4:27 PM, Kosala Atapattu wrote: You need to create a customization_spec in the vCenter and then refer that using customization_spec.

Re: [ansible-project] Gather Facts failed due resolve hostname inventory_hostname

2023-06-01 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Also, does your nxos_facts task need to "delegate_to: localhost" and use an API to talk to the "inventory_hostname" target? Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jun 1, 2023, at 2:45 PM, Brian Coca wrote: I believe the message is about DNS

Re: [ansible-project] Hello All

2023-05-26 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
The ansible documentation covers this well. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On May 26, 2023, at 9:38 AM, malek sakir <2141.maleksa...@gmail.com> wrote: Anyone have proper documents for Kerberos-based Authentication for ansible then

Re: [ansible-project] can we not use 2 var_files in a playbook

2023-05-19 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Your curl command places the output in /var/output/{{ item }}.json. Your jq command reads the output from {{ item }}.json which is not /var/output/{{ item }}.json. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On May 19, 2023, at 1:21 AM, Narmada

Re: [ansible-project] trying to convert a dummy String with list but skipping the first iteration

2023-05-19 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
% ansible -e 'input="172.11.12.13, 127.0.0.1 , test123.kp.org"' -m debug -a msg="{{ input | split(',') | map('trim') | list }}" localhost -i localhost, localhost | SUCCESS => { "msg": [ "172.11.12.13", "127.0.0.1", "test123.kp.org" ] } Note the use of

Re: [ansible-project] Ansible-Winrm Authentation method

2023-05-17 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
If you are unfamiliar with Windows authentication you may want to speak with a Windows admin at your work. WinRM requires a number of "connection settings" that differ from the easier SSH we use on Linux. You have to determine whether you will use NTLM or Kerberos, what port to use for the

Re: [ansible-project] The lookup pipe is returning a 127 error, even though the file exists and has all the required permissions.

2023-05-15 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
My guess is that pipe is trying to run an executable named exactly this: "/home/BreadPitt/program/executable --version" vs passing the --version option to the executable. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On May 15, 2023, at 9:40 AM, LT

Re: [ansible-project] question on single playbook or roles?

2023-05-12 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Yes, that was me, LOL. Even a single playbook can be "parameterized" to use variables you supply via command line or a vars file. That offers reuse. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On May 12, 2023, at 11:54 AM, Kevin Knox wrote: Hmmm.

Re: [ansible-project] question on single playbook or roles?

2023-05-10 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I agree with Dick. Is this something you will do over and over so taking the time makes sense? Or is this a once-and-done task? Also look at the tools VMware offers. Ansible isn't always the right solution. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123

Re: [ansible-project] why lineinfile not able to run with item.path

2023-05-01 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
You need proper indentation. The module name and "with_items" must align with the task name. The module args would then outdent by two space to also reflect proper indentation. I used a "debug" vs "lineinfile" to display the item.path and item.line vars and it worked just fine once indentation

Re: [ansible-project] VMWARE rest colleciton

2023-04-20 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
https://github.com/ansible-collections/vmware.vmware_rest/blob/main/docs/vmware.vmware_rest.vcenter_vmtemplate_libraryitems_module.rst * Creates a library item in content library from a virtual machine. This {@term operation} creates a library item in content library whose

Re: [ansible-project] ansible.builtin.cron

2023-04-19 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
job: "/home/jwelby/ansible/sub-playbooks/ansible-playbook -i dev-hosts /home/jwelby/ansible/sub-playbooks/patching.yml" 30 15 * * 3 /home/jwelby/ansible/sub-playbooks/patching.yaml These don't match. cron isn't running ansible-playbook. It is trying to run the YAML file itself.

Re: [ansible-project] copy files based on descending precedence

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
My sense is they are searching from most specific to least specific file. The first one they find they use. The remaining params are hardcoded. We do a similar thing when looking for vars files. We might search for RedHat8, then RedHat, then Linux. - name: Add OS specific variables for {{

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
And if you really wanted only unique list items this also works ... - debug: msg="{{ [listb] | sum(start=lista) | unique }}" Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Apr 18, 2023, at 12:44 PM, 'Rowe, Walter P. (Fed)' via Ansib

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
"two": "str2" }, { "four": "str4", "three": "str3" }, { "five": "str5", "six": "str6" } ] } PLAY RECAP **

Re: [ansible-project] copy files based on descending precedence

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I'm not sure what value the with_items adds to this. Its all hardcoded values so why not hard code them into the parameters of the task? ansible.builtin.copy: src: "{{ lookup('ansible.builtin.first_found', findme) }}" dest: "/etc/security/access.conf" owner: "root" group: "root"

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
}, { "five": "str5", "six": "str6" } ] } PLAY RECAP ** localhost : ok=2changed=0unreachable=0failed=0 skipped=0re

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
* localhost : ok=4changed=0unreachable=0failed=0 skipped=0rescued=0 ignored=0 Walter -- Walter Rowe, Division Ch

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
, Apr 18, 2023 at 8:56 AM 'Rowe, Walter P. (Fed)' via Ansible Project wrote: TASK [debug] *** ok: [localhost] => { "listb": [ [ {

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
--- - name: test lists become: false gather_facts: false hosts: localhost vars: lista: - { one: 'str1', two: 'str2' } listb: - { one: 'str1', two: 'str2' } tasks: - debug: var=lista - debug: var=listb - set_fact: listb: [ "{{ lista + listb }}" ]

Re: [ansible-project] JOB | DevOps Automation Evangelist/Presenter (London/Singapore)

2023-04-04 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Does the rules of this group permit job recruiting? Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Apr 4, 2023, at 5:45 AM, James Tobin wrote: Hello, I'm working with an employer that is looking to hire someone to be the voice of their on-prem

Re: [ansible-project] Panik Github RSH SSH host key change breaks installations

2023-03-27 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
SSH is NOT hard to manage. You need a well defined management practice. We have a service account on our machines with populated SSH public key. We tightly control access to the private key. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Mar 25,

Re: [ansible-project] How to get a list of dict with a cat from command module

2023-03-22 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
If the file content is JSON data you need to read it like JSON data. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Mar 22, 2023, at 10:17 AM, Dick Visser wrote: On Wed, 22 Mar 2023 at 15:02, Hiero-nymo mailto:jer.m.me...@gmail.com>> wrote: Hi

Re: [ansible-project] how to handle prompts in aruba_command module

2023-03-21 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Look at expect / pexpect module. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Mar 21, 2023, at 4:29 AM, Akshay Jadhav wrote: Hi, i want to copy os image from tftp server to aruba switch . when i tried manually its asking for prompt Continue(y/n)?

Re: [ansible-project] How to use roles/../tests directory

2023-03-17 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
https://stackoverflow.com/questions/70898834/which-tools-use-the-tests-directory-in-an-ansible-role-by-default Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Mar 17, 2023, at 10:28 AM, Ngoc Quan Pham wrote: Hi everyone, As you know, the standard

Re: [ansible-project] azure_rm_resourcegroup_info usage help

2023-03-15 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Given how they are presented in all caps and it says "environment variables" then you need to make them ENVIRONMENT variables (ie Linux env vars) – not parameters to the task module. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Mar 15, 2023, at

Re: [ansible-project] azure_rm_resourcegroup_info usage help

2023-03-15 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
TypeError: ResourceManagementClient.__init__() missing 1 required positional argument: 'credential'. What kind of authentication have you configured?

Re: [ansible-project] Ansible Powershell Usage

2023-03-15 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
If you are truly managing Windows resources look at win_dsc. https://docs.ansible.com/ansible/latest/os_guide/windows_dsc.html Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Mar 14, 2023, at 3:59 PM, Shawn Singh wrote: Also, I noticed this

Re: [ansible-project] how to parse variable in patterns by find module

2023-03-13 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
: files: "{{ found.results | json_query('[*].files[*][]') }}" - name: show list of files debug: var=item.path loop: "{{ files }}" Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Mar 13, 2023, at 1:11 PM, '

Re: [ansible-project] how to parse variable in patterns by find module

2023-03-13 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
You are not registering the product of the task. find: paths: /tmp recurse: false file_type_ file patterns: '^{{ item.filename }}\.[0-9]{6}.*$' use_regex: yes loop: {{ file }} register: found You then need to look at found.files (a list) to see what is found. This is documented in the

Re: [ansible-project] Ansible variable data to CSV file

2023-03-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
- name: not working debug: var=item loop: "{{ csv_json }}" when: item.status == 'online' and item.work_status == 'not_used' - name: exclude debug: var=item loop: "{{ csv_json }}" when: (item.status == 'offline') and ('Test' in item.vol_name)

Re: [ansible-project] Ansible variable data to CSV file

2023-03-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Do you have a playbook that isn't working or are you asking us to write this playbook? When I have challenges like this I create a sandbox playbook that tackles the individual challenge. When I get it working I copy that back into the larger playbook I am developing. Walter -- Walter Rowe,

Re: [ansible-project] Fetching varialble data into loops iterate/repeat

2023-03-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
e q/query instead of lookup. On Mon, Mar 6, 2023 at 6:10 PM 'Rowe, Walter P. (Fed)' via Ansible Project mailto:ansible-project@googlegroups.com>> wrote: --- - name: test loop with JSON dict list hosts: all become: false gather_facts: false vars: aggregates: - { cluster

Re: [ansible-project] Fetching varialble data into loops iterate/repeat

2023-03-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
****** fatal: [localhost]: FAILED! => {} MSG: Invalid data passed to 'loop', it requires a list, got this instead: . Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup. On Mon, Mar 6, 2023 at 5

Re: [ansible-project] Fetching varialble data into loops iterate/repeat

2023-03-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
ates.records[*].[name]" loop: "{{ ontap.results }}" no_log: true Looking for: As above mentioned set_fact giving data into list into lists, Can we make aggregates data into dict structure as mentioned below from same set_fact ? aggregates: - { cluster: "Cluster 1", aggregat

Re: [ansible-project] Fetching varialble data into loops iterate/repeat

2023-03-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
aggregates data into dict structure as mentioned below from same set_fact ? aggregates: - { cluster: "Cluster 1", aggregate: "aggr1" } - { cluster: "Cluster 1", aggregate: "aggr2" } - { cluster: "Cluster 1", aggregate: "aggr4" } - {

Re: [ansible-project] Fetching varialble data into loops iterate/repeat

2023-03-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
uster 3, hostname aggr2" } PLAY RECAP * localhost : ok=1 changed=0unreachable=0failed=0 skipped=0rescued=0ignored=0 Just another idea ... W

Re: [ansible-project] Fetching varialble data into loops iterate/repeat

2023-03-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Your 'aggregates' is a list of lists. For each aggregate list item, you have a two-element list where element [0] is cluster name and element [1] is aggregate name. Loop through aggregates, and use item.0 for cluster and item.1 for hostname ? - name: Get info na_ontap_rest_info:

  1   2   3   >