[ansible-project] Lineinfile - Skip/Update an item inside "with_items" using conditions

2022-08-04 Thread farrukh ahmed
I have a question. Can an item inside "with_items" or "loop" be skipped? using condition "when some_variable is not defined" ? Here is my play. *- name: "Update text in the file" lineinfile:path: /path-to-the-file/backrefs: yesregexp: "{{ item.regexp }}"line: "{{ ite

Re: [ansible-project] Alma Linux not recognised as RedHat family

2022-08-04 Thread shaneoh1980 McP
Thanks so much - I was able to do this using: when: (ansible_distribution == 'AlmaLinux') And that is working as expected. On Fri, 5 Aug 2022 at 08:28, Paul Manno wrote: > Have you looked at the full ansible_facts for that OS? Maybe there is > another value you can use other than os_family.

Re: [ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread Vladimir Botka
> On Wednesday, August 3, 2022 at 5:02:16 PM UTC-4 wpgpo...@gmail.com wrote: > > *general_var.yml* > > main_dir: "{{ app_name }}-{{ ansible_hostname }}-{{ ver }}" Use *vars* lookup plugin to indirectly reference the value of the variable stored in *app_name*. Then use filter *product* to create th

[ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread wpgpo...@gmail.com
Thank you Walter... Honestly, I have no idea and trying to understand and learning it now. I'll get back once I have tried again. Thank you and appreciated... WP On Thursday, August 4, 2022 at 1:14:51 PM UTC-5 walte...@nist.gov wrote: > > https://docs.ansible.com/ansible/latest/reference_appendi

Re: [ansible-project] Alma Linux not recognised as RedHat family

2022-08-04 Thread Matt Martz
Support to detect AlmaLinux as being in the RedHat family was added in 2.9.19 Take note that 2.9 is now end of life. You should consider upgrading to a supported version. On Thu, Aug 4, 2022 at 3:23 PM shane.do...@gmail.com < shane.dobson1...@gmail.com> wrote: > I've got some playbooks that ins

Re: [ansible-project] Alma Linux not recognised as RedHat family

2022-08-04 Thread Paul Manno
Have you looked at the full ansible_facts for that OS? Maybe there is another value you can use other than os_family. On Thu, Aug 4, 2022 at 3:23 PM shane.do...@gmail.com < shane.dobson1...@gmail.com> wrote: > I've got some playbooks that install updates to some servers based on > operating syst

[ansible-project] Alma Linux not recognised as RedHat family

2022-08-04 Thread shane.do...@gmail.com
I've got some playbooks that install updates to some servers based on operating system family like so: - include_tasks: update-RedHat.yml when: (ansible_os_family == 'RedHat') - include_tasks: update-Debian.yml when: (ansible_os_family == 'Debian') We recently changed a bunch of

[ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread 'Walter Rowe' via Ansible Project
https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html Look for ansible_limit ... On Thursday, August 4, 2022 at 2:11:35 PM UTC-4 Walter Rowe wrote: > Are you thinking there is different "dir_list" for each group? > > --limit awssxb would also need an awssbx vars fil

[ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread 'Walter Rowe' via Ansible Project
Are you thinking there is different "dir_list" for each group? --limit awssxb would also need an awssbx vars file that has one list of values for dir_list --limt awssbx2 would also need an awssbx2 vars file that has a different list of values for dir_list? In your playbook you can reference var

[ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread wpgpo...@gmail.com
Hello, I have tried something like this one... Btw, I've been using group_vars already for my other variables. *dir tree:* - inventory - inv_test_01 (file) - group_vars (dir) - awssbx (file) * inv_test_01 (file) * [awssbx] awssandbox001.us.com [awsdev] awsdev001 awsdev002 * awssbx (f

[ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread 'Walter Rowe' via Ansible Project
You can group your inventory and provide the group name to the execution and it will only run on that group. $ ansible-playbook --inventory *my_inventory_file* --limit *group_name* ... rest of your command ... The "*hosts: all*" in your playbook will be limited to the group from your inventory

[ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread wpgpo...@gmail.com
Thank You, Walter. It does work as expected however, I do have couple of variables inside the dirname.yml and different directories inside of the home path. The idea, I don't want to run the copy module (etc) in one execution but instead putting them in a group or set. Another purpose, I don't wa

[ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread 'Walter Rowe' via Ansible Project
See if this does what you want .. - name: Test Playbook Script for Debug hosts: localhost vars_files: - general_var.yml - dirname.yml - patch_file.yml tasks: - name: Copy | All Mule v392 Patch to LIB-User Directory for "{{Application_Runtime | upper}}" Runtime copy:

[ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread wpgpo...@gmail.com
Yeah, I forgot to mention the result. Basically, there was no error but instead it creates a new directory from the value of 'app_name' rather than the item list of the dir_list. *Result:* /home/*dir_list*-awssandbox001.us.com-123/lib/user *Expected:* - /home/*hello*-awssandbox001.us.com-123/l

Re: [ansible-project] Use variable with item in when condition in ansible task

2022-08-04 Thread 'Walter Rowe' via Ansible Project
Your output tells you everything you need to know. skipping: [localhost] => (item={*'name': 'Datacenter-Test'*, 'moid': 'datacenter-1247', 'config_status': 'gray', 'overall_status': 'gray'}) skipping: [localhost] => (item={*'name': 'opendc-rookie'*, 'moid': 'datacenter-2', 'config_status': 'gray

[ansible-project] Re: Pull of List in a Variable File as Extra-Vars

2022-08-04 Thread 'Walter Rowe' via Ansible Project
Are you getting an error? Can we see it? -- Walter Rowe, Chief Infrastructure Services Office of Information Systems Management National Institute of Standards and Technology United States Department of Commerce On Wednesday, August 3, 2022 at 5:02:16 PM UTC-4 wpgpo...@gmail.com wrote: > Hello Te

Re: [ansible-project] Use variable with item in when condition in ansible task

2022-08-04 Thread Dick Visser
what are you trying to do exactly? i.e. what do you expect the debug task to show? without knowing the structure of the datacenter variable, it's not really possible to help On Thu, 4 Aug 2022 at 08:41, 'Pugazhendhi Ramakrishnan' via Ansible Project wrote: > I'm using the below playbook to capt