Re: [ansible-project] ansible_facts['device_links']['ids'] empty for RHEL9 on AWS

2024-07-17 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Bravo! It is empty on the RHEL9 system and populated on the RHEL8 system.

Now I need to determine why.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jul 17, 2024, at 2:27 PM, Abhijeet Kasurde  wrote:

What is the content of /dev/disk/by-id on AWS EC2 instance?


-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/A719A892-3A43-4A37-803E-C6965D55FB47%40nist.gov.


[ansible-project] ansible_facts['device_links']['ids'] empty for RHEL9 on AWS

2024-07-17 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I am querying ansible facts of AWS EC2s to get volume IDs without having to use 
the AWS API. Prior to Red Hat 9 I could use ansible_device_links['ids'][device 
name] to get the associated volume ID.

REDHAT 8

"ansible_facts": {
"ansible_device_links": {
"ids": {
"nvme0n1": [
"nvme-Amazon_Elastic_Block_Store_vol0205cf99926f7c3e8",

"nvme-nvme.1d0f-766f6c3032303563663939393236663763336538-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001"
],

Starting with Red Hat 9 we seem to have lost this info.

REDHAT 9

"ansible_facts": {
"ansible_device_links": {
"ids": {},

Is this something unique to my environment or is this something that changed 
with RHEL facts?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

REDHAT 8

{
"ansible_facts": {
"ansible_device_links": {
"ids": {
"nvme0n1": [
"nvme-Amazon_Elastic_Block_Store_vol0205cf99926f7c3e8",

"nvme-nvme.1d0f-766f6c3032303563663939393236663763336538-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001"
],
"nvme0n1p1": [

"nvme-Amazon_Elastic_Block_Store_vol0205cf99926f7c3e8-part1",

"nvme-nvme.1d0f-766f6c3032303563663939393236663763336538-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001-part1",

"wwn-nvme.1d0f-766f6c3032303563663939393236663763336538-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001-part1"
],
"nvme0n1p2": [

"nvme-Amazon_Elastic_Block_Store_vol0205cf99926f7c3e8-part2",

"nvme-nvme.1d0f-766f6c3032303563663939393236663763336538-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001-part2",

"wwn-nvme.1d0f-766f6c3032303563663939393236663763336538-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001-part2"
],
"nvme1n1": [
"nvme-Amazon_Elastic_Block_Store_vol0abf628274ab398f2",

"nvme-nvme.1d0f-766f6c3061626636323832373461623339386632-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001"
],
"nvme2n1": [
"nvme-Amazon_Elastic_Block_Store_vol0690b9672f6e52240",

"nvme-nvme.1d0f-766f6c3036393062393637326636653532323430-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001"
],
"nvme3n1": [
"nvme-Amazon_Elastic_Block_Store_vol08404f1191eb63440",

"nvme-nvme.1d0f-766f6c3038343034663131393165623633343430-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001"
],
"nvme4n1": [
"nvme-Amazon_Elastic_Block_Store_vol081f2b191f4e7d7cc",

"nvme-nvme.1d0f-766f6c3038316632623139316634653764376363-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001"
],
"nvme5n1": [
"nvme-Amazon_Elastic_Block_Store_vol0b51ac580c17c745e",

"nvme-nvme.1d0f-766f6c3062353161633538306331376337343565-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001"
],
"nvme6n1": [
"nvme-Amazon_Elastic_Block_Store_vol07427283fef5d12ad",

"nvme-nvme.1d0f-766f6c3037343237323833666566356431326164-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001"
],
"nvme7n1": [
"nvme-Amazon_Elastic_Block_Store_vol07c3177d94a329f70",

"nvme-nvme.1d0f-766f6c303761373764393461333239663730-416d617a6f6e20456c617374696320426c6f636b2053746f7265-0001"
]
},
"labels": {
"nvme1n1": [
"tmp"
],
"nvme2n1": [
"swap"
],
"nvme3n1": [
"apps"
],
"nvme4n1": [
"external"
],
"nvme5n1": [
"archive"
],
"nvme6n1": [
"orafra"
],
"nvme7n1": [
"oradata"
]
},
"masters": {},
"uuids": {
"nvme0n1p2": [
"c9aa25ee-e65c-4818-9b2f-fa411d89f585"
],
"nvme1n1": [
"e5d6f42e-45ca-4b3b-8492-46314d453a31"
],
"nvme2n1": [
"5fd97b83-1ed6-4237-92cc-c95462493da6"
],
"nvme3n1": [

Re: [ansible-project] Create inventory in a Workflow and then use in subsequent playbooks

2024-07-10 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Do you need these plays to be in separate playbook? You can put multiple plays 
in a single playbook. Play one can create an inventory group. Play two can run 
agains that group. We use this for some of our tasks where we create new 
machines, create a new inventory group, then run a play on that new group.


##
## play 1: add new machines to an inventory group
##
- name: Add new host to playbook inventory
hosts: localhost
gather_facts: no

tasks:

# add our new host to the inventory for this play
- name: add {{ item | lower }} to group
add_host:
name: "{{ item | lower }}"
group: newvm
loop: "{{ new_vm_names }}"

##
## play 2: customize new machines
##
- name: "Customize Server - Linux - Set Time Zone, Hostname, Join AD"
gather_facts: no
hosts: newvm

Notice that "hosts" in play #2 refers to the "newvm" group created in play #1.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jul 10, 2024, at 12:19 PM, HBach  wrote:

Thanks, Walter.

We're not using static addresses but dynamic.  If we were, it would be easier.  
I figured out the Ansible fact to grab the IP but this only grabs it for a 
single host.

ansible_facts["azure_vm"]["network_profile"]["network_interfaces"][0]["properties"]["ip_configurations"][0]["private_ip_address"]

I wrote a simple task to loop through the host list provided in the Ansible 
survey to dump the ips to stdout.

  - name: Gather specific Ansible facts
  debug:
msg: "{{ hostvars[item]['ansible_default_ipv4']['address'] }}"
  loop: "{{ linux_hosts }}"

but it looks like it can't find the host(s).
  "msg": "The task includes an option with an undefined variable. The error 
was: \"hostvars['rheltest0709a']\" is undefined.

Thanks!

On Tuesday, July 9, 2024 at 10:00:09 AM UTC-6 Rowe, Walter P. (Fed) wrote:
You need names and corresponding IP addresses for an inventory.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jul 9, 2024, at 11:52 AM, HBach  wrote:

Hi, community,

I am creating a deployment workflow using the Ansible Automation Platform (AAP) 
and, right now, the workflow is composed of two job templates.  The first job 
template creates the actual vms and the the second job template is used for 
some post-build configuration tasks.  I want to use the inventory generated in 
the first job template for the second job template.

Right now, I am having AAP reach back to itself via the AAP API and create an 
inventory.  I have also used the set_stats module to create an artifact that 
the second job template can see.

- name: Set stats to pass inventory
  ansible.builtin.set_stats:
data:
  target_hosts: "{{ linux_hosts }}"

- name: Get an AAP API Token and store it as new_token
  register: new_token
  ansible.builtin.uri:
  url: "https:///api/v2/tokens/"
  method: POST
  user: admin
  password: "{{ survey_controller_passwd }}"
  validate_certs: false
  force_basic_auth: true
  status_code: 201
  return_content: true

- name: Azure inventory update
  ansible.controller.host:
controller_host: "https:///"
controller_password: "{{ survey_controller_passwd }}"
controller_username: 'admin'
controller_oauthtoken: "{{ new_token.json.token }}"
name: "{{ linux_hosts }}"
inventory: "Azure-test"
state: present
enabled: true

The artifact is created and the new inventory on AAP is updated when job 
template 1 completes.

{
  "target_hosts": [
"rheltest0701c"
  ]
}

But, the second job template fails as it cannot find the host(s).
[WARNING]: Could not match supplied host pattern, ignoring: target_hosts

Any idea, folks?


--
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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/aa0fcd58-3f55-4c9a-8ea6-2d0e28fa3495n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/aa0fcd58-3f55-4c9a-8ea6-2d0e28fa3495n%40googlegroups.com?utm_medium=email_source=footer>.


--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fd7b18b7-e4f0-43af-9d79-e3f02ca3b089n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/fd7b18b7-e4f0

Re: [ansible-project] Create inventory in a Workflow and then use in subsequent playbooks

2024-07-09 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
You need names and corresponding IP addresses for an inventory.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jul 9, 2024, at 11:52 AM, HBach  wrote:

Hi, community,

I am creating a deployment workflow using the Ansible Automation Platform (AAP) 
and, right now, the workflow is composed of two job templates.  The first job 
template creates the actual vms and the the second job template is used for 
some post-build configuration tasks.  I want to use the inventory generated in 
the first job template for the second job template.

Right now, I am having AAP reach back to itself via the AAP API and create an 
inventory.  I have also used the set_stats module to create an artifact that 
the second job template can see.

- name: Set stats to pass inventory
  ansible.builtin.set_stats:
data:
  target_hosts: "{{ linux_hosts }}"

- name: Get an AAP API Token and store it as new_token
  register: new_token
  ansible.builtin.uri:
  url: "https:///api/v2/tokens/"
  method: POST
  user: admin
  password: "{{ survey_controller_passwd }}"
  validate_certs: false
  force_basic_auth: true
  status_code: 201
  return_content: true

- name: Azure inventory update
  ansible.controller.host:
controller_host: "https:///"
controller_password: "{{ survey_controller_passwd }}"
controller_username: 'admin'
controller_oauthtoken: "{{ new_token.json.token }}"
name: "{{ linux_hosts }}"
inventory: "Azure-test"
state: present
enabled: true

The artifact is created and the new inventory on AAP is updated when job 
template 1 completes.

{
  "target_hosts": [
"rheltest0701c"
  ]
}

But, the second job template fails as it cannot find the host(s).
[WARNING]: Could not match supplied host pattern, ignoring: target_hosts

Any idea, folks?


--
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 visit 
https://groups.google.com/d/msgid/ansible-project/aa0fcd58-3f55-4c9a-8ea6-2d0e28fa3495n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/06F426EE-5A5D-420C-81ED-F26E2C8CB606%40nist.gov.


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:

loop: '{{ known.stdout_lines }}'

The second instance is the desired behavior. The difference is subtle at first 
glance but makes a world of difference in execution.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On May 23, 2024, at 11:30 AM, Todd Lewis  wrote:

Gah! Of course. known.stdout_lines is a list, so

loop:
  - '{{ known.stdout_lines }}'


passes the whole list as a single item. So you need to not put the list in a 
list:

loop: '{{ known.stdout_lines }}'


should do the trick.
—
Todd

On 5/23/24 11:17 AM, Dimitri Yioulos wrote:
Todd, I made the change, but, the last play failed:

TASK [Append to all known_host files] 
*
Thursday 23 May 2024  11:06:33 -0400 (0:00:01.629)   0:00:06.012 **
Thursday 23 May 2024  11:06:33 -0400 (0:00:01.629)   0:00:06.011 **
failed: [myhost] (item=['/root/.ssh/known_hosts', 
'/home/user1/.ssh/known_hosts', '/home/user2/.ssh/known_hosts', 
'/home/user3/.ssh/known_hosts', '/home/user4/.ssh/known_hosts']) => changed=true
  ansible_loop_var: item
  cmd: cat /tmp/append >> ['/root/.ssh/known_hosts', 
'/home/user1/.ssh/known_hosts', '/home/user2/.ssh/known_hosts', 
'/home/user3/.ssh/known_hosts', '/home/user4/.ssh/known_hosts']
  delta: '0:00:00.012330'
  end: '2024-05-23 11:06:33.947617'
  item:
  - /root/.ssh/known_hosts
  - /home/user1/.ssh/known_hosts
  - /home/user2/.ssh/known_hosts
  - /home/user3/.ssh/known_hosts
  - /home/user4/.ssh/known_hosts
  msg: non-zero return code
  rc: 1
  start: '2024-05-23 11:06:33.935287'
  stderr: '/bin/sh: line 1: [/root/.ssh/known_hosts,: No such file or directory'
  stderr_lines: 
  stdout: ''
  stdout_lines: 

I wonder if [ in  [/root/.ssh/known_hosts is getting in the way, since  
/root/.ssh/known_host does exist.

On Thursday, May 23, 2024 at 10:50:28 AM UTC-4 Todd Lewis wrote:
You want stdout_lines rather than stdout. The former is a list with new-lines 
removed. The latter is a possibly very long string with the complete output 
stream intact.

- name: Append to all known_host files
  shell: cat /tmp/append >> {{ item }}
  loop:
- '{{ known.stdout_lines }}'


On 5/23/24 9:07 AM, Dimitri Yioulos wrote:
Good day, all. I hope I'm not wearing out my welcome with too many questions.

In the following playbook, I first find any know_host file for any user on a 
particular system. I then copy a file with the list of additions to add to the 
known_hosts files. What I want to do is use the output of my register values to 
make changes to those know_host files, which my last play does. My iteration is 
wrong, though.

The playbook:

---

- hosts: all
  gather_facts: false
  become: yes

  vars:
script_path: 

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 }}'


- name: construct 2

  debug: var=item

  loop: '{{ my_list }}'





% ansible-playbook -i localhost, loop.yml


PLAY [test loop constructs] 



TASK [construct 1] 
*

ok: [localhost] => (item=['one', 'two', 'three']) => {

"ansible_loop_var": "item",

"item": [

"one",

"two",

"three"

]

}


TASK [construct 2] 
*

ok: [localhost] => (item=one) => {

"ansible_loop_var": "item",

"item": "one"

}

ok: [localhost] => (item=two) => {

"ansible_loop_var": "item",

"item": "two"

}

ok: [localhost] => (item=three) => {

"ansible_loop_var": "item",

"item": "three"

}


PLAY RECAP 
*

localhost  : ok=2changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0



Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On May 24, 2024, at 7:41 AM, Rowe, Walter P. (Fed)  wrote:

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:

loop: '{{ known.stdout_lines }}'

The second instance is the desired behavior. The difference is subtle at first 
glance but makes a world of difference in execution.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On May 23, 2024, at 11:30 AM, Todd Lewis  wrote:

Gah! Of course. known.stdout_lines is a list, so

loop:
  - '{{ known.stdout_lines }}'


passes the whole list as a single item. So you need to not put the list in a 
list:

loop: '{{ known.stdout_lines }}'


should do the trick.
—
Todd

On 5/23/24 11:17 AM, Dimitri Yioulos wrote:
Todd, I made the change, but, the last play failed:

TASK [Append to all known_host files] 
*
Thursday 23 May 2024  11:06:33 -0400 (0:00:01.629)   0:00:06.012 **
Thursday 23 May 2024  11:06:33 -0400 (0:00:01.629)   0:00:06.011 **
failed: [myhost] (item=['/root/.ssh/known_hosts', 
'/home/user1/.ssh/known_hosts', '/home/user2/.ssh/known_hosts', 
'/home/user3/.ssh/known_hosts', '/home/user4/.ssh/known_hosts']) => changed=true
  ansible_loop_var: item
  cmd: cat /tmp/append >> ['/root/.ssh/known_hosts', 
'/home/user1/.ssh/known_hosts', '/home/user2/.ssh/known_hosts', 
'/home/user3/.ssh/known_hosts', '/home/user4/.ssh/known_hosts']
  delta: '0:00:00.012330'
  end: '2024-05-23 11:06:33.947617'
  item:
  - /root/.ssh/known_hosts
  - /home/user1/.ssh/known_hosts
  - /home/user2/.ssh/known_hosts
  - /home/user3/.ssh/known_hosts
  - /home/user4/.ssh/known_hosts
  msg: non-zero return code
  rc: 1
  start: '2024-05-23 11:06:33.935287'
  stderr: '/bin/sh: line 1: [/root/.ssh/known_hosts,: No such file or directory'
  stderr_lines: 
  stdout: ''
  stdout_lines: 

I wonder if [ in  [/root/.ssh/known_hosts is getting in the way, since  
/root/.ssh/known_host does exist.

On Thursday, May 23, 2024 at 10:50:28 AM UTC-4 Todd Lewis wrote:
You want stdout_lines rather than stdout. The former is a list with new-lines 
removed. The latter is a possibly very long string with the complete output 
stream intact.

- name: Append to all known_host files
  shell: cat /tmp/append >> {{ item }}
  loop:
- '{{ known.stdout_lines }}'


On 5/23/24 9:07 AM, Dimitri Yioulos wrote:
Good day, all. I hope I'm not wearing out my welcome with too many questions.

In the following playbook, I first find any know_host file for any user on a 
particular system. I then copy a file with the list of additions to add to the 
known_hosts files. What I want to do is use the output of my register values to 
make changes to those know_host files, which my last play does. My iteration is 
wrong, though.

The playbook:

---

- hosts: all
  gather_facts: false
  become: yes

  vars:
script_path: 

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 }

{{ vcenter[inventory_hostname].datacenter }}
{{ vcenter[inventory_hostname].vcenter }}

Keeping that dictionary update to date will be tedious but could be automated 
too. Query each vcenter / datacenter pair for its list of VMs and generate a 
vars file with the above dictionary. Include that vars file in your playbooks. 
Alternatively (and more expensive) is to create an initial task that queries 
the each vcenter / datacenter pair and creates this dictionary in real time.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On May 8, 2024, at 12:34 PM, Dimitri Yioulos  wrote:

Hello, all.

The subject of this post is probably terribly named. That said, here's what I'm 
trying to accomplish:

I have two VMware vCenter hosts - vcenter1.mycompany.com and 
vcenter2.mycompany.com. Within each host is are two datacenters - datacenter1 
and datacenter2. for each host, the datacenter alignments are vcenter1 -- 
datacenter1 and vcenter2 -- datacenter2.

I have a number of playbooks that do actions against vCenter. For example, I 
have one deletes all snapshots. It looks like this:

---

- hosts: all
  become: false
  gather_facts: false

  vars_prompt:

- name: "vcenter_username"
  prompt: "Enter your Vcenter username (without @vsphere.local)"
  private: no
- name: "vcenter_password"
  prompt: "Enter your VMware password"
  private: yes
- name: "vcenter_hostname"
  prompt: "Enter your Vcenter host name:\nvcenter1\nvcenter2\n"
  private: no
- name: "vcenter_datacenter"
  prompt: "Enter your Vcenter datacenter:\ndatacenter1\ndatacenter2\n"
  private: no

  tasks:

- name: Find vm folder name
  ~

- name: Remove all snapshots of all VMs
  community.vmware.vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}.fmycompany.com"
username: "{{ vcenter_username }}@vsphere.local"
password: "{{ vcenter_password }}"
datacenter: "{{ vcenter_datacenter }} Datacenter"
folder: "{{ vm_folder.folders | regex_replace(\"([\\[\\]'])\",'') }}"
name: "{{ inventory_hostname }}"
state: remove_all
validate_certs: False
  delegate_to: localhost

As you can see, at present, I have to provide the vCenter name, and the 
corresponding datacenter name in order for the playbook to work. I would like 
to eliminate the need to specify the datacenter name, and have that populate 
datacenter ("{{ vcenter_datacenter }} Datacenter") based on the vCenter host 
that I choose (hostname: "{{ vcenter_hostname }}.fmycompany.com"). I'm not 
clever enough to suss that out, and would appreciate your help.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/424d790e-e657-405b-b720-8ce0448df4f4n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/E3B4BB6D-1A35-4EA0-9D87-B16EEDF3A036%40nist.gov.


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, Azadeh Amirhosseini  
wrote:

Hi All,
which ansible pluging do you suggest to be installed in Pycharm? I want to use 
Pycharm as IDE for developing my playbooks?

Is there any facility that you can write your playbook and test it in the same 
environment to check the output of the playbook , before migrating it in the 
ansible controle node?

Thanks for your replies.

Regards,
Azadeh Amir

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/acacf78d-6db7-48e8-aaa7-180be80b625cn%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/DCA91F1D-54FC-453E-97B8-15BD994740D7%40nist.gov.


Re: [ansible-project] interpolation of loop variables

2024-03-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
In the first loop assert is evaluating that 'item' itself is defined.

In the second loop assert is evaluating whether a variable who's name is stored 
in 'item' is defined.


% cat foo.yml

---

- hosts: localhost

  gather_facts: no

  become: no

  tasks:

  - name: without templating

assert:

  that: "{{ item }} is defined"

loop:

  - varA

  - varB


% ansible-playbook -i localhost, foo.yml -e varB=string


PLAY [localhost] 
***


TASK [without templating] 
**

failed: [localhost] (item=varA) => {

"ansible_loop_var": "item",

"assertion": "varA is defined",

"changed": false,

"evaluated_to": false,

"item": "varA",

"msg": "Assertion failed"

}

ok: [localhost] => (item=varB) => {

"ansible_loop_var": "item",

"changed": false,

"item": "varB",

"msg": "All assertions passed"

}


PLAY RECAP 
*

localhost  : ok=0changed=0unreachable=0failed=1
skipped=0rescued=0ignored=0


NOTE that on the command line I explicitly define varB but not varA.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Mar 14, 2024, at 10:11 AM, Rob Wagner  wrote:

Hey Todd - apologies, I don't understand your comment.

Hey Walter - yes, you are correct.

To elaborate on the use case.  FIrst task in my playbooks confirms the user 
provided all the expected/required variables.  I iterate over the list of 
variables and make sure they are defined with assert.  The list of required 
variables is provided as a list to "loop." Trouble I'm seeing is the items in 
the loop (i.e., the variable names) are not being interpolated by assert unless 
they are templated.

But if we ignore the loop for a second, and just pass a variable to assert, it 
does get interpolated without templating:

#> cat c.yml
---
- hosts: localhost
  gather_facts: no
  tasks:
  - name: a defined variable
assert:
  that: ansible_forks is defined
  - name: an undefined variable
assert:
  that: varA is defined
#> ansible-playbook c.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that 
the
implicit localhost does not match 'all'

PLAY [localhost] 
**

TASK [a defined variable] 
*
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [an undefined variable] 
**
fatal: [localhost]: FAILED! => {
"assertion": "varA is defined",
"changed": false,
"evaluated_to": false,
"msg": "Assertion failed"
}

So, it seems that assert interpolates (non-templated) variables unless that 
variable is "item"

Rob

On Thu, Mar 14, 2024 at 7:48 AM 'Rowe, Walter P. (Fed)' via Ansible Project 
mailto:ansible-project@googlegroups.com>> 
wrote:
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 = 
/opt/homebrew/lib/python3.11/site-packages/ansible
  ansible collection location = 
/Users/wrowe/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.11.8 (main, Feb  6 2024, 21:21:21) [Clang 15.0.0 
(clang-1500.1.0.2.5)] (/opt/homebrew/opt/python@3.11/bin/python3.11)
  jinja version = 3.1.3
  libyaml = True


% ansible-playbook foo.yaml -i localhost,

PLAY [localhost] 
***

TASK [without templating] 
**
ok: [localhost] => (item=varA) => {
"ansible_loop_var": "item",
"changed": false,
"item": "varA",
"msg": "All assertions passed"
}
ok: [localhost] => (item=varB) => {
"ansible_loop_var": "item",
"changed": false,
"item": "varB",
"msg": "All a

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 = 
/opt/homebrew/lib/python3.11/site-packages/ansible

  ansible collection location = 
/Users/wrowe/.ansible/collections:/usr/share/ansible/collections

  executable location = /opt/homebrew/bin/ansible

  python version = 3.11.8 (main, Feb  6 2024, 21:21:21) [Clang 15.0.0 
(clang-1500.1.0.2.5)] (/opt/homebrew/opt/python@3.11/bin/python3.11)

  jinja version = 3.1.3

  libyaml = True



% ansible-playbook foo.yaml -i localhost,


PLAY [localhost] 
***


TASK [without templating] 
**

ok: [localhost] => (item=varA) => {

"ansible_loop_var": "item",

"changed": false,

"item": "varA",

"msg": "All assertions passed"

}

ok: [localhost] => (item=varB) => {

"ansible_loop_var": "item",

"changed": false,

"item": "varB",

"msg": "All assertions passed"

}


TASK [with templating] 
*

failed: [localhost] (item=varA) => {

"ansible_loop_var": "item",

"assertion": "varA is defined",

"changed": false,

"evaluated_to": false,

"item": "varA",

"msg": "Assertion failed"

}

failed: [localhost] (item=varB) => {

"ansible_loop_var": "item",

"assertion": "varB is defined",

"changed": false,

"evaluated_to": false,

"item": "varB",

"msg": "Assertion failed"

}


PLAY RECAP 
*

localhost  : ok=1changed=0unreachable=0failed=1
skipped=0rescued=0ignored=0

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Mar 13, 2024, at 4:55 PM, Todd Lewis  wrote:

Maybe it will facilitate understanding what's going on if we name things what 
they really are:

---
- hosts: localhost
  gather_facts: no
  tasks:
  - name: Strings in a loop are indeed defined
ignore_errors: true
assert:
  that: item is defined
loop:
  - RandomStringA
  - RandomStringB
  - ansible_forks

  - name: Strings in a loop are unlikely to be variable names
ignore_errors: true
assert:
  that: '{{ item }} is defined'
loop:
  - UndefinedVariableNameA
  - UndefinedVariableNameB
  - ansible_forks




On 3/13/24 2:27 PM, rjwagn...@gmail.com wrote:
Hi all - I recently upgraded to Ansible core 2.15, and started hitting 
"Conditional is marked as unsafe, and cannot be evaluated."  As discussed at 
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_9.html, I 
removed templating from when and assert.  All seemed fine, but then I 
discovered loop variables don't appear to be interpolated in assert without 
templating.

As an example, consider the following playbook that aims to confirm two 
variables, varA and varB, are defined (in the sample output, they are not 
defined):
#> cat b.yml
---
- hosts: localhost
  gather_facts: no
  tasks:
  - name: without templating
assert:
  that: item is defined
loop:
  - varA
  - varB
  - name: with templating
assert:
  that: '{{ item }} is defined'
loop:
  - varA
  - varB

#> ansible-playbook b.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that 
the
implicit localhost does not match 'all'

PLAY [localhost] 
**

TASK [without templating] 
*
ok: [localhost] => (item=varA) => {
"ansible_loop_var": "item",
"changed": false,
"item": "varA",
"msg": "All assertions passed"
}
ok: [localhost] => (item=varB) => {
"ansible_loop_var": "item",
"changed": false,
"item": "varB",
"msg": "All assertions passed"
}

TASK [with templating] 

failed: [localhost] (item=varA) => {
"ansible_loop_var": "item",
"assertion": "varA is defined",
"changed": false,
"evaluated_to": false,
"item": "varA",
"msg": "Assertion failed"
}
failed: [localhost] (item=varB) => {
"ansible_loop_var": "item",
"assertion": "varB is defined",
"changed": false,
"evaluated_to": false,
"item": "varB",
"msg": "Assertion failed"
}

Why is templating required to interpolate the loop variable but not other (non 
loop) variables?  Furthermore, is there a way to write 

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 host, etc.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Mar 7, 2024, at 2:50 PM, Thirumalai Raja A  wrote:

hi team,

i am facing below issue intermittently even i specify IP address in the 
inventory list and mentioned in LImit section of my AWX template
i can't understand why its giving error with DNS name even i mention ip address 
and i am sure network is there from AWX to Target host

Can someone pls help me with this.



--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CALyK%3Dg-JqQbo%3DztVgCE9i9Psy%3DL0m8ma9Oo_B9GK6a302EFnDg%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/A4D49B01-25F3-4408-908E-2C2045FEC835%40nist.gov.


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 command.


% cat serverlist.txt

serverAflavorlocationXowner

serverBflavorlocationYowner

serverCflavorlocationZowner


% awk '$1 ~ /serverB/ { print $3; }' serverlist.txt

locationY


Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/AF495547-15F6-4E50-ACD2-D2B1F1A75945%40nist.gov.


[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 | SUCCESS => {

"this": "None"

}


Just making sure that jinja2_native=True should convert a string value of 
"None" to value null when evaluated.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/2BA2FDC8-1CA3-4C93-B702-FA5F0B77248B%40nist.gov.


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 Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Feb 23, 2024, at 12:09 PM, lift...@gmail.com  wrote:

Just pull out those fields from the returned user information.  I use that in 2 
or 3 other playbooks so I know that it works.

Thanks,
Harry

On Friday, February 23, 2024 at 11:53:04 AM UTC-5 Rowe, Walter P. (Fed) wrote:
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
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Feb 23, 2024, at 11:30 AM, lift...@gmail.com  wrote:

I am trying to determine when user's password's are going to expire in the next 
10 days.  After I traverse my FreeIPA users and store those users into a 
variable, I try to set a fact like so:
  - name: Find users who's password will expire in the next 10 days
set_fact:
  pwd_expire_soon: "{{ user_show.results | 
json_query('[*].json.result.result.{uid: uid[0], pwdchg: 
krblastpwdchange[0].__datetime__}') | selectattr('pwdchg', 'lessthan', 
'expire_date') | list }}"

When I run my playbook, I get the following error:

fatal: [localhost]: FAILED! => {"msg": "Unexpected templating type error 
occurred on ({{ user_show.results | json_query('[*].json.result.result.{uid: 
uid[0], pwdchg: krblastpwdchange[0].__datetime__}') | selectattr('pwdchg', 
'lessthan', 'expire_date') | list }}): '<' not supported between instances of 
'NoneType' and 'str'. '<' not supported between instances of 'NoneType' and 
'str'"}

I can't seem to find what the issue is.  I originally  had '<' instead of 
'lessthan' but got the same error.  Any ideas?

Thanks,
Harry

--
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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a1131cb0-bc23-46bb-afbf-ca9ad6f4ce34n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/a1131cb0-bc23-46bb-afbf-ca9ad6f4ce34n%40googlegroups.com?utm_medium=email_source=footer>.


--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c0b4de3d-50e2-4fff-85b1-0437076137dcn%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/c0b4de3d-50e2-4fff-85b1-0437076137dcn%40googlegroups.com?utm_medium=email_source=footer>.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/EE113257-3848-41E9-90D0-42D447F8C84C%40nist.gov.


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
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Feb 23, 2024, at 11:30 AM, lift...@gmail.com  wrote:

I am trying to determine when user's password's are going to expire in the next 
10 days.  After I traverse my FreeIPA users and store those users into a 
variable, I try to set a fact like so:
  - name: Find users who's password will expire in the next 10 days
set_fact:
  pwd_expire_soon: "{{ user_show.results | 
json_query('[*].json.result.result.{uid: uid[0], pwdchg: 
krblastpwdchange[0].__datetime__}') | selectattr('pwdchg', 'lessthan', 
'expire_date') | list }}"

When I run my playbook, I get the following error:

fatal: [localhost]: FAILED! => {"msg": "Unexpected templating type error 
occurred on ({{ user_show.results | json_query('[*].json.result.result.{uid: 
uid[0], pwdchg: krblastpwdchange[0].__datetime__}') | selectattr('pwdchg', 
'lessthan', 'expire_date') | list }}): '<' not supported between instances of 
'NoneType' and 'str'. '<' not supported between instances of 'NoneType' and 
'str'"}

I can't seem to find what the issue is.  I originally  had '<' instead of 
'lessthan' but got the same error.  Any ideas?

Thanks,
Harry

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/a1131cb0-bc23-46bb-afbf-ca9ad6f4ce34n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/46E40AD9-7412-4C76-99AE-76C22418BF24%40nist.gov.


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:

- set_fact:

pemno: "{{ pemno }}"


- hosts: all

  gather_facts: false

  become: false


  tasks:

- debug: var=pemno


Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Feb 21, 2024, at 8:03 AM, Dimitri Yioulos  wrote:

Dick, I'm not getting that to work. For now, I'm prompting again for the pemno 
withing the second set of tasks. That works, but isn't ideal. I'd like to see 
if I can "re-use" the pemno gathered from the first tasks prompt in the second 
set of tasks:

- hosts: localhost
  connection: local
  gather_facts: false

  vars_prompt:
   - name: "pemno"
 prompt: "Enter the number of the created pems"
 private: no

   tasks:
   

- hosts: myhost
  become: yes

  tasks:
   <- use pemno here from above
On Tuesday, February 20, 2024 at 9:15:29 AM UTC-5 Dick Visser wrote:
I *think* the vars from vars_prompt are tied to localhost in the first play, so 
if you need them in any next plays, you would need to reference them as 
localhost's hostvars:

{{ hostvars['localhost'].pemno }}

(not tested)

On Tue, 20 Feb 2024 at 14:10, Dimitri Yioulos  wrote:
Good  morning.

In the following playbook, i have prompts to capture certain information. The 
created variables work fine in the first set of tasks in the playbook. However, 
they don't carry over into the second set of tasks in the playbook, based on 
what I've tried (as seen in the playbook, which is probably not the most 
efficient). Is there a way to do this?

---

- hosts: localhost
  connection: local
  gather_facts: false

  vars_prompt:

- name: "domainfile"
  prompt: "Enter domain short name"
  private: no

- name: "pemno"
  prompt: "Enter the number of the created pems"
  private: no

#- name: ""
#prompt: ""
#private: no

  tasks:

- name: Create directory
  ansible.builtin.file:
path: '/home/deploy/{{ domainfile }}'
state: directory
owner: deploy
owner: deploy
group: deploy
mode: '0755'
  tags:
- create_dir

- name: Copy pem files to directory
  ansible.builtin.copy:
src: "{{ item.src }}"
dest: '/home/deploy/{{ domainfile }}'
owner: deploy
group: deploy
mode: '0644'
remote_src: yes
  with_items:
- { src: 
'/etc/letsencrypt/archive/myhost.com/privkey{{<http://myhost.com/privkey%7B%7B> 
pemno }}.pem' }
- { src: 
'/etc/letsencrypt/archive/myhost.com/cert{{<http://myhost.com/cert%7B%7B> pemno 
}}.pem' }
- { src: 
'/etc/letsencrypt/archive/myhost.com/chain{{<http://myhost.com/chain%7B%7B> 
pemno }}.pem' }
- { src: 
'/etc/letsencrypt/archive/myhost.com/fullchain{{<http://myhost.com/fullchain%7B%7B>
 pemno }}.pem' }
  become: yes
  become_user: root
  become_method: sudo
  tags:
- copy_pems

- name: Change privkey permission
  ansible.builtin.file:
path: '/home/deploy/{{ domainfile }}/privkey{{ pemno }}.pem'
mode: '0600'
  tags:
- chg_privkey_perm

- name: Save our variables to localhost facts for next tasks
  run_once: yes
  delegate_to: localhost
  delegate_facts: yes
  set_fact:
domainfile: "{{ domainfile }}"
pemno: "{{ pemno }}"

- hosts: another_host
  become: yes
  become_user: root
  become_method: sudo

  vars:
a_domainfile: "{{ domainfile }}"
pemno: "{{ pemno }}"

  tasks:

- name: Copy pem files to hosts
  ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: preserve
remote_src: yes
  with_items:
- { src: 
'/etc/letsencrypt/archive/myhost.com/privkey{{<http://myhost.com/privkey%7B%7B> 
pemno }}.pem' ,dest: '/home/deploy/' }
- { src: 
'/etc/letsencrypt/archive/myhost.com/cert{{<http://myhost.com/cert%7B%7B> pemno 
}}.pem' ,dest: '/home/deploy/' }
- { src: 
'/etc/letsencrypt/archive/myhost.com/chain{{<http://myhost.com/chain%7B%7B> 
pemno }}.pem' ,dest: '/home/deploy/' }
- { src: 
'/etc/letsencrypt/archive/myhost.com/fullchain{{<http://myhost.com/fullchain%7B%7B>
 pemno }}.pem',dest: '/home/deploy/' }
  tags:
- copypems

- name: Copy pem files to letsencrypt archive directory
  shell: cp -p '/home/deploy/{{ pemno }}.pem 
/etc/letsencrypt/archive/myhost.com/<http://myh

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
Mobile: 202.355.4123

On Feb 14, 2024, at 12:56 PM, Kathy L  wrote:

I removed the vars_file from my playbook.

I just double-checked and I am not loading  iptables_v4_rules and/or 
iptables_directory  twice..

I wish I could throw it into a repo but this is on a non-Internet connected 
device and can't be moved off.

I've moved from curious to frustrated.


On Tuesday, February 13, 2024 at 4:38:46 PM UTC-5 Todd Lewis wrote:
Do you still have that vars_files: thing? As Dick suggested, it feels like that 
file is getting loaded more than once, and you don't want that.

Is it at all possible that variables iptables_v4_rules and/or 
iptables_directory are being set anywhere else?

[If you want to toss the whole thing in a private repo that I can clone, or 
some other way get to me, I'm willing to take a look; I'm really curious to 
know how this is happening.]

On Tuesday, February 13, 2024 at 3:55:23 PM UTC-5 Kathy Lyons wrote:
Todd- thank you for clearing that up for me

I made default.yml all.yml amd reran things with the same errors.

I am running my roles from within a playbook like this.

- roles

   - role1
  become: true
   - role2
  become: true

On Tue, Feb 13, 2024 at 2:51 PM Todd Lewis  wrote:
This bears repeating. I know I missed it the first few times I was told, and 
then the light came on.

  *   All hosts are in the "all" group. (That much I got the first time. :)

  *   Any files or directories in ./group_vars/ that match a host's group names 
– including "all" – get loaded for that host. It was the "or directories" part 
I didn't appreciate at first. For example, if a host is in the "foo" group, 
then the files ./group_vars/foo, or better, ./group_vars/foo.yml (the former 
won't be ansible-linted; the latter will be) get loaded for that host. But more 
than that, if ./group_vars/foo/ is a directory, then all the files within 
./group_vars/foo/ get loaded for all hosts in the foo group.

  *   That works even for groups that don't exist when the playbook starts but 
are created on-they-fly by, for example, the ansible.builtin.group_by module. 
This allows you to have amazingly crazy ad hoc groups – like "hosts the CEO has 
logged into in the last 30 minutes" – and still use relevant ./group_vars/ 
files in a straightforward way.

We suffered a bit initially because in some of our projects different competing 
interests clashed over ownership of the ./group_vars/all.yml file. When we 
realized we could have files ./group_vars/all/interest_aaa.yml, 
./group_vars/all/interest_bbb.yml, ./group_vars/all/interest_ccc.yml, 
./group_vars/all/interest_ddd.yml, etc., then the competition for that 
namespace became cooperation, and things just got much easier.

On 2/13/24 12:19 PM, Dick Visser wrote:


On Tue, 13 Feb 2024 at 17:35, Kathy L  wrote:
When I make Todd's changes, I get the same original error EXCEPT it tells me 
CentOS is not a dict, even though I am targeting a Debian box.

Dick, are you saying that the file all.yml in the group_vars folder does not 
need to be explicitly stated in my playbook?

Yes.
It sounds like the vars file is somehow used twice, which I think (after Todd's 
comment) may screw up the level of laziness.
(speculation on my side, but let's see)
--
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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLbksQ5HTbbD4xcofM8-e2LUQB8eAFDF5%2BYV%2BGOXv3J3%2BQ%40mail.gmail.com.

-- Todd

--
You received this message because you are subscribed to a topic in the Google 
Groups "Ansible Project" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/ansible-project/irvn6QeOB_w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
ansible-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4858ac06-ca17-447e-a345-d52724145520%40gmail.com.

--
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 

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 group_vars/default.yml being sourced by the role, or by the playbook 
that invokes the role? How are you invoking the role?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Feb 13, 2024, at 11:35 AM, Kathy L  wrote:

When I make Todd's changes, I get the same original error EXCEPT it tells me 
CentOS is not a dict, even though I am targeting a Debian box.

Dick, are you saying that the file all.yml in the group_vars folder does not 
need to be explicitly stated in my playbook?

On Tuesday, February 13, 2024 at 10:51:41 AM UTC-5 Dick Visser wrote:
On Tue, 13 Feb 2024 at 15:33, Kathy L  wrote:
Default.yml is at the playbook level in a folder called group_vars.  It is 
being read in by my playbook like this:

vars_files:
  - group_vars/default.yml

If 'group_vars' is adjacent to your playbook, then 'group_vars/default.yml' 
would also load if the host is in a group called 'default'.
So this file name/location is a bit ambiguous.
In any case I would only use the 'vars_files' statement for files that are not 
automatically loaded.
So I would remove the vars_files statement from your playbook and then rename 
the vars file to 'group_vars/all.yml'.
Or create a dir 'group_vars/all' and move it there: 
'group_vars/all/default.yml' (or main.yml, doesn't matter)



--
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 visit 
https://groups.google.com/d/msgid/ansible-project/dc20f5fa-0045-4673-915f-8668c47d3acdn%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/0243362B-EF8F-487E-8516-E2EC1D1B3901%40nist.gov.


Re: [ansible-project] variable misunderstanding

2024-02-06 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Furthering Todd's message about needing more colons:


% cat foo.yml

---

- name: list to dict

  hosts: localhost

  become: false

  gather_facts: false

  vars:

backups:

  mongodb:

  postgresql:

- sonarqube

- other

  /opt:

  /etc:

  tasks:

- debug: var=backups

- debug: var=backups.postgresql

% ansible-playbook -i localhost, foo.yml


PLAY [list to dict] 



TASK [debug] 
***

ok: [localhost] => {

"backups": {

"/etc": null,

"/opt": null,

"mongodb": null,

"postgresql": [

"sonarqube",

"other"

]

}

}


TASK [debug] 
***

ok: [localhost] => {

"backups.postgresql": [

"sonarqube",

"other"

]

}


PLAY RECAP 
*

localhost  : ok=2changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Feb 6, 2024, at 12:20 PM, 'Rowe, Walter P. (Fed)' via Ansible Project 
 wrote:

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:
- sonarqube
- other
  - /opt
  - /etc
  tasks:
- debug: var=backups


% ansible-playbook -i localhost, foo.yml

PLAY [list to dict] 


TASK [debug] 
***
ok: [localhost] => {
"backups": [
"mongodb",
{
"postgresql": [
"sonarqube",
"other"
]
},
"/opt",
"/etc"
]
}

PLAY RECAP 
*
localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0

backup[0] is a string "mongo"

backup[1] is a dictionary with one key 'postgresql'

backup[2] & [3] are strings "/opt" and "/etc"

backups[1].postgresql is a list of strings

backups[1].postgresql[0] is string "sonarqube"
backups[1].postgresql[1] is string "other"


Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Feb 6, 2024, at 8:05 AM, gregory@gmail.com  
wrote:

i have this:

  backups:
- mongodb
- postgresql:
- sonarqube
- other
- /opt
- /etc

later i use it in template task:
- name: template backup script out
  template:
src: backup-script.sh.j2
dest: /root/backup.sh
mode: 755


my jinja2 is:
{% if backups.postgresql is defined %}
  {% for db in backups.postgresql %}
 {{ db }}
   {% endfor %}
{% endif %}

expected output:
sonarqube
other

but got an empty output.
what's wrong in my template?

thank you!

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d9bd0bf0-11b4-45db-8b94-2cd445a093a9n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/d9bd0bf0-11b4-45db-8b94-2cd445a093a9n%40googlegroups.com?utm_medium=email_source=footer>.


--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7910AFC7-18E1-4952-B8B9-F764461E0405%40nist.gov<https://groups.google.com/d/msgid/ansible-project/7910AFC7-18E1-4952-B8B9-F764461E0405%40nist.gov?utm_medium=email_source=footer>.

-- 
You received this message because yo

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:

- sonarqube

- other

  - /opt

  - /etc

  tasks:

- debug: var=backups



% ansible-playbook -i localhost, foo.yml


PLAY [list to dict] 



TASK [debug] 
***

ok: [localhost] => {

"backups": [

"mongodb",

{

"postgresql": [

"sonarqube",

"other"

]

},

"/opt",

"/etc"

]

}


PLAY RECAP 
*

localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0

backup[0] is a string "mongo"

backup[1] is a dictionary with one key 'postgresql'

backup[2] & [3] are strings "/opt" and "/etc"

backups[1].postgresql is a list of strings

backups[1].postgresql[0] is string "sonarqube"
backups[1].postgresql[1] is string "other"


Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Feb 6, 2024, at 8:05 AM, gregory@gmail.com  
wrote:

i have this:

  backups:
- mongodb
- postgresql:
- sonarqube
- other
- /opt
- /etc

later i use it in template task:
- name: template backup script out
  template:
src: backup-script.sh.j2
dest: /root/backup.sh
mode: 755


my jinja2 is:
{% if backups.postgresql is defined %}
  {% for db in backups.postgresql %}
 {{ db }}
   {% endfor %}
{% endif %}

expected output:
sonarqube
other

but got an empty output.
what's wrong in my template?

thank you!

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/d9bd0bf0-11b4-45db-8b94-2cd445a093a9n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/7910AFC7-18E1-4952-B8B9-F764461E0405%40nist.gov.


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 }} - {{ item.has_wiki }}"
loop: "{{ json }}"


Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Feb 5, 2024, at 12:26 PM, John Simmons  wrote:

Hi Hope you can help me,

I have a step in a playbook that makes a uri call to the gihub api servers and 
returns all the info regarding all of our repo's. I need to create a with_items 
list with information from that json response to have 3 items per repo(for 
example) for the next part of the playbook. Does anybody know any great ideas 
on how to go about this?

wanted with_items list:
with_items: - { name: REPO1, disabled: False, has_wiki: True } - { name: REPO2, 
disabled: False, has_wiki: True }

Example json output from previous step:

"json": [
{
"allow_forking": true,
"archive_url": 
"https://api.github.com/repos/**/REPO1/{archive_format}{/ref};,
"archived": false,
"assignees_url": 
"https://api.github.com/repos/**/REPO1/assignees{/user};,
"blobs_url": 
"https://api.github.com/repos/**/REPO1/git/blobs{/sha};,
"branches_url": 
"https://api.github.com/repos/**/REPO1/branches{/branch};,
"clone_url": "https://github.com/**/REPO1.git;,
"collaborators_url": 
"https://api.github.com/repos/**/REPO1/collaborators{/collaborator};,
"comments_url": 
"https://api.github.com/repos/**/REPO1/comments{/number};,
"commits_url": 
"https://api.github.com/repos/**/REPO1/commits{/sha};,
"compare_url": 
"https://api.github.com/repos/**/REPO1/compare/{base}...{head};,
"contents_url": 
"https://api.github.com/repos/**/REPO1/contents/{+path};,
"contributors_url": 
"https://api.github.com/repos/**/REPO1/contributors;,
"created_at": "2023-12-14T09:22:56Z",
"default_branch": "main",
"deployments_url": 
"https://api.github.com/repos/**/REPO1/deployments;,
"description": "",
"disabled": false,
"downloads_url": "https://api.github.com/repos/**/REPO1/downloads;,
"events_url": "https://api.github.com/repos/**/REPO1/events;,
"fork": true,
"forks": 0,
"forks_count": 0,
"forks_url": "https://api.github.com/repos/**/REPO1/forks;,
"full_name": "**/REPO1",
"git_commits_url": 
"https://api.github.com/repos/**/REPO1/git/commits{/sha};,
"git_refs_url": 
"https://api.github.com/repos/**/REPO1/git/refs{/sha};,
"git_tags_url": 
"https://api.github.com/repos/**/REPO1/git/tags{/sha};,
"git_url": "git://github.com/**/REPO1.git",
"has_downloads": true,
"has_issues": true,
"has_pages": false,
"has_projects": true,
"has_wiki": true,
"homepage": null,
"hooks_url": "https://api.github.com/repos/**/REPO1/hooks;,
"html_url": "https://github.com/**/REPO1;,
"id": ***,
"issue_comment_url": 
"https://api.github.com/repos/**/REPO1/issues/comments{/number};,
"issue_events_url": 
"https://api.github.com/repos/**/REPO1/issues/events{/number};,
"issues_url": 
"https://api.github.com/repos/**/REPO1/issues{/number};,
"keys_url": "https://api.github.com/repos/**/REPO1/keys{/key_id};,
"labels_url": "https://api.github.com/repos/**/REPO1/labels{/name};,
"language": "Python",
"languages_url": "https://api.github.com/repos/**/REPO1/languages;,
"license": null,
"merges_url": "https://api.github.com/repos/**/REPO1/merges;,
"milestones_url": 
"https://api.github.com/repos/**/REPO1/milestones{/number};,
"mirror_url": null,
"name": "REPO1",
"node_id": "***",
"notifications_url": 
"https://api.github.com/repos/**/REPO1/notifications{?since,all,participating};,
"open_issues": 0,
"open_issues_count": 0,
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/20?v=4;,
"events_url": 
"https://api.github.com/users/**/events{/privacy};,
"followers_url": "https://api.github.com/users/**/followers;,
"following_url": 
"https://api.github.com/users/**/following{/other_user};,
"gists_url": "https://api.github.com/users/**/gists{/gist_id};,
"gravatar_id": "",
"html_url": "https://github.com/**;,
"id": 20,
"login": "**",
"node_id": "",
"organizations_url": "https://api.github.com/users/**/orgs;,
"received_events_url": 
"https://api.github.com/users/**/received_events;,
"repos_url": 

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 Project 
 wrote:

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 that provides 
the value of that key to look up at run time. We have an east and west vCenter 
and a sandbox we call "vCloud". You will see vc_east, vc_west, vc_vcloud keys 
in the esx_vars.yml dictionary.

The esx-create-snapshot.yml gets info about the existing machine, powers it 
down, creates the snapshot, then powers it back up ONLY if it was powered on 
when we started (state: "{{ snapvm.instance.hw_power_status | lower }}" at line 
74 comes from the guest info we get at line 31). At the bottom of 
esx-snapshot-create.yml we use set_stats to artifacts so they can be used 
downstream in the AAP workflow by ex-snapshot-revert.yml including its powered 
on status.



Even if you don't use these playbooks they may help you craft your own.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jan 22, 2024, at 3:36 AM, Prady A  wrote:

Hi Rilindo,

Thanks for your reply. That was typo error . I fixed the issue, in the REST api 
i need to pass memory flag which by default is false. This memory flag retains 
the machine power status also.

Thank you for your all support.

PD

On Mon, 22 Jan 2024 at 13:50, Rilindo Foster 
mailto:rili...@gmail.com>> wrote:
Is that a space before snapshot (right where it says “Task” in the JSON 
request)? Was that part of the request or did you insert that by mistake when 
you copied it into the email?

- Rilindo

On Jan 21, 2024, at 9:13 PM, Prady A 
mailto:pradyumna@gmail.com>> wrote:


Hi,

Thank you both of you for your kind suggestions.
We are using leap-upgrade tool to upgrade. In upgrade there is no issue. We 
have a health checkup also post upgrade.

The issue is in VMware but not sure when creating manually the “Snapshot the 
virtual machine memory” is set to Yes but when I am creating the snapshot 
through ansible automatically it is setting as No. This is something with 
VMware maybe..

- Name: Create VM snapshot
   Uri:
  URL: https://api.xyz/virtualization/snapshot/snow
  User: “ {{ snapshot_user }}”
  Password: “{{ snapshot_Password }}“
  force_basic_auth: true
  Method: post
  Body_format: json
  Body: |-
  {
 “Hostname”: “{{ vm_hostname }}”,
 “Task”: “ create”,
  “Snapshot_name”: “upgrade-{{vm_hostname}} “
   }
  Status code: 202
   Register: snapshot_result


Regards
PD



On Sun, 21 Jan 2024 at 07:15, Nico Kadel-Garcia 
mailto:nka...@gmail.com>> wrote:
On Thu, Jan 18, 2024 at 8:16 PM Prady A 
mailto:pradyumna@gmail.com>> wrote:
>
> Hi experts,
>
> We are doing automation to update RHEL7-> RHEL8 .
> Before we upgrade we take the snapshot.
> The issue is whenever there is an upgrade failure we revert the server to its 
> previous state. But it seems when we revert it the machine is in power off 
> state..
> it seems when we take automatic snapshot it happens like that.. Any pointers 
> pls
>
> Regards
> PD

That's a RHEL problem. It's not an operation supported by RHEL.
Updating the critical system libraries, such as glibc and the python
on which RPM is based, and RPM itself, is likely to trip over a *lot*
of problems without quite a lot of research and debugging. From
decades of experience with Red Hat based operating systems, I
recommend very strongly against this approach.

If I may suggest, take a disk image of the old system and build a new
system, with content copied as needed to configure the new system.

--
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<mailto:ansible-project%2bunsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAOCN9ry6d0wKwzJutwXDJSMH3X9vD51hLVqqtbJd9rHzRfkEKQ%40mail.gmail.com.

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/an

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 that provides 
the value of that key to look up at run time. We have an east and west vCenter 
and a sandbox we call "vCloud". You will see vc_east, vc_west, vc_vcloud keys 
in the esx_vars.yml dictionary.

The esx-create-snapshot.yml gets info about the existing machine, powers it 
down, creates the snapshot, then powers it back up ONLY if it was powered on 
when we started (state: "{{ snapvm.instance.hw_power_status | lower }}" at line 
74 comes from the guest info we get at line 31). At the bottom of 
esx-snapshot-create.yml we use set_stats to artifacts so they can be used 
downstream in the AAP workflow by ex-snapshot-revert.yml including its powered 
on status.



Even if you don't use these playbooks they may help you craft your own.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jan 22, 2024, at 3:36 AM, Prady A  wrote:

Hi Rilindo,

Thanks for your reply. That was typo error . I fixed the issue, in the REST api 
i need to pass memory flag which by default is false. This memory flag retains 
the machine power status also.

Thank you for your all support.

PD

On Mon, 22 Jan 2024 at 13:50, Rilindo Foster 
mailto:rili...@gmail.com>> wrote:
Is that a space before snapshot (right where it says “Task” in the JSON 
request)? Was that part of the request or did you insert that by mistake when 
you copied it into the email?

- Rilindo

On Jan 21, 2024, at 9:13 PM, Prady A 
mailto:pradyumna@gmail.com>> wrote:


Hi,

Thank you both of you for your kind suggestions.
We are using leap-upgrade tool to upgrade. In upgrade there is no issue. We 
have a health checkup also post upgrade.

The issue is in VMware but not sure when creating manually the “Snapshot the 
virtual machine memory” is set to Yes but when I am creating the snapshot 
through ansible automatically it is setting as No. This is something with 
VMware maybe..

- Name: Create VM snapshot
   Uri:
  URL: https://api.xyz/virtualization/snapshot/snow
  User: “ {{ snapshot_user }}”
  Password: “{{ snapshot_Password }}“
  force_basic_auth: true
  Method: post
  Body_format: json
  Body: |-
  {
 “Hostname”: “{{ vm_hostname }}”,
 “Task”: “ create”,
  “Snapshot_name”: “upgrade-{{vm_hostname}} “
   }
  Status code: 202
   Register: snapshot_result


Regards
PD



On Sun, 21 Jan 2024 at 07:15, Nico Kadel-Garcia 
mailto:nka...@gmail.com>> wrote:
On Thu, Jan 18, 2024 at 8:16 PM Prady A 
mailto:pradyumna@gmail.com>> wrote:
>
> Hi experts,
>
> We are doing automation to update RHEL7-> RHEL8 .
> Before we upgrade we take the snapshot.
> The issue is whenever there is an upgrade failure we revert the server to its 
> previous state. But it seems when we revert it the machine is in power off 
> state..
> it seems when we take automatic snapshot it happens like that.. Any pointers 
> pls
>
> Regards
> PD

That's a RHEL problem. It's not an operation supported by RHEL.
Updating the critical system libraries, such as glibc and the python
on which RPM is based, and RPM itself, is likely to trip over a *lot*
of problems without quite a lot of research and debugging. From
decades of experience with Red Hat based operating systems, I
recommend very strongly against this approach.

If I may suggest, take a disk image of the old system and build a new
system, with content copied as needed to configure the new system.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAOCN9ry6d0wKwzJutwXDJSMH3X9vD51hLVqqtbJd9rHzRfkEKQ%40mail.gmail.com.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAEuB3AoFvdepBuNSvKHQ%3Dc_TYpwUUjrF8QYdgMd_MKb22-8v8A%40mail.gmail.com.

--
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 

Re: [ansible-project] Incomprehensible error message

2024-01-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
If you install a collection via ansible-galaxy how do you keep it updated? Is 
there a galaxy command to refresh all your existing collections and plugins?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jan 18, 2024, at 7:57 AM, Dick Visser  wrote:

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 collections current?

We tend to use the ansible version as the starting point, and use just the 
collection versions from that...
Or do you mean something else?

Dick

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLY8qfRXMQO4RcXsf0oYS5TNOtg72mZ%2Br12q5SGiUat7JA%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAF8BbLY8qfRXMQO4RcXsf0oYS5TNOtg72mZ%2Br12q5SGiUat7JA%40mail.gmail.com?utm_medium=email_source=footer>.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/25DFEFE9-443C-4471-9072-7D0F84A5DB65%40nist.gov.


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 2:30 AM, Vladimir Botka  wrote:

On Thu, 18 Jan 2024 12:38:09 +0700
Ian Hobson  wrote:

The comma separated list of privileges, cannot have spaces after the
commas.

This is unusually user-hostile!

This was fixed two years ago
https://github.com/ansible-collections/community.mysql/blob/main/plugins/module_utils/user.py#L522

See also:
https://github.com/ansible-collections/community.mysql/pull/189
https://github.com/ansible-collections/community.mysql/pull/243

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/20240118083057.28a18ab8%40gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/9AEFC5D7-32CE-43B1-8FEB-F67046114602%40nist.gov.


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 to a list

s: "['/First Datacenter/vm/Prod-SRM']"
l: "{{ s|from_yaml }}"

gives

l.0: /First Datacenter/vm/Prod-SRM

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/20240110181644.79b47b90%40gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/DFDE8949-FE3F-4DB7-AE58-41247AB0D056%40nist.gov.


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 ansible we have to escape the backslashes.

[\\[\\]']

You could place any characters in that set. The regex matches *any* of them any 
number of times.

For example I could use [walter] and it would look for any of those characters.

You also can use ranges like [a-dv-z]. This all follows Python regex rules.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jan 10, 2024, at 11:03 AM, Dimitri Yioulos  wrote:

Walter, to further my knowledge, would you mind explaining further what this 
regex  \"([\\[\\]'])\",'  does? Is the regex specifi to regex_replace?

On Wednesday, January 10, 2024 at 10:33:53 AM UTC-5 Dimitri Yioulos wrote:
Walter, that worked, and thanks so much! I both appreciate the regex solution, 
and it simplification. I also probably be able to reuse this, with some 
modifications, depending on what I'm trying to accomplish. Double win. Thanks 
again!

On Wednesday, January 10, 2024 at 10:14:32 AM UTC-5 Rowe, Walter P. (Fed) wrote:
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: false
  vars:
mystr: "['/First Datacenter/vm/Prod-SRM']"
  tasks:
- debug: msg="{{ mystr | regex_replace(\"([\\[\\]'])\",'') }}"


% ansible-playbook -i localhost, foo.yml

PLAY [test] 


TASK [debug] 
***
ok: [localhost] => {
"msg": "/First Datacenter/vm/Prod-SRM"
}

PLAY RECAP 
*
localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0

The solution was found on this stack overflow page.

https://stackoverflow.com/questions/52495838/ansible-remove-the-single-quote-character-from-a-string

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jan 10, 2024, at 9:27 AM, Rowe, Walter P. (Fed)  wrote:

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 
folders. In order for this to work, I first have to get the folders in which 
the virtual machines live. Here's the playbook:

---

- hosts: all
  become: false
  gather_facts: false

  vars_prompt:

- name: "vcenter_username"
  prompt: "Enter your Vcenter username"
  private: no
- name: "vcenter_password"
  prompt: "Enter your VMware password"
  private: yes

  vars:
vcenter_hostname: vcenter1.mycompany.com<http://vcenter1.mycompany.com/>
vcenter_datacenter: First Datacenter

  tasks:

- name: Find virtual machine's folder name
  vmware_guest_find:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ inventory_hostname }}"
validate_certs: False
  delegate_to: localhost
  ignore_errors: true
  register: vm_facts
  tags:
- folder

- name: Show folders
  ansible.builtin.debug:
msg: "{{ vm_facts.folders }}"
  tags:
- folder

- name: Remove all snapshots of a VM
  community.vmware.vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ vcenter_datacenter }}"
folder: "{{ vm_facts.folders | regex_replace('(\\[)|(\\])',  '') }}"
name: "{{ inventory_hostname }}"
state: remove_all
validate_certs: False
  delegate_to: localhost

Previous to my having employed regex_replace, this is the output I'd get, e.g., 
for a vm's folder:

"['/First Datacenter/vm/Prod-SRM']"

The problem with that is [' and ']. They can't be part pf the folder name. 
After employing regex-replace, the output is:

" '/Bedford Datacenter/vm/Bedford-Prod-SRM' "

Try as 

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: false

  vars:

mystr: "['/First Datacenter/vm/Prod-SRM']"

  tasks:

- debug: msg="{{ mystr | regex_replace(\"([\\[\\]'])\",'') }}"



% ansible-playbook -i localhost, foo.yml


PLAY [test] 



TASK [debug] 
***

ok: [localhost] => {

"msg": "/First Datacenter/vm/Prod-SRM"

}


PLAY RECAP 
*

localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0

The solution was found on this stack overflow page.

https://stackoverflow.com/questions/52495838/ansible-remove-the-single-quote-character-from-a-string

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jan 10, 2024, at 9:27 AM, Rowe, Walter P. (Fed)  wrote:

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 
folders. In order for this to work, I first have to get the folders in which 
the virtual machines live. Here's the playbook:

---

- hosts: all
  become: false
  gather_facts: false

  vars_prompt:

- name: "vcenter_username"
  prompt: "Enter your Vcenter username"
  private: no
- name: "vcenter_password"
  prompt: "Enter your VMware password"
  private: yes

  vars:
vcenter_hostname: vcenter1.mycompany.com
vcenter_datacenter: First Datacenter

  tasks:

- name: Find virtual machine's folder name
  vmware_guest_find:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ inventory_hostname }}"
validate_certs: False
  delegate_to: localhost
  ignore_errors: true
  register: vm_facts
  tags:
- folder

- name: Show folders
  ansible.builtin.debug:
msg: "{{ vm_facts.folders }}"
  tags:
- folder

- name: Remove all snapshots of a VM
  community.vmware.vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ vcenter_datacenter }}"
folder: "{{ vm_facts.folders | regex_replace('(\\[)|(\\])',  '') }}"
name: "{{ inventory_hostname }}"
state: remove_all
validate_certs: False
  delegate_to: localhost

Previous to my having employed regex_replace, this is the output I'd get, e.g., 
for a vm's folder:

"['/First Datacenter/vm/Prod-SRM']"

The problem with that is [' and ']. They can't be part pf the folder name. 
After employing regex-replace, the output is:

" '/Bedford Datacenter/vm/Bedford-Prod-SRM' "

Try as I may, I've not been able to find a way to also remove the single quotes 
(the double quotes can remain). I've tried appending to the regex_replace, but 
every piece of code i've used has failed.

regex_replace('(\\[)|(\\])'|(addlcodehere),  '') }}

Your kinf assistance requested.

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/34393455-5021-4342-89b4-de276d68ccd9n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/34393455-5021-4342-89b4-de276d68ccd9n%40googlegroups.com?utm_medium=email_source=footer>.


-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/D4C8E154-6B7D-4D2A-9EEF-7E0ECE8CBC17%40nist.gov.


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 
folders. In order for this to work, I first have to get the folders in which 
the virtual machines live. Here's the playbook:

---

- hosts: all
  become: false
  gather_facts: false

  vars_prompt:

- name: "vcenter_username"
  prompt: "Enter your Vcenter username"
  private: no
- name: "vcenter_password"
  prompt: "Enter your VMware password"
  private: yes

  vars:
vcenter_hostname: vcenter1.mycompany.com
vcenter_datacenter: First Datacenter

  tasks:

- name: Find virtual machine's folder name
  vmware_guest_find:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ inventory_hostname }}"
validate_certs: False
  delegate_to: localhost
  ignore_errors: true
  register: vm_facts
  tags:
- folder

- name: Show folders
  ansible.builtin.debug:
msg: "{{ vm_facts.folders }}"
  tags:
- folder

- name: Remove all snapshots of a VM
  community.vmware.vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ vcenter_datacenter }}"
folder: "{{ vm_facts.folders | regex_replace('(\\[)|(\\])',  '') }}"
name: "{{ inventory_hostname }}"
state: remove_all
validate_certs: False
  delegate_to: localhost

Previous to my having employed regex_replace, this is the output I'd get, e.g., 
for a vm's folder:

"['/First Datacenter/vm/Prod-SRM']"

The problem with that is [' and ']. They can't be part pf the folder name. 
After employing regex-replace, the output is:

" '/Bedford Datacenter/vm/Bedford-Prod-SRM' "

Try as I may, I've not been able to find a way to also remove the single quotes 
(the double quotes can remain). I've tried appending to the regex_replace, but 
every piece of code i've used has failed.

regex_replace('(\\[)|(\\])'|(addlcodehere),  '') }}

Your kinf assistance requested.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/34393455-5021-4342-89b4-de276d68ccd9n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/6D8F3276-7A70-4ABC-A47D-B177ACB4E34C%40nist.gov.


Re: [ansible-project] backslashes in regex_replace filter

2024-01-09 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Perhaps because you have single quotes inside double quotes so everything 
inside the single quotes is automatically escaped?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jan 9, 2024, at 9:04 AM, Rob Wagner  wrote:

Right, but why doesn’t the \\d 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 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 still don't get why the first parameter (\\d) MAY be double 
backslashed but the second parameter (\\1) MUST be double backslashed.  
However, I'm starting to think it's at the python level.  
https://stackoverflow.com/a/33582215 says Python's string parser causes both \d 
and \\d to become \d.  But why?  A little more searching takes me to 
https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences, 
where I think I see why \\1 becomes \1 and \1 becomes a non-printable character 
(octal 1).  But then, by analogy, \\d should become \d (it does) but why 
doesn't \d become an error (since it's not listed as a valid escape sequence).

Maybe I'll take this over to the Python list.

On Mon, Jan 8, 2024 at 4:52 PM Matt Martz 
mailto:m...@sivel.net>> wrote:
This is a result of some normalization code in jinja2 that attempts to unescape 
strings:

https://github.com/pallets/jinja/blob/d594969d722ceb4e8f3da8861befc9c0ac87ae1b/src/jinja2/lexer.py#L647-L653

That code results in those becoming '^p(\\d+).*$' and '\\1'.

Those 2 when statements, when processed by pyyaml become:

["( item | regex_replace('^p(\\d+).*$', '1') ) in s",
 "( item | regex_replace('^p(d+).*$', '1') ) in s"]

Then if we apply the .encode/.decode:

>>> "( item | regex_replace('^p(\\d+).*$', '1') ) in s".encode("ascii", 
>>> "backslashreplace").decode("unicode-escape")
"( item | regex_replace('^p(\\d+).*$', '\\1') ) in s"

>>> "( item | regex_replace('^p(d+).*$', '\\\\1') ) in s".encode("ascii", 
>>> "backslashreplace").decode("unicode-escape")
"( item | regex_replace('^p(\\d+).*$', '\\1') ) in s"

--
You received this message because you are subscribed to a topic in the Google 
Groups "Ansible Project" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/ansible-project/A-QsBqBiWVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
ansible-project+unsubscr...@googlegroups.com<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v-Sf3AmrkEnFZZtxAbJHTUv%3D6gNezDkESTxoatHq-86YA%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAD8N0v-Sf3AmrkEnFZZtxAbJHTUv%3D6gNezDkESTxoatHq-86YA%40mail.gmail.com?utm_medium=email_source=footer>.

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAMc-rNPNqQMKKsqy2gwRBAt%2BEWnn%2B_rEY-CJo7sWJFhGnamLQQ%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAMc-rNPNqQMKKsqy2gwRBAt%2BEWnn%2B_rEY-CJo7sWJFhGnamLQQ%40mail.gmail.com?utm_medium=email_source=footer>.


--
You received this message because you are subscribed to a topic in the Google 
Groups "Ansible Project" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/ansible-project/A-QsBqBiWVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
ansible-project+unsubscr...@googlegroups.com<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/BECB61FE-847C-44CB-8FB2-6AC5489F052F%40nist.gov<https://groups.google.com/d/msgid/ansible-project/BECB61FE-847C-44CB-8FB2-6AC5489F052F%40nist.gov?utm_medium=email_source=footer>.

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To vie

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 extract 
the 1, 2, 4 digits from those strings.

Your string 's' has digits 1 and 2. You are getting two lines of output as 
expected.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Jan 8, 2024, at 4:15 PM, rjwagn...@gmail.com  wrote:

Hi - Does anyone (who understands how backslashes work in Ansible/YAML) know 
why both of the following tasks work:

(ansible2_15_8) rowagn@localhost:~#> cat d.yml
- hosts: all
  gather_facts: no
  vars:
s: 'This is a string containing 1 and 2.'
t:
  - p1_xyz
  - p2_xyz
  - p4_xyz

  tasks:
  - name: single backslash
debug:
  msg: '{{ item }} is in s'
loop: '{{ t }}'
when: ( item | regex_replace('^p(\d+).*$', '\\1') ) in s

  - name: double backslash
debug:
  msg: '{{ item }} is in s'
loop: '{{ t }}'
when: ( item | regex_replace('^p(\\d+).*$', '\\1') ) in s

(ansible2_15_8) rowagn@localhost:~#> ansible-playbook -i l d.yml

PLAY [all] 
**

TASK [single backslash] 
*
ok: [localhost] => (item=p1_xyz) => {
"msg": "p1_xyz is in s"
}
ok: [localhost] => (item=p2_xyz) => {
"msg": "p2_xyz is in s"
}
skipping: [localhost] => (item=p4_xyz)

TASK [double backslash] 
*
ok: [localhost] => (item=p1_xyz) => {
"msg": "p1_xyz is in s"
}
ok: [localhost] => (item=p2_xyz) => {
"msg": "p2_xyz is in s"
}
skipping: [localhost] => (item=p4_xyz)

PLAY RECAP 
**
localhost  : ok=2changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


The tasks are extracting the number from the strings in list t and then looking 
for that number in string s.  What is strange is the second example at 
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/regex_replace_filter.html#examples
 indicates the backslashes in both parameters need to be doubled, but the above 
testing shows double backslashes are not required in the first parameter (they 
are required in the second parameter).

Thanks
Rob

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bd36f3ef-9b36-4af1-aede-9435535d9fb0n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/bd36f3ef-9b36-4af1-aede-9435535d9fb0n%40googlegroups.com?utm_medium=email_source=footer>.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/CEE7C868-60EE-4D65-9303-878D705B3CE0%40nist.gov.


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 still don't get why the first parameter (\\d) MAY be double 
backslashed but the second parameter (\\1) MUST be double backslashed.  
However, I'm starting to think it's at the python level.  
https://stackoverflow.com/a/33582215 says Python's string parser causes both \d 
and \\d to become \d.  But why?  A little more searching takes me to 
https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences, 
where I think I see why \\1 becomes \1 and \1 becomes a non-printable character 
(octal 1).  But then, by analogy, \\d should become \d (it does) but why 
doesn't \d become an error (since it's not listed as a valid escape sequence).

Maybe I'll take this over to the Python list.

On Mon, Jan 8, 2024 at 4:52 PM Matt Martz 
mailto:m...@sivel.net>> wrote:
This is a result of some normalization code in jinja2 that attempts to unescape 
strings:

https://github.com/pallets/jinja/blob/d594969d722ceb4e8f3da8861befc9c0ac87ae1b/src/jinja2/lexer.py#L647-L653

That code results in those becoming '^p(\\d+).*$' and '\\1'.

Those 2 when statements, when processed by pyyaml become:

["( item | regex_replace('^p(\\d+).*$', '1') ) in s",
 "( item | regex_replace('^p(d+).*$', '1') ) in s"]

Then if we apply the .encode/.decode:

>>> "( item | regex_replace('^p(\\d+).*$', '1') ) in s".encode("ascii", 
>>> "backslashreplace").decode("unicode-escape")
"( item | regex_replace('^p(\\d+).*$', '\\1') ) in s"

>>> "( item | regex_replace('^p(d+).*$', '\\\\1') ) in s".encode("ascii", 
>>> "backslashreplace").decode("unicode-escape")
"( item | regex_replace('^p(\\d+).*$', '\\1') ) in s"

--
You received this message because you are subscribed to a topic in the Google 
Groups "Ansible Project" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/ansible-project/A-QsBqBiWVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
ansible-project+unsubscr...@googlegroups.com<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v-Sf3AmrkEnFZZtxAbJHTUv%3D6gNezDkESTxoatHq-86YA%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAD8N0v-Sf3AmrkEnFZZtxAbJHTUv%3D6gNezDkESTxoatHq-86YA%40mail.gmail.com?utm_medium=email_source=footer>.

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAMc-rNPNqQMKKsqy2gwRBAt%2BEWnn%2B_rEY-CJo7sWJFhGnamLQQ%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAMc-rNPNqQMKKsqy2gwRBAt%2BEWnn%2B_rEY-CJo7sWJFhGnamLQQ%40mail.gmail.com?utm_medium=email_source=footer>.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/BECB61FE-847C-44CB-8FB2-6AC5489F052F%40nist.gov.


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 confused about what you are asking for.

It sounds like you are currently managing AD objects in an existing domain 
controller by using win_shell commands targeting that domain controller. So far 
so good.

The part that confuses me is "my target host will be localhost as it's linux" 
and "no dependency of windows target". Are you running a windows domain on 
linux with a linux host as the domain controller? Are we talking about a 
genuine windows domain here and not an IPA suite? (Although that would be 
sweet!)

Then I'm even more confused by "I am using AWX […] on [kubernetes]". Surely you 
aren't running your domain controller on the same host(s) as your AWX 
instance(s)?

I'm not a windows domain admin — which may be painfully obvious from my 
confusion, displayed above. But if my guesses are correct, then the crucially 
important point is tucked away in these 
docs'
 "Notes" section:

  *   If running on a server that is not a Domain Controller, credential 
delegation through CredSSP or Kerberos with delegation must be used or the 
domain_username, domain_password must be set.

If you do get it working, please drop a followup message to this thread 
indicating what you needed to do. You surely aren't the only one with the issue.


On 1/2/24 2:01 PM, Thirumalai Raja A wrote:
Hi, gys

i have a task to manage AD objects like create, delete using ansible task right 
now i am using win_shell command module to run the command on windows target 
and creating AD objects. But I need to do it the same using an inbuilt ansible 
module like microsoft.ad about my target host will be 
localhost as its linux so that no dependency of windows target any one can 
guide me on this.

I am using AWX tower to run the playbook and AWX is running on the K8 cluster.

Regards,

Thirumalai
--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CALyK%3Dg8AXXg6kaB8A%2B9GFtwXQgB3F8MrYVjS1%3DOE-qSG2uqPJQ%40mail.gmail.com.


--
Todd

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/98db6d07-c792-4b6e-8648-d3cb6aa30940%40gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/26D5A657-F9FA-427F-BDA6-E74AE92E068A%40nist.gov.


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

2023-12-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I wonder how copy module works even though the concept are same.

Again, if the source is part of the project then it will be visible to the 
playbook. If it is not you need to delegate_to the source host and provide the 
correct source path for the source host.

Walter
--
Walter Rowe, Division 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)' via Ansible Project 
mailto:ansible-project@googlegroups.com>> 
wrote:
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 Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Dec 13, 2023, at 9:19 AM, Prady A 
mailto:pradyumna@gmail.com>> wrote:

Hi Dick

Thank you for the directions. If I not wrong all AAP uses containers to execute 
the templates and this is not specific to me. I m not sure why ansible AAP 
provided which does not work in the out of box bundle. let me chk with RH 
support..
Thank a lot again..



On Wed, 13 Dec 2023 at 22:52, Dick Visser 
mailto:dnmvis...@gmail.com>> wrote:


On Wed, 13 Dec 2023 at 14:43, Prady A 
mailto:pradyumna@gmail.com>> wrote:
Thank you for your direction and suggestion..
actually we want to sync http folder not a file
Is there any way I can sync between 2 servers.?

You can, with the synchronize module. But as explained above, your specific 
setup includes containers, so that needs some work. What exactly depends on 
your setup, if you can mount volumes, etc. Something that is known to you. IIRC 
the product you are using (AAP) includes support, so that would be the most 
logical thing to try.

If you folder is not too big you can still use the copy module:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html#parameter-src

You should experiment a bit with that.



--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLY%3DHLFLXFWy4W2emk4ioWJBwgWSFOFE8ORQCWNN1VzXBA%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAF8BbLY%3DHLFLXFWy4W2emk4ioWJBwgWSFOFE8ORQCWNN1VzXBA%40mail.gmail.com?utm_medium=email_source=footer>.

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEuB3ApSvRPBPz-nkSefCwuYOQL%2BQQEDomEpo3xQpAPsSmdXtg%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAEuB3ApSvRPBPz-nkSefCwuYOQL%2BQQEDomEpo3xQpAPsSmdXtg%40mail.gmail.com?utm_medium=email_source=footer>.


--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/96F718E3-53E3-46AD-AD5B-9C96243C548E%40nist.gov<https://groups.google.com/d/msgid/ansible-project/96F718E3-53E3-46AD-AD5B-9C96243C548E%40nist.gov?utm_medium=email_source=footer>.

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEuB3ApDMLxu8iF_HLng%3DvE-pZVfuGO6vo%2BNtmA4nMdPPvaoAQ%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAEuB3ApDMLxu8iF_HLng%3DvE-pZVfuGO6vo%2BNtmA4nMdPPvaoAQ%40mail.gmail.com?utm_medium=email_source=footer>.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/7B721678-D25A-47E5-A2B0-108FF245E91A%40nist.gov.


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 Chief
Infrastructure Services Division
Mobile: 202.355.4123

On Dec 13, 2023, at 9:19 AM, Prady A  wrote:

Hi Dick

Thank you for the directions. If I not wrong all AAP uses containers to execute 
the templates and this is not specific to me. I m not sure why ansible AAP 
provided which does not work in the out of box bundle. let me chk with RH 
support..
Thank a lot again..



On Wed, 13 Dec 2023 at 22:52, Dick Visser 
mailto:dnmvis...@gmail.com>> wrote:


On Wed, 13 Dec 2023 at 14:43, Prady A 
mailto:pradyumna@gmail.com>> wrote:
Thank you for your direction and suggestion..
actually we want to sync http folder not a file
Is there any way I can sync between 2 servers.?

You can, with the synchronize module. But as explained above, your specific 
setup includes containers, so that needs some work. What exactly depends on 
your setup, if you can mount volumes, etc. Something that is known to you. IIRC 
the product you are using (AAP) includes support, so that would be the most 
logical thing to try.

If you folder is not too big you can still use the copy module:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html#parameter-src

You should experiment a bit with that.



--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLY%3DHLFLXFWy4W2emk4ioWJBwgWSFOFE8ORQCWNN1VzXBA%40mail.gmail.com.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAEuB3ApSvRPBPz-nkSefCwuYOQL%2BQQEDomEpo3xQpAPsSmdXtg%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/96F718E3-53E3-46AD-AD5B-9C96243C548E%40nist.gov.


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 below code


- Name: Install rsync on the Target
  package:
name: rsync
state: present

- Name: Synchronize file from local to remote
  synchronize:
 src: /tmp/memo.txt
 dest: /temp/test

code I can run the code using ansible-playbook command but when I am executing 
it via ansible automation platform gui it is giving me the below error
Message . No file error.

cmd": "/usr/bin/rsync --delay-updates -F --compress --archive 
--rsh='/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o 
UserKnownHostsFile=/dev/null' --out-format='<>%i %n%L' /tmp/memo.txt 
root@xyz1234:/tmp/test",  "msg": "Warning: Permanently added 
'xyz1234,148.168.65.73' (ECDSA) to the list of known hosts.\r\nWARNING!\n   
   This system, owned by the Company, may be used only by 
authorized personnel for authorized purposes. All activities conducted on and 
communications and other information, including personal information, accessed, 
processed, stored, or transmitted using the system may be examined, recorded, 
copied, used and disclosed in accordance with applicable law. The Company 
monitors systems to safeguard the security of its systems and data, to protect 
against policy violations and unlawful activity, to administer working 
relationships, and to meet legal obligations and promises to business partners. 
By proceeding, you agree to use the system only for authorized purposes and in 
accordance with Company policies that have been made available to you. For 
additional information consult your local business's employee privacy notice or 
contact your local Privacy Officer.\nrsync: link_stat \"/tmp/memo.txt\" failed: 
No such file or directory (2)\nrsync error: some files/attrs were not 
transferred (see previous errors) (code 23) at main.c(1189) [sender=3.1.3]\n",


Though I kept /tmp/memo.txt in both control node and execution node still the 
error persist. Kindly suggest


Thanks

pd






--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAEuB3AqOxr3AbQ9k-vgCdJtgmLTm3ZvKBBD645mNW-F9F_p%2BeQ%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/D306ACD9-CF34-4763-B065-9E893A9819A9%40nist.gov.


[ansible-project] Dynamic Log creation for individual workflow

2023-11-26 Thread Karthick Kumar P
Hi Everyone,
  I'm using a highly available AAP2.4 cluster. Trying to create a 
dynamic custom log for each workflow.

Case Scenario:
1. One custom ee is mapped with 4 different workflows. log path is mapped 
to /Ansible_log/inf_worlflow/ansible.log.
2. Here I'm trying to find a way to use the same execution environment for 
all 4 workflows and my log needs to be sent to a different log path 
dynamically.
3. I tried to give shell env in the log path. but I couldn't pass the shell 
variable inside the container for the particular workflow execution. 
4. Tried to pass for job env but it taking for all the jobs. I'm looking 
for individual env for each workflow.


I required some guidance here.


-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/4aee9a6e-6933-42c7-b81e-57bc93158703n%40googlegroups.com.


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 sounds less like an ansible task and more like a git action or git 
runner job. Ansible natively has no idea what is in the git repo.

On Thu, Nov 16, 2023 at 7:47 AM Ashok Reddy 
mailto:ashokrd...@gmail.com>> wrote:
Hi,

I have been trying to implement the following:

If any file change in git lab repo, then only we need to deploy the file in 
servers.

How to write Ansible playbook?

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAKRLcHhXSrJSoAdd6toBHt9Bh8CsF%2B92T5Ga%3DTEvrzhwKQG9sw%40mail.gmail.com.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAEcFzYx_%3DoPyP9uYh0OwacTCW3E9OUNG9J%3DT6Uw3-K%2BRezaT4Q%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/E1543712-496E-40BB-AC75-A1AD9587F6E7%40nist.gov.


Re: [ansible-project] UNREACHABLE!

2023-11-13 Thread Prabhakar P
Ssh key folder permissions issue set for 700 for folder and authorized keys
644

On Mon, Nov 13, 2023 at 7:47 AM Василий Арутюнов 
wrote:

> Hello, pls help me understand this error; I've been trying to fix it for
> the second day and can't figure it out
>
> TASK [Gathering Facts]
> **
> fatal: [pixel-3xui]: UNREACHABLE! => {"changed": false, "msg": "Failed to
> connect to the host via ssh: root@193.84.2.###
> : Permission denied (publickey,password).",
> "unreachable": true}
>
> PLAY RECAP
> **
> pixel-3xui : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0
> ignored=0
>
> --
> 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 visit
> https://groups.google.com/d/msgid/ansible-project/128f0d12-959c-440d-97b7-7b9c087e3156n%40googlegroups.com
> 
> .
>

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/CALCdCunTgO0ySP7Wd%2BizybtsAP_OQjj9nPAYV%3DyWNukMyKbxbg%40mail.gmail.com.


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
Infrastructure Services, OISM
Mobile: 202.355.4123

On Oct 26, 2023, at 3:31 PM, Kathy L  wrote:

Walter - Unfortunately I can't provide the code as this is on a client's 
off-line network.  Todd, I'll look again at when I use the chrony tasks.

On Thursday, October 26, 2023 at 9:32:36 AM UTC-4 Todd Lewis wrote:
Hi Kathy,

Files, templates, plugins, etc. that live in various local roles aren't 
available to your playbook tasks until those roles are accessed, for example 
through the roles: playbook keyword or import_role or include_role.

>From your description, it appears that you've accessed your yum role but not 
>your chrony role at the point you tried to use your etc.chrony.conf.j2 
>template.
--
Todd


On 10/26/23 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, but the chrony playbook fails on copying a template. 
 The odd thing is, the error I get indicates ansible is looking in the yum 
module for chrony's template.  here is the specific error message;

Could not find or access chrony.conf.j2
Searched in:
 /work/roles/yum/templates/chrony.conf.j2
 /work/roles/yum/chrony.conf.j2
/work/roles/yum/tasks/chrony.conf.j2
   /work/templates/etc.chrony.conf.j2

Why is it searching in the yum role for a chrony template?  The template is in 
/work/roles/chrony/templates/chrony.conf.j2.


--
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 visit 
https://groups.google.com/d/msgid/ansible-project/efe73dbf-7f61-4a5e-88dc-97cfd22824c2n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/24DF9FBA-E183-4870-B808-FF3E7FC8EA5F%40nist.gov.


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, but the chrony playbook fails on copying a template. 
 The odd thing is, the error I get indicates ansible is looking in the yum 
module for chrony's template.  here is the specific error message;

Could not find or access chrony.conf.j2
Searched in:
 /work/roles/yum/templates/chrony.conf.j2
 /work/roles/yum/chrony.conf.j2
/work/roles/yum/tasks/chrony.conf.j2
   /work/templates/etc.chrony.conf.j2

Why is it searching in the yum role for a chrony template?  The template is in 
/work/roles/chrony/templates/chrony.conf.j2.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/299d557e-58a9-4807-a9e1-a874db4bd387n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/8F072F41-0D15-4DE4-9BA5-351029FFF85B%40nist.gov.


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 file.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Oct 20, 2023, at 6:26 AM, Sameer Modak  wrote:

Hello Team,

I just want to know why we have builtin for all modules in ansible earlier it 
was just module name

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/8ac74d5a-a341-49aa-bf17-69e3323f0ec1n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/156522B8-AFD3-4E3B-853F-47C7A67DED91%40nist.gov.


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, at 6:49 PM, Todd Lewis  wrote:

You could help us help you if you included some background.

Is the error you got associated with the "copy JSON" task?

How are you elevating privileges? There's no "become: true" on the plays; are 
you specifying "--become" or "-b" on the command line? Does it run as you, or 
are you using a different become user? Is "nfs" a group or an individual host?

It might help to show the whole command line, and the output of
  ansible-config dump --only-changed
could avoid us having to ask some follow-up questions, too.

On 10/12/23 5:26 PM, William Flow wrote:
So I have a template that runs a PB like"
---
- name: Get data on flex-fiber 9500
  hosts: flex-copper
  gather_facts: no

  tasks:
  - name: run show configuration on flex-copper FS 5800
# cisco.ios.ios_command:
#   commands: show interface
ansible.netcommon.cli_command:
  command: show version | json
register: myconfigs
- name: Show data on flex-copper FS 5800
  hosts: nfs
  gather_facts: no

  tasks:
  - name: display value of "myconfigs" variable
debug:
  msg: "{{ hostvars['flex-copper'].myconfigs }}"
  - name: copy JSON
copy:
  content: "{{ hostvars['flex-copper'].myconfigs | to_json(indent=4, 
sort_keys=True )}}"
  dest: "/nfs/html/switch_json/flex-copper-5800_data.json"
  owner: rtlogic
  group: rtlogic
  mode: '0644'
I tried with Cisco with the same error and I always fail with
 "msg": "failed to elevate privilege to enable mode, still at level [4] and 
prompt [b'\\nflex-c-tor-1# ']",
i have changed my creds for this many times really need some help here
Thanks
B
--
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 visit 
https://groups.google.com/d/msgid/ansible-project/be7db7a1-3f67-4fd8-ad9d-3d7b43e70bd4n%40googlegroups.com.


--
Todd

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/ef9b8734-c431-4a3a-970c-aff4a464c85e%40gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/BE357121-B6FC-4B58-9F57-027F31823298%40nist.gov.


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 from
127.0.0.1.

So to access in the 2nd play you need to go through hostvars:
{{hostvasr['server1']['reg_name']
--
--
Brian Coca

--
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 visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCACVha7f1zJc8ni3tG415F2EWiQDHZDyTVNnTZsvSvzgCzmgbSw%2540mail.gmail.com=05%7C01%7Cwalter.rowe%40nist.gov%7C8af8d8d876cf4490a1b808dbbaae4ad3%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638309029959489682%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=j7qzTtXfQ1g3uGSzohc4lw6cWSlGY3ySy6c67uEuia0%3D=0.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/1E11EF33-1F49-47AD-9DEF-14F156638169%40nist.gov.


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

On Sep 21, 2023, at 8:02 AM, Veera  wrote:

I have a 2 tasks in a playbook and from task1  I have  a variable collected 
from the register output as below.

- name: Playbook to collect the actual hostname
  hosts: server1
  become: yes
  tasks:
- name: collect the actual hostname
  shell: 'hostname'
  register: short_name

- name: collect the hostname for the next task
  set_fact:
reg_name: "{{ short_name.stdout_lines[-1].split('.')[1] }}"


- name: Playbook to test the new hostname collections
  hosts: 127.0.0.1
  become: yes
  tasks:
- name: print  the collected hostname
  debug:
msg: {{reg_name  }}

 collecting  the host's shortname using set_fact is  working .  However the 
data stored using set_fact in reg_name is  not carry to the next task.
Is there an option/module available to have the variable from one task to be 
made available to the next?



--
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 visit 
https://groups.google.com/d/msgid/ansible-project/e414a185-f743-4618-ab14-b4449dfecf6dn%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/FF9075A2-E4A7-4E55-9413-872AF345EAC1%40nist.gov.


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

   tasks:

 - debug: var=my_fact





 % ansible-playbook -i localhost, foo.yml


 PLAY [play 1] 
**


 TASK [set_fact] 


 ok: [localhost]


 PLAY [play 2] 
**


 TASK [debug] 
***

 ok: [localhost] => {

 "my_fact": "this is a fact"

 }


 PLAY RECAP 
*

 localhost  : ok=2changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0



Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Sep 21, 2023, at 8:02 AM, Veera  wrote:

I have a 2 tasks in a playbook and from task1  I have  a variable collected 
from the register output as below.

- name: Playbook to collect the actual hostname
  hosts: server1
  become: yes
  tasks:
- name: collect the actual hostname
  shell: 'hostname'
  register: short_name

- name: collect the hostname for the next task
  set_fact:
reg_name: "{{ short_name.stdout_lines[-1].split('.')[1] }}"


- name: Playbook to test the new hostname collections
  hosts: 127.0.0.1
  become: yes
  tasks:
- name: print  the collected hostname
  debug:
msg: {{reg_name  }}

 collecting  the host's shortname using set_fact is  working .  However the 
data stored using set_fact in reg_name is  not carry to the next task.
Is there an option/module available to have the variable from one task to be 
made available to the next?



--
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 visit 
https://groups.google.com/d/msgid/ansible-project/e414a185-f743-4618-ab14-b4449dfecf6dn%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/CB89830F-FF55-4DB7-99F4-49EEBD210F6D%40nist.gov.


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": [

{

"ansible_loop_var": "item",

"changed": false,

"failed": false,

"invocation": {

"module_args": {

"checksum_algorithm": "sha1",

"follow": false,

"get_attributes": true,

"get_checksum": true,

"get_md5": false,

"get_mime": true,

"path": "/opt/db/data"

}

},

"item": "/opt/db/data",

"stat": {

    "exists": false

}

}

],

"skipped": false

}

}


Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Sep 6, 2023, at 8:51 AM, Rowe, Walter P. (Fed)  wrote:

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 ownership is right
  ansible.builtin.debug:
msg: "owned by postgres"
  when: postgres.stat.pw_name == 'postgres'


OR


- name: Get stats of a file
ansible.builtin.stat:
path: "{{ item }}"
register: postgres
loop:
- /opt/db/data

- name: return ownership is right
ansible.builtin.debug:
msg: "{{ item.item }} owned by postgres"
loop: "{{ postgres.results }}"
when:
- item.stat.exists == true
- item.stat.pw_name is defined
- item.stat.pw_name == 'postgres'

- name: return ownership is not right
ansible.builtin.debug:
msg: "{{ item.item }} owned not by postgres"
loop: "{{ postgres.results }}"
when:
- item.stat.exists == true
- item.stat.pw_name is defined
- item.stat.pw_name != 'postgres'

- name: return does not exist
ansible.builtin.debug:
msg: "{{ item.item }} does not exist"
loop: "{{ postgres.results }}"
when:
- item.stat.exists == false


Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Sep 6, 2023, at 8:34 AM, dulhaver via Ansible Project 
 wrote:

I want to check for existence of a folder and also the right owner, group and 
mode.
When any of the conditions (exists, owner=postgres, group=postgres, mode=0755) 
does not meet requirements I want to stop and be notified of the reason.

I think I need stat for that (exists, isdir, gr_name, pw_name, mode)

As a first step I try to get the value of pg_name with debug, but can not 
figure out how to adress that value


- name: Get stats of a file
  ansible.builtin.stat:
path: "{{ item }}"
  register: postgres
  loop:
- /opt/db/data

- name: return ownership is right
  ansible.builtin.debug:
msg: "owned by postgres"
  when: postgres.stat.pw_name == 'postgres'



output

TASK [show content of 'postgres'] 

fatal: [dvzsn-rd5400.ref.eakte.rz-dvz.cn-mv.de]: FAILED! => {"msg": "The 
conditional check 'postgres.stat.pw_name == 'postgres'' failed. The error was: 
error while evaluating conditional (postgres.stat.pw_name == 'postgres'): 'dict 
object' has no attribute 'stat'. 'dict object' has no attribute 'stat'\n\nThe 
error appears to be in 
'/home/gwagner/repos/automation_postgres/playbooks/check_postgres_dir.yml': 
line 16, column 7, but may\nbe elsewhere in the file depending on the exact 
syntax problem.\n\nThe offending line appears to be:\n\n\n - name: show content 
of 'postgres'\n ^ here\n"}


what I am doing wrong?

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1292803683.374335.1694003663225%40office.mailbox.org<https://groups.google.com/d/msgid/ansible-project/1292803683.374335.1694003663225%40office.mailbox.org?utm_medium=email_source=footer>.


-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/B337B96D-A8BB-4EAF-A1A4-C089C775A003%40nist.gov.


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 ownership is right
  ansible.builtin.debug:
msg: "owned by postgres"
  when: postgres.stat.pw_name == 'postgres'


OR


- name: Get stats of a file
ansible.builtin.stat:
path: "{{ item }}"
register: postgres
loop:
- /opt/db/data

- name: return ownership is right
ansible.builtin.debug:
msg: "{{ item.item }} owned by postgres"
loop: "{{ postgres.results }}"
when:
- item.stat.exists == true
- item.stat.pw_name is defined
- item.stat.pw_name == 'postgres'

- name: return ownership is not right
ansible.builtin.debug:
msg: "{{ item.item }} owned not by postgres"
loop: "{{ postgres.results }}"
when:
- item.stat.exists == true
- item.stat.pw_name is defined
- item.stat.pw_name != 'postgres'

- name: return does not exist
ansible.builtin.debug:
msg: "{{ item.item }} does not exist"
loop: "{{ postgres.results }}"
when:
- item.stat.exists == false


Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Sep 6, 2023, at 8:34 AM, dulhaver via Ansible Project 
 wrote:

I want to check for existence of a folder and also the right owner, group and 
mode.
When any of the conditions (exists, owner=postgres, group=postgres, mode=0755) 
does not meet requirements I want to stop and be notified of the reason.

I think I need stat for that (exists, isdir, gr_name, pw_name, mode)

As a first step I try to get the value of pg_name with debug, but can not 
figure out how to adress that value


- name: Get stats of a file
  ansible.builtin.stat:
path: "{{ item }}"
  register: postgres
  loop:
- /opt/db/data

- name: return ownership is right
  ansible.builtin.debug:
msg: "owned by postgres"
  when: postgres.stat.pw_name == 'postgres'



output

TASK [show content of 'postgres'] 

fatal: [dvzsn-rd5400.ref.eakte.rz-dvz.cn-mv.de]: FAILED! => {"msg": "The 
conditional check 'postgres.stat.pw_name == 'postgres'' failed. The error was: 
error while evaluating conditional (postgres.stat.pw_name == 'postgres'): 'dict 
object' has no attribute 'stat'. 'dict object' has no attribute 'stat'\n\nThe 
error appears to be in 
'/home/gwagner/repos/automation_postgres/playbooks/check_postgres_dir.yml': 
line 16, column 7, but may\nbe elsewhere in the file depending on the exact 
syntax problem.\n\nThe offending line appears to be:\n\n\n - name: show content 
of 'postgres'\n ^ here\n"}


what I am doing wrong?

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/1292803683.374335.1694003663225%40office.mailbox.org.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/69BC3525-B55F-4FE1-9FBF-7D48166BFC0A%40nist.gov.


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

2023-09-05 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Make sure you read thoroughly the module document for each task so you don't 
miss any parameters.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Sep 5, 2023, at 9:47 AM, Kathy L  wrote:

ok, will do that.  Thanks!

On Tuesday, September 5, 2023 at 9:44:41 AM UTC-4 Richard Megginson wrote:
You could put the tasks that you want to run in the loop in a separate tasks 
file, then use include_tasks with with_sequence

On Tue, Sep 5, 2023 at 7:39 AM Kathy Lyons  wrote:
Thanks.  Any idea how I would then add these users to the system without using 
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 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 and passwords for the number of users the user has plugged in, 
using the with_sequence block.  I am getting the error message "with_sequence 
is not a valid attribute for a Block."  How to I get around this?

Code:

- name:  Block to generate x number of users & passwords
  block:
  - name: Generate user
set_fact:
   username: "{{ lookup('ansible.builtin.password', '/dev/null', 
chars=['ascii_letters', 'digits'] length = 12 ) }}"

  - name: Generate password
set_fact:
   passwd: "{{ lookup('ansible.builtin.password', '/dev/null', 
chars=['ascii_letters', 'digits'] length = 12 ) }}:

 with_sequence:  "count={{ num_users_to_add }}"

--
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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1c72e363-9a1c-4e3b-9768-5fae67d7b5een%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/1c72e363-9a1c-4e3b-9768-5fae67d7b5een%40googlegroups.com?utm_medium=email_source=footer>.


--
You received this message because you are subscribed to a topic in the Google 
Groups "Ansible Project" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/ansible-project/Cy006u7szBo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
ansible-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3C3CB63B-6456-4720-9C58-DC5DBDD4FF51%40nist.gov<https://groups.google.com/d/msgid/ansible-project/3C3CB63B-6456-4720-9C58-DC5DBDD4FF51%40nist.gov?utm_medium=email_source=footer>.

--
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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAK9%2BsMcP-5juw-W3AZUikVRdOpnM3vw2dXL9RVB14jBEjRhtnw%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAK9%2BsMcP-5juw-W3AZUikVRdOpnM3vw2dXL9RVB14jBEjRhtnw%40mail.gmail.com?utm_medium=email_source=footer>.

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cd98963b-16af-4953-b568-9f5fcd47a1b5n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/cd98963b-16af-4953-b568-9f5fcd47a1b5n%40googlegroups.com?utm_medium=email_source=footer>.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/29F1297B-F843-4B43-B86F-691F0FCC7D13%40nist.gov.


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 and passwords for the number of users the user has plugged in, 
using the with_sequence block.  I am getting the error message "with_sequence 
is not a valid attribute for a Block."  How to I get around this?

Code:

- name:  Block to generate x number of users & passwords
  block:
  - name: Generate user
set_fact:
   username: "{{ lookup('ansible.builtin.password', '/dev/null', 
chars=['ascii_letters', 'digits'] length = 12 ) }}"

  - name: Generate password
set_fact:
   passwd: "{{ lookup('ansible.builtin.password', '/dev/null', 
chars=['ascii_letters', 'digits'] length = 12 ) }}:

 with_sequence:  "count={{ num_users_to_add }}"

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/1c72e363-9a1c-4e3b-9768-5fae67d7b5een%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/3C3CB63B-6456-4720-9C58-DC5DBDD4FF51%40nist.gov.


Re: [ansible-project] Inventory file to csv

2023-09-02 Thread Prabhakar P
Still not yet started but thought of starting

On Sat, Sep 2, 2023 at 2:06 AM Dick Visser  wrote:

> Hii,
> What does your current playbook look like?
>
> On Sat, 2 Sept 2023 at 01:25, Prabhakar P  wrote:
>
>> Hi
>>
>> Any one  created a playbook for collecting the certificates from all
>> servers in use, which can write to csv or excel
>>
>> Any help appreciated
>>
>> Thanks
>>
>> --
>> 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 visit
>> https://groups.google.com/d/msgid/ansible-project/CALCdCukCEroPyVHsCZ8%3DUC4x%2B%2Bp%2BF2FVNeRmi0mv2TmDdEK7Ag%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CALCdCukCEroPyVHsCZ8%3DUC4x%2B%2Bp%2BF2FVNeRmi0mv2TmDdEK7Ag%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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 visit
> https://groups.google.com/d/msgid/ansible-project/CAF8BbLaAdYbeJGFoCRnTwdXNZs0hcjS0r0NOZKGNu7d3N2k9SA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAF8BbLaAdYbeJGFoCRnTwdXNZs0hcjS0r0NOZKGNu7d3N2k9SA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/CALCdCumTxPpJ9HHgD87nWL%3Dytvr0Yv_-UjRFKOhbpM5zCL_x2w%40mail.gmail.com.


[ansible-project] Inventory file to csv

2023-09-01 Thread Prabhakar P
Hi

Any one  created a playbook for collecting the certificates from all
servers in use, which can write to csv or excel

Any help appreciated

Thanks

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/CALCdCukCEroPyVHsCZ8%3DUC4x%2B%2Bp%2BF2FVNeRmi0mv2TmDdEK7Ag%40mail.gmail.com.


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 validate the SNOW change request with Ansible which are 
deploying through Ansible template.




Thanks

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/d5002b68-66c0-4db9-9f19-34d2b8261e34n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/2CA4F0CA-247C-46B4-8BD0-247BB6235C6C%40nist.gov.


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 command (df) to work when using a F5 module 
(bigip_command:) (which does use provider:).  However, the F5 modules do not 
support (AWK, GREP, SED, etc.) (which is a bummer), like (shell:) and 
(command:) do.  I may end up having to use (bigip_command:) to grab the disk 
space, and then use a separate Ansible (regex_search) task to filter for what I 
want, which is what I have done in the past (albeit this is an extra step).

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/FD30305E-7242-43EA-B6F9-E7D9930B3B6B%40nist.gov.


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 becase 'connection: local' forces using the 'local' connection
plugin, which means that instead of executing on the target it 'forks
locally' to execute the module.
Just remove it, 99% of the time you do not need to specify `connection`.

--
--
Brian Coca

--
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 visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCACVha7dZo6PgpVnymyO9trKRqU3YS6EoF9AoXxeR5-%252BDN9KGcQ%2540mail.gmail.com=05%7C01%7Cwalter.rowe%40nist.gov%7C9efc5d85b5954e48b10d08db9f2a4560%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638278776139822553%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=5V8CbvQmY8TYnDQ6%2BMLHGSb3XVELxUivqYvCFm0p4qc%3D=0.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/A37D9962-78E8-4B6A-A209-C3130AFE778E%40nist.gov.


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

fatal: [172.31.3.117]: FAILED! => {"msg": "The task includes an option with an 
undefined variable. The error was: 'herlit_semaphore' is undefined. 
'herlit_semaphore' is undefined\n\nThe error appears to be in 
'/etc/ansible/roles/create_admin_user/tasks/main.yml': line 13, column 3, but 
may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n- name:  semaphore\n  ^ here\n"}

This is my create_admin_user.yaml file in  the playbooks/users directory
- hosts: all
  gather_facts: yes
  become: yes
  become_user: root
  tasks:
- ansible.builtin.import_role:
name: create_admin_user

This is my main.yml in the vars directory
admin:
  - name: 'herlit_semaphore'
comment: 'Ultimate User'
uid: '1000'

  - name: 'semaphore'
comment: 'Semaphore App User'
uid: '1001'

This is my main.yml in the tasks directory
---
# tasks file for create_admin_user

- name: Add the user with a specific uid and a primary group of "admin"
  ansible.builtin.user:
name: "{{ herlit_semaphore.name }}"
comment: "{{ herlit_semaphore.comment }}"
uid: "{{ herlit_semaphore.uid }}"
state: present
group: admin
append: yes

- name: Add the user "semaphore" with a specific uid and a primary group of 
"admin"
  ansible.builtin.user:
name: "{{ semaphore.name }}"
comment: "{{ semaphore.comment }}"
uid: "{{ semaphore.uid }}"
state: present
group: admin
append: yes

Sorry for the long email. Any ideas about this error?
THanks
Hernan

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/269931b4-2003-41cf-8321-7e04ac730488n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/D16085FF-00C0-455C-9F8D-3708B15929A8%40nist.gov.


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:

- name: reboot setting

  debug: var=rebootSetting


Execution: note the first test does not provide an extra_var value for 
rebootSetting, while the second and third do provide one.



% ansible-playbook -i localhost, override.yaml


PLAY [test overriding playbook variable] 
***


TASK [reboot setting] 
**

ok: [localhost] => {

"rebootSetting": "ifRequired"

}


PLAY RECAP 
*

localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


% ansible-playbook -i localhost, override.yaml -e rebootSetting=Never


PLAY [test overriding playbook variable] 
***


TASK [reboot setting] 
**

ok: [localhost] => {

"rebootSetting": "Never"

}


PLAY RECAP 
*

localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


% ansible-playbook -i localhost, override.yaml -e rebootSetting=Always


PLAY [test overriding playbook variable] 
***


TASK [reboot setting] 
**

ok: [localhost] => {

"rebootSetting": "Always"

}


PLAY RECAP 
*

localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jul 26, 2023, at 8:39 AM, Veera  wrote:

Hi,

I have the below variable defined  in my playbook.
reboot_option:
- IfRequired
- Never
 - Always

while calling the same  variable from the playbook ,   the value "IfRequired'  
must be the default.
 "rebootSetting": "{{ reboot_option | default(Ifrequired) }}"

While executing the playbook without extra-vars reboot_option then by 
"ifrequired " need to the default,.
If the playbook is executed with -e "reboot_option=Never" or "Always"  then it 
should select the given option.

how to call the dictionary items with default as "Ifrequired"?
Or I have to declare  the variables in a different way ?






--
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 visit 
https://groups.google.com/d/msgid/ansible-project/90154402-8d8b-4041-8a9f-d1bbea023a6en%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/978B6FAD-7D86-4D08-BF6F-710D93FD19A5%40nist.gov.


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 servers parallel

Flow is
1) Copy the patch file from the central server to the destination server
2) Installation start parallel on multiple servers
3) once the installation is completed on Particular server I need report as well

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/5c7dcac3-5621-4c0c-9c2b-40806205e63dn%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/796BA870-0D6D-4C94-9070-4C5F68E3E78C%40nist.gov.


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:
name: "{{ pkgs }}"
state: present
  notify: "packages installed"

  handlers:
- name: start and enable ntp
  service:
name: ntp
state: started
enabled: true
  listen: "packages installed"
- name: update yum cache
  yum:
update_cache: yes
  listen: "packages installed"

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jul 20, 2023, at 11:08 AM, Saillesh Satam  wrote:

I am getting below error

FAILED! => {"changed": false, "msg": "The Python 2 yum module is needed for 
this module. If you require Python 3 support use the `dnf` Ansible module 
instead."}

Please help

---
  - hosts: all
become: true
vars:
 ansible_become_pass:
tasks:
- name: install ntp
  yum:
   name: ntp
   state: present
  notify:
 run update
- name: install vim
  yum:
name: vim
state: present
- name: start ntp service
  service:
name: ntp
state: started
enabled: true
handlers:
  - name: run update
yum:
   update_cache: yes

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/9108c006-ae4e-4e0b-948b-98fcd1d47436n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/EE7D0A7D-242C-4DD0-BB97-681B01C6CEBF%40nist.gov.


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 times out?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jul 23, 2023, at 10:03 AM, Rodrigo Reis  wrote:


Hello Everyone!

I trying to install ohmyzsh using ansible inside of a bigger yml file with a 
bunch of other sutff.
in hte ansible.builtin.expect block the goal is to anwser one  installation 
question but it waits for the timeou and display a huge error message.
Basically sucessfully install ohmyzsh but not awnser the installation question.

What you guys think, I'm doing wrong or have a better way to do it?

- name: Check if Oh My Zsh is installed
stat:
path: /home/rreis/.oh-my-zsh
register: ohmyzsh_installed

- name: Install Oh My Zsh
ansible.builtin.expect:
command: sh /home/rreis/install.sh
responses:
'Do you want to change your default shell to zsh? \[Y/n\]:': "Y\n"
timeout: 30
when: ohmyzsh_installed.stat.exists == false

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/3708b636-7b93-48e0-b119-65d24863bab7n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/27491DBB-9800-43C0-AAD9-B93FF7E1E6A9%40nist.gov.


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 don't want use  python  in the 
ansible  just  wanted to  know can we use  ansible loop and condition to 
determine the match  group_names?


Thanks
Deepak Kumar

On Thursday, July 20, 2023 at 5:48:51 AM UTC+5:30 Todd Lewis wrote:
Deepak,

Here's a playbook that demonstrates one way to do it. I tried lots of incorrect 
Jinja2 expressions that failed to achieve the final output before going back to 
iterative loops. It feels like the subelements lookup should be part of the 
solution, and that is shown below. However, it's actually more straightforward 
to do old-school looping over your original data to find the matching group 
names, and that's what the second set_fact task does.

If there is a way to express this with Jinja2 filters, it's unintuitive enough 
to me that I wouldn't want to maintain it anyway. I can read the loops and make 
some sense out of it, so that's the way I'd go.

[utoddl@tango ansible]$ cat test-subelements3.yml
---
- name: Demo set_fact over subelements
  hosts: localhost
  gather_facts: false
  vars:
vm_name: NED-DEV601-X
vm_drs_groups:
  - group_name: VM2-on-dev
vms:
  - deep-test
  - NED-DEV601-X
type: vm
  - group_name: VM2-on-uat
vms:
  - NED-TST601-X
type: vm
  - group_name: VM2-on-qa
vms:
  - deep-test
  - NED-DEV601-X
type: vm
  tasks:
- name: Show the list generated by the subelements lookup
  ansible.builtin.debug:
msg: "{{ lookup('subelements', vm_drs_groups, 'vms') }}"

- name: Iterate over subelements to gather the group_names for {{ vm_name }}
  ansible.builtin.set_fact:
match_vm_group: |
  {% set matching_groups = [] %}
  {% for vm_by_group_name in lookup('subelements', vm_drs_groups, 
'vms') %}
  {%   if vm_by_group_name[1] == vm_name %}
  {%  set _ = 
matching_groups.append(vm_by_group_name[0].group_name) %}
  {%   endif %}
  {% endfor %}{{ matching_groups }}

- name: Same thing without subelements
  ansible.builtin.set_fact:
match_vm_group: |
  {% set matching_groups = [] %}
  {% for vm_drs_group in vm_drs_groups %}
  {%   if vm_name in vm_drs_group.vms %}
  {%  set _ = matching_groups.append(vm_drs_group.group_name) %}
  {%   endif %}
  {% endfor %}{{ matching_groups }}

[utoddl@tango ansible]$ ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook 
test-subelements3.yml -v
Using /etc/ansible/ansible.cfg as config file

PLAY [Demo set_fact over subelements] 
***

TASK [Show the list generated by the subelements lookup] 

ok: [localhost] =>
  msg:
  - - group_name: VM2-on-dev
  type: vm
- deep-test
  - - group_name: VM2-on-dev
  type: vm
- NED-DEV601-X
  - - group_name: VM2-on-uat
  type: vm
- NED-TST601-X
  - - group_name: VM2-on-qa
  type: vm
- deep-test
  - - group_name: VM2-on-qa
  type: vm
- NED-DEV601-X

TASK [Iterate over subelements to gather the group_names for NED-DEV601-X] 
**
ok: [localhost] => changed=false
  ansible_facts:
match_vm_group:
- VM2-on-dev
- VM2-on-qa

TASK [Same thing without subelements] 
***
ok: [localhost] => changed=false
  ansible_facts:
match_vm_group:
- VM2-on-dev
- VM2-on-qa

PLAY RECAP 
**
localhost  : ok=3changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


Cheers,
--
Todd


On 7/19/23 7:31 AM, Deepak B K wrote:
Hi  Team,

I am trying to loop with a condition to match vm_name for all the  VM groups  I 
see that the loop stops at the first instance match . I need help how can I run 
the loop for all the  vm group name in the variable output  to match vm_name 
and extract  the match group names in the list

for example:

"vm_drs_groups": "“[{'group_name': VM2-on-dev', 'vms': ['deep-test', 
'NED-DEV601-X'], 'type': 'vm'}, {'group_name': 'VM2-on-uat', 'vms': 
['NED-TST601-X'], 'type': 'vm'}, {'group_name': VM2-on-qa', 'vms': 
['deep-test', 'NED-DEV601-X'], 'type': 'vm'}
}

If vm_name = 'NED-DEV601-X'  I have two match group name but  my  logic stops 
after the first match  how can I search for all the groups in the register 
variable.

- name: set fact specific VM group
  ansible.builtin.set_fact:
vm_drs_groups: “{{ group_info.drs_group_info[vcenter_env.cluster] | 
selectattr('type', '==', "vm" ) | list  }}”

- name: 

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

2023-07-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Silly me .. I should re-read my own code before pressing 'send'!

- name: validate filename lookup value
  assert:
that:
  - my_var in file_table.keys()
fail_msg: "File lookup key '{{ my_var }}' is not valid"
success_msg: "File lookup key '{{ my_var }}' is valid"

- name: do my file-based task
  debug:
msg: "File name is {{file_table[my_var] }}"

An added footnote .. keys() provides the dictionary keys in the lookup table as 
a list.

vars:
  file_table:
oracle: /apps/oracle/some/file/path
mysql: /apps/mysql/other/path
postgres: /apps/postgres/different/path

With this dictionary, file_table.keys() returns a list of [ mysql, oracle, 
postgres ].The assert task tests my_var against that list. If my_var isn't one 
of those values, the assert task fails. If my_var is one of those values, the 
debug task prints the corresponding 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 you didn't want a default value and instead wanted to gracefully handle an 
invalid value you could do something like this:

- name: validate filename lookup value
  assert:
that:
  - my_var in file_table.keys()
fail_msg: "File lookup key '{{ my_var }}' is not valid"
success_msg: "File lookup key '{{ my_var }}' is valid"

- name: do my file-based task
  debug:
msg: "File name is {{ artifacts[my_var] }}"

The "assert" task will fail the playbook if any of the tests fail (you can list 
more than one test).
If all the tests pass 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 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, David.

You could use a lookup table implemented as a simple dict. If you only need it 
in one task, you can define it in that task's vars section as I've done below, 
or farther "up" in host_vars, group_vars, etc., as long as it's defined 
somewhere. Here's a simple demo. I'm mapping colors to veggies, but you could 
map to file names or whatever. Be sure to handle the "missing" case.

[utoddl@tango ansible]$ cat select-artifact.yml
---
- name: Select artifact based on value
  hosts: localhost
  gather_facts: false
  tasks:
- name: Match an artifact based on a value
  ansible.builtin.debug:
msg: "Value {{ item }} matches artifact {{ artifacts[item] | 
default('!missing!') }}."
  vars:
artifacts:
  green: cucumbers
  red: tomatoes
  purple: cabage
  yellow: squash
  loop:
- red
- orange
- yellow
- green
- blue
- indigo
- violet
[utoddl@tango ansible]$ ansible-playbook select-artifact.yml

PLAY [Select artifact based on value] 
*

TASK [Match an artifact based on a value] 
*
ok: [localhost] => (item=red) => {
"msg": "Value red matches artifact tomatoes."
}
ok: [localhost] => (item=orange) => {
"msg": "Value orange matches artifact !missing!."
}
ok: [localhost] => (item=yellow) => {
"msg": "Value yellow matches artifact squash."
}
ok: [localhost] => (item=green) => {
"msg": "Value green matches artifact cucumbers."
}
ok: [localhost] => (item=blue) => {
"msg": "Value blue matches artifact !missing!."
}
ok: [localhost] => (item=indigo) => {
"msg": "Value indigo matches artifact !missing!."
}
ok: [localhost] => (item=violet) => {
"msg": "Value violet matches artifact !missing!."
}

PLAY RECAP 

localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


Cheers,
--
Todd

On 7/14/23 2:00 PM, David Nadelson wrote:
Hi All,
I'm a DBA learning to use ansible to automate.  I'm wondering if anyone can 
point me to docs on how to use ansible to select a file based on the value of a 
variable.   i.e.  if variable=x than choose 1.txt  if variable=y then choose 
2.txt.

Thanks,

David


--
You received this message because you are subscribed to the Google Groups 
&q

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

2023-07-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
If you didn't want a default value and instead wanted to gracefully handle an 
invalid value you could do something like this:

- name: validate filename lookup value
  assert:
that:
  - my_var in file_table.keys()
fail_msg: "File lookup key '{{ my_var }}' is not valid"
success_msg: "File lookup key '{{ my_var }}' is valid"

- name: do my file-based task
  debug:
msg: "File name is {{ artifacts[my_var] }}"

The "assert" task will fail the playbook if any of the tests fail (you can list 
more than one test).
If all the tests pass 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 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, David.

You could use a lookup table implemented as a simple dict. If you only need it 
in one task, you can define it in that task's vars section as I've done below, 
or farther "up" in host_vars, group_vars, etc., as long as it's defined 
somewhere. Here's a simple demo. I'm mapping colors to veggies, but you could 
map to file names or whatever. Be sure to handle the "missing" case.

[utoddl@tango ansible]$ cat select-artifact.yml
---
- name: Select artifact based on value
  hosts: localhost
  gather_facts: false
  tasks:
- name: Match an artifact based on a value
  ansible.builtin.debug:
msg: "Value {{ item }} matches artifact {{ artifacts[item] | 
default('!missing!') }}."
  vars:
artifacts:
  green: cucumbers
  red: tomatoes
  purple: cabage
  yellow: squash
  loop:
- red
- orange
- yellow
- green
- blue
- indigo
- violet
[utoddl@tango ansible]$ ansible-playbook select-artifact.yml

PLAY [Select artifact based on value] 
*

TASK [Match an artifact based on a value] 
*
ok: [localhost] => (item=red) => {
"msg": "Value red matches artifact tomatoes."
}
ok: [localhost] => (item=orange) => {
"msg": "Value orange matches artifact !missing!."
}
ok: [localhost] => (item=yellow) => {
"msg": "Value yellow matches artifact squash."
}
ok: [localhost] => (item=green) => {
"msg": "Value green matches artifact cucumbers."
}
ok: [localhost] => (item=blue) => {
"msg": "Value blue matches artifact !missing!."
}
ok: [localhost] => (item=indigo) => {
"msg": "Value indigo matches artifact !missing!."
}
ok: [localhost] => (item=violet) => {
"msg": "Value violet matches artifact !missing!."
}

PLAY RECAP 

localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


Cheers,
--
Todd

On 7/14/23 2:00 PM, David Nadelson wrote:
Hi All,
I'm a DBA learning to use ansible to automate.  I'm wondering if anyone can 
point me to docs on how to use ansible to select a file based on the value of a 
variable.   i.e.  if variable=x than choose 1.txt  if variable=y then choose 
2.txt.

Thanks,

David


--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2927e3e7-9dae-26e1-d51c-e42a3acd6607%40gmail.com<https://groups.google.com/d/msgid/ansible-project/2927e3e7-9dae-26e1-d51c-e42a3acd6607%40gmail.com?utm_medium=email_source=footer>.


--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9B6013A3-11F0-4D69-B9E6-56BAEC15EA40%40nist.gov<https://groups.google.com/d/msgid/ansible-project/9B6013A3-11F0-4D69-B9E6-56BAEC15EA40%40nist.gov?utm_medium=email_source=footer>.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/8EAC318D-AF10-40AE-8787-0710A5BD552F%40nist.gov.


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, David.

You could use a lookup table implemented as a simple dict. If you only need it 
in one task, you can define it in that task's vars section as I've done below, 
or farther "up" in host_vars, group_vars, etc., as long as it's defined 
somewhere. Here's a simple demo. I'm mapping colors to veggies, but you could 
map to file names or whatever. Be sure to handle the "missing" case.

[utoddl@tango ansible]$ cat select-artifact.yml
---
- name: Select artifact based on value
  hosts: localhost
  gather_facts: false
  tasks:
- name: Match an artifact based on a value
  ansible.builtin.debug:
msg: "Value {{ item }} matches artifact {{ artifacts[item] | 
default('!missing!') }}."
  vars:
artifacts:
  green: cucumbers
  red: tomatoes
  purple: cabage
  yellow: squash
  loop:
- red
- orange
- yellow
- green
- blue
- indigo
- violet
[utoddl@tango ansible]$ ansible-playbook select-artifact.yml

PLAY [Select artifact based on value] 
*

TASK [Match an artifact based on a value] 
*
ok: [localhost] => (item=red) => {
"msg": "Value red matches artifact tomatoes."
}
ok: [localhost] => (item=orange) => {
"msg": "Value orange matches artifact !missing!."
}
ok: [localhost] => (item=yellow) => {
"msg": "Value yellow matches artifact squash."
}
ok: [localhost] => (item=green) => {
"msg": "Value green matches artifact cucumbers."
}
ok: [localhost] => (item=blue) => {
"msg": "Value blue matches artifact !missing!."
}
ok: [localhost] => (item=indigo) => {
"msg": "Value indigo matches artifact !missing!."
}
ok: [localhost] => (item=violet) => {
"msg": "Value violet matches artifact !missing!."
}

PLAY RECAP 

localhost  : ok=1changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


Cheers,
--
Todd

On 7/14/23 2:00 PM, David Nadelson wrote:
Hi All,
I'm a DBA learning to use ansible to automate.  I'm wondering if anyone can 
point me to docs on how to use ansible to select a file based on the value of a 
variable.   i.e.  if variable=x than choose 1.txt  if variable=y then choose 
2.txt.

Thanks,

David


--
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 visit 
https://groups.google.com/d/msgid/ansible-project/2927e3e7-9dae-26e1-d51c-e42a3acd6607%40gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/9B6013A3-11F0-4D69-B9E6-56BAEC15EA40%40nist.gov.


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 "vm" are double quotes.

1) You can't have smart quotes. Change to normal double quotes.
2) You can't have double quotes inside double quotes. Change "vm" to 'vm'.

name: set fact specific VM group
  ansible.builtin.set_fact:
vm_groups: "{{ group_info.drs_group_info[vcenter_env.cluster] | 
selectattr('type', '==', 'vm' ) | list  }}"

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jul 14, 2023, at 8:32 AM, Deepak B K  wrote:

Hi  Todd,

Please find  output below  ansible task

- name: Show registered var group_info and vm_name
ansible.builtin.debug:
msg:
- "group_info: {{ group_info }}"
- "vm_name: {{ vm_name }}"


TASK [Show registered var group_info and vm_name] 
**
ok: [NED-TST1x] => {
"msg": [
"group_info: {'failed': False, 'drs_group_info': {'NED-Cluster': 
[{'group_name': 'NED-HOST001-HG', 'hosts': ['ned-host612-hyp'], 'type': 
'host'}, {'group_name': 'VM2-on-dev', 'vms': ['deep-test', 'NED-DEV601-X'], 
'type': 'vm'}, {'group_name': 'VM2-on-uat', 'vms': ['NED-TST601-X'], 'type': 
'vm'}]}, 'changed': False}",
"vm_name: NED-TST601-X"
]
}



Thanks & Regards
Deepak Kumar

On Fri, Jul 14, 2023 at 12:47 PM Deepak B K  wrote:
Hi Groups ,

I am trying to  parse the list variable but I am getting ansible unsafe text  I 
need to match the vm name and get the corresponding vm group from the 
registered variable vm_groups.
tasks:
- name: "Gather DRS info about given Cluster"
  community.vmware.vmware_drs_group_info:
hostname: "{{  vcenter.hostname }}"
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
validate_certs: "{{ vcenter.validate_certs }}"
cluster_name: "{{ vcenter_env.cluster }}"
  delegate_to: localhost
  register: group_info

 - name: set fact specific group_info VM groups
   ansible.builtin.set_fact:
  match_vm_group: "{{ item.drs_group_info[vcenter_env.cluster] | 
regex_search(vm_name) }}"
when: "{{ item.drs_group_info[vcenter_env.cluster] | regex_search( vm_name 
) }}"
loop: "{{ group_info  }}"

name: set fact specific VM group
  ansible.builtin.set_fact:
vm_groups: “{{ group_info.drs_group_info[vcenter_env.cluster] | 
selectattr('type', '==', "vm" ) | list  }}”

"vm_groups": "“[{'group_name': VM2-on-dev', 'vms': ['deep-test', 
'NED-DEV601-X'], 'type': 'vm'}, {'group_name': 'VM2-on-uat', 'vms': 
['NED-TST601-X'], 'type': 'vm'}
}

I appreciate  your quick help .

Thanks
Deepak

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/61ff8b55-dd13-4cd2-b718-11eb1fd28cb1n%40googlegroups.com.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAF%3DeWbLmw9m8qg%3DQ0Pu%2BMaajK1H3fmpCxYe-7_-AviOWTNu2sA%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/1587F975-D826-4DAF-8F4F-222E344F16EE%40nist.gov.


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 "group_info" and "vm_name":

- name: Show registered var group_info and vm_name
  ansible.builtin.debug:
msg:
  - "group_info: {{ group_info }}"
  - "vm_name: {{ vm_name }}"


It would be helpful to include the job log for the relevant section of your 
playbook as well. You say you are trying to parse "the list variable" but you 
don't say what that variable is or show what it contains. Please help us help 
you.

On 7/14/23 3:17 AM, Deepak B K wrote:
Hi Groups ,

I am trying to  parse the list variable but I am getting ansible unsafe text  I 
need to match the vm name and get the corresponding vm group from the 
registered variable vm_groups.
tasks:
- name: "Gather DRS info about given Cluster"
  community.vmware.vmware_drs_group_info:
hostname: "{{  vcenter.hostname }}"
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
validate_certs: "{{ vcenter.validate_certs }}"
cluster_name: "{{ vcenter_env.cluster }}"
  delegate_to: localhost
  register: group_info

 - name: set fact specific group_info VM groups
   ansible.builtin.set_fact:
  match_vm_group: "{{ item.drs_group_info[vcenter_env.cluster] | 
regex_search(vm_name) }}"
when: "{{ item.drs_group_info[vcenter_env.cluster] | regex_search( vm_name 
) }}"
loop: "{{ group_info  }}"

name: set fact specific VM group
  ansible.builtin.set_fact:
vm_groups: “{{ group_info.drs_group_info[vcenter_env.cluster] | 
selectattr('type', '==', "vm" ) | list  }}”

"vm_groups": "“[{'group_name': VM2-on-dev', 'vms': ['deep-test', 
'NED-DEV601-X'], 'type': 'vm'}, {'group_name': 'VM2-on-uat', 'vms': 
['NED-TST601-X'], 'type': 'vm'}
}

I appreciate  your quick help .

Thanks
Deepak


--
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 visit 
https://groups.google.com/d/msgid/ansible-project/08b16ee1-1087-4b0a-21f7-be65df5dc199%40gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/CE7B2EAC-2D67-4223-BC7D-61AB8B2E3B83%40nist.gov.


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, at 11:30 AM, John Petro  wrote:

Good Morning,
  I manage the building of some virtual machine templates using packer.  I am 
leveraging ansible as part of this, and when I am doing some cleanup after the 
setup is done to prepare for the conversion to template, and a couple of the 
options I need in yum/dnf, etc don't exist in the module don't exist.  So, to 
get around this, I am using the command module, but I get a warning that I 
should use the module, but that if I am doing it for a specific reason, I 
should use warn: false or set the option to ignore warnings in my ansible.cfg.  
Since I am using a "ansible_local" provisioner in packer, I don't use an 
ansible.cfg, so I was wondering if there is another way to accomplish the warn: 
false option since it has been removed in the more recent versions of ansible.

--John

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAPAjob92oJ2rXs8UnESjNJ4URE37WtO0XZ1P0O9Sbo980RQ5_A%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/52131541-D791-4DFE-B2A0-B5BA479DF444%40nist.gov.


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 things, does not mean it should, see this old
presentation where i show an example of 'file alteration monitoring'
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.slideshare.net%2Fbcoca%2Fansible-tips-=05%7C01%7Cwalter.rowe%40nist.gov%7Ce6f703ac677c43128bac08db77ef1afd%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638235641059517237%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=2W0aGHIvU2qZMcD2N6O%2B1t4dygx06rcDVHeP%2BjvrUCI%3D=0
 tricks  slide 15
(cowsay kitty mentions aide/osiris/tripwire).


--
--
Brian Coca

--
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 visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCACVha7cYusvntKFN8KuE1znVaAqn5rO-tpjzONpw%252BXONcmxkdA%2540mail.gmail.com=05%7C01%7Cwalter.rowe%40nist.gov%7Ce6f703ac677c43128bac08db77ef1afd%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638235641059517237%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=xyXKl1lGywXWqQOIMAIPWJBMWWQl0q6cOYkFILu7KEU%3D=0.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/8CFB4E06-3A9D-482D-8618-794E53FDF806%40nist.gov.


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 change. if it is missing the task will add it.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jun 28, 2023, at 10:55 AM, Kathy L  wrote:

I am checking to see if a cron job exists and if it doesn't, add it.  Because 
we use random times (for both hours and minutes) I cannot search for the entire 
line.  Here is what I have:

- name: UPDATE_WAZUH
  lineinfile:
path: /var/spool/cron/crontabs/root
regexp: "find /var/log/nginx/nginx_error.log"
state: present
 register: remove_nginx_logs

- name: UPDATE_WAZUH
  cron:
name: "empty nginx logs"
minute: "{{ 59|random }}"
hour: "{{ 23|random }}"
job: 'find /var/log/nginx/nginx_error.log -name "*.gz" -type f -mtime 
+15 -delete'
when: remove_wazuh_logs is defined

One of the errors I get is:

   line is required with state=present

When I try adding line to lineinfile like this:

- name: UPDATE_WAZUH
  lineinfile:
path: /var/spool/cron/crontabs/root
regexp: "find /var/log/nginx/nginx_error.log"
state: present
line: 'find /var/log/nginx/nginx_error.log -name "*.gz" -type f -mtime 
+15 -delete'
 register: remove_nginx_logs


It still fails.  How can I accomplish this?

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/52410dee-5afe-405d-94da-bcf0074d9fe4n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/CDE60797-936D-4613-9E85-1AD431C8F7EE%40nist.gov.


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 with our 
secure configuration baseline.

stop machine -> snapshot -> start machine -> patch -> reboot -> test -> 
snapshot -> secure config -> reboot

if patching fails we revert to the starting snapshot.
if secure config fails we revert to the post-test snapshot.

All of this is done via ansible automation platform.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jun 27, 2023, at 3:11 PM, John Petro  wrote:

Good Afternoon,
  I was wondering what you all are doing to manage configuration drift.  Are 
you having ansible  fix the drift, are you having it notify you of the drift, 
or are you doing something else.  At work, we are preparing to start having 
some conversations about what we want to do, and I thought this information 
from you all might be helpful in our journey.

Thanks for your time!!

---john

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAPAjob9NsjTGPNa_J8oeBbfZQOHjjqy7ELd6eHhodbHuTykkrQ%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/74E8295F-0895-4DF2-9CF2-1C363FD92C38%40nist.gov.


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.

 


BTW, if you're on 7.0.3+, cloud-init will be the way forward.

https://github.com/ansible-collections/community.vmware/pull/1574/

Kosala




On Fri, Jun 2, 2023 at 2:00 AM Tony Wong 
mailto:tdubb...@gmail.com>> wrote:
I want to create vm in vsphere from template and customize OS with 
customization spec

I am not sure how to apply a customization spec in ansible. any idea?

will something like this work

---
- hosts: localhost
  gather_facts: true
  connection: local
  vars_files:
- vcenter_creds.yml
- vars.yml
  #no_log: True
  tasks:
- name: Clone the VM template and customize
  vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: False
name: ansible-vm
template: "{{ template_name }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/Ansible-test"
cluster: "{{ cluster_name }}"
datastore: "{{ datastore_name }}"
networks:
  - name: VLAN-111
start_connected: yes
ip: "{{ vm_ip }}"
netmask: "{{ vm_netmask }}"
gateway: "{{ vm_gateway }}"
type: static
dns_servers: "{{ vm_dns_servers }}"
customization:
  hostname: "ansible-vm"
  dns_servers: "{{ vm_dns_servers }}"
state: poweredon
wait_for_ip_address: yes
  delegate_to: localhost


--
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 visit 
https://groups.google.com/d/msgid/ansible-project/b4729a2b-c090-46a2-82a8-006a1410b264n%40googlegroups.com.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAP7S5HYoq-fUL%3D8pbefDNNpkJ4MrQyotXbRg6GNP9ajQu97HuA%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/B83B01AC-5029-4490-B4A9-C73DCB2F6FCC%40nist.gov.


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 resolution, if the inventory_hostname is not 
DNS resolvable, try setting the ip or resolvable name in the ansilbe_host 
variable in that host's scope

--
Brian Coca

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7do3KXQL1LBs8uL%2BXOyFMMMhkE2WiTFVQtS3ZqVpBSJew%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/C4BE5A11-F7A6-4DDE-A897-09A6DDF7A074%40nist.gov.


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 please help me .


Thank You
Malek Sakir.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/89ffbe82-da04-4a61-93a9-f69414ddaa5an%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/5866A2BC-2781-4F54-8CB2-E025FABA8A57%40nist.gov.


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 Karthika  wrote:

I am getting error saying  I am using 2 var_files.
ERROR! failed at splitting arguments, either an unbalanced jinja2 block or 
quotes:

I also tried using include_vars which gave me same error, the values in these 2 
files need to be replace at diff locations at play book
some one please suggest what is the best way for this

 name: post call to get servergroup
  hosts: localhost
  become: true
  gather_facts: no
  tasks:
- name: set the facts per host
  set_fact:
access_token: "{{ hostvars.localhost.output.stdout }}" # this is the 
output of the above play
- name: Make a post call to get server details
  shell: |
cd /var/output/
curl --location --request GET "{{ serverlist }}" \--header 
'Authorization: Bearer "{{ access_token }}" > /var/output/"{{ item }}".json
jq -r '.[]|.serverData[].servers[]' "{{ item }}".json > 
/home/deploy-user/ansible/group_vars/"{{ item }}".yml
  # item and server list from one file and
register: data
- debug: msg="data , {{ repo }}" # this need to replaced from one var file
  loop:
- dev
- uat
- stg2


--
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 visit 
https://groups.google.com/d/msgid/ansible-project/41e35941-ac2e-48fe-9654-489f0c298c7dn%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/1A60AF1D-F9C4-4201-A7A6-5DFFBA77EB80%40nist.gov.


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 "map('trim')" this applying trim to each item in the list.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On May 18, 2023, at 2:48 PM, javed khan Siddque  
wrote:

The Input Which i passed


client_nfs_export_server_string_ui: '172.11.12.13, 127.0.0.1 , 
test123.kp.org'

there is some space before and after strings , which i require to trim and 
create a fresh list.


expected output

ok: [localhost] => {
"msg": [
"172.11.12.13",
"127.0.0.1",
"test123.kp.org",
"myserver.nndc.kp.org"
]
}
On Friday, May 19, 2023 at 12:14:08 AM UTC+5:30 javed khan Siddque wrote:
Hi Dick,

screenshots missed from my side.
here we go.


- name: "Converting String Input From - > client_nfs_export_server_string In A 
List After trim/split by comma -> client_nfs_export_server_list"
  ansible.builtin.set_fact:
server_list: "{{ item | trim }}"
client_nfs_export_server_list: "{{ client_nfs_export_server_list | 
default([]) + ['{{ server_list }}'] }}"
  loop: "{{ client_nfs_export_server_string_ui.split(',') }}"


- name: "Print client_nfs_export_server_list Once"
  ansible.builtin.debug:
msg: "{{ client_nfs_export_server_list }}"




ok: [cnpdcstore117.ctolab.kp.org] => 
(item=172.11.12.13) => {
528
"ansible_facts": {
529
"client_nfs_export_server_list": [
530
"{{ server_list }}"
531
],
532
"server_list": "172.11.12.13"
533
},
534
"ansible_loop_var": "item",
535
"changed": false,
536
"item": "172.11.12.13"
537
}
538
ok: [cnpdcstore117.ctolab.kp.org] => 
(item= 127.0.0.1 ) => {
539
"ansible_facts": {
540
"client_nfs_export_server_list": [
541
"172.11.12.13",
542
"{{ server_list }}"
543
],
544
"server_list": "127.0.0.1"
545
},
546
"ansible_loop_var": "item",
547
"changed": false,
548
"item": " 127.0.0.1 "
549
}
550
ok: [cnpdcstore117.ctolab.kp.org] => 
(item= test123.kp.org) => {
551
"ansible_facts": {
552
"client_nfs_export_server_list": [
553
"172.11.12.13",
554
"{{ server_list }}",
555
"{{ server_list }}"
556
],
557
"server_list": "test123.kp.org"
558
},
559
"ansible_loop_var": "item",
560
"changed": false,
561
"item": " test123.kp.org"
562
}
563




TASK [isilon_allocation_for_KPHC_environment : Print 
client_nfs_export_server_list Once] ***
00:01:11
565
task path: 
/tmp/bwrap_1228189_9zrqk15v/awx_1228189_9shz6zke/project/roles/xxx/tasks/main.yml:25
566
ok: [cnpdcstore117.ctolab.kp.org] => {
567
"msg": [
568
"172.11.12.13",
569
"{{ server_list }}",
570
"{{ server_list }}"
571
]
572
}
573
META: ending play
574

On Thursday, May 18, 2023 at 11:41:46 PM UTC+5:30 javed khan Siddque wrote:
Hi Team,

i am trying to convert a dummy String with list but skipping the first iteration
i am getting below output

"client_nfs_export_server_list":
[
"127.0.0.1",
"test123.kp.org",
"myserver.nndc.kp.org",
"{{ item | trim }}"
  ]

[X]

skipping the first iteration

[X]

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/59e7a996-a262-48aa-8932-402755133c70n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/F5A49809-608F-4C9C-8699-75EB15262DD1%40nist.gov.


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 connection, etc. The 
Windows host also has to be configured to accept WinRM.

https://docs.ansible.com/ansible/latest/os_guide/windows_setup.html

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On May 17, 2023, at 3:16 AM, malek sakir <2141.maleksa...@gmail.com> wrote:

Yes


On Wed, May 17, 2023, 12:37 PM Kosala Atapattu 
mailto:kosala.atapa...@gmail.com>> wrote:
Did you try the Ansible documentation?

Kosala




On Wed, May 17, 2023 at 6:34 PM malek sakir 
<2141.maleksa...@gmail.com> wrote:
Hello All,
Greeting of the day,

I am recently joining one company as junior DevOps engineer and
my company director give me task of ansible server and multiple windows host
connectivity lab.
Can anyone give me any documents or source regarding ansilbe-winrm 
Authentication methods.

Please help me.

Thanks and regards.


--
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 visit 
https://groups.google.com/d/msgid/ansible-project/c0b05111-002c-406b-8653-d387e8b2a661n%40googlegroups.com.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAP7S5Ha86X6-MFqdLkUbOQiihW5wwtejWkhDVwfyY7xcHLYTQg%40mail.gmail.com.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAKMnU-8vWn30jnv8puo2%2B96CFH4hi0W5kngmiir82sUDFMBRaw%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/22201E65-54EC-43AC-8050-0CEE086F5911%40nist.gov.


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  wrote:

I am trying to retrieve the version number of the installed executable. The 
complete path exists, the file has executable permissions, but I am 
encountering a 127 error, indicating that the file does not exist. Have I 
missed something?
Here is the code that I have:
- set_fact: remote_version: "{{ lookup('ansible.builtin.pipe', '/home/' + 
username + '/program/executable_file' + ' --version') }}"

The error that I am getting:
fatal: [xxx.yyy.zzz.fff]: FAILED! => {"msg": "An unhandled exception occurred 
while running the lookup plugin 'ansible.builtin.pipe'. Error was a , original message: 
lookup_plugin.pipe(/home/BreadPitt/program/executable --version) returned 127. 
lookup_plugin.pipe( /home/BreadPitt/program/executable   --version) returned 
127"}

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/808be77b-2253-48b2-9664-9ad16f8f3ab2n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/6A19AB81-81F8-4F95-A192-06A0C65DBAA2%40nist.gov.


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. My reply did not post. Maybe I replied to the user?

Anyway, my vote is to consider "roles" to be an enhancement. I have to be very 
certain I'm going to reuse the role before I will create it. If I'm not sure, 
then I call the creation of a role "gold plating" and unnecessary. So, I will 
create a straight playbook if there's any doubt in my mind about whether this 
is a reusable task. That does mean when the time comes to reuse the tasks that 
would be in the role, I need to refactor the original play to role-ify it, but 
that's pretty light work. I'd rather be certain I don't gold plate any plays 
than end up with a bunch of single-use roles cluttering my project.

On Wednesday, May 10, 2023 at 12:12:49 PM UTC-4 Rowe, Walter P. (Fed) wrote:
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

On May 10, 2023, at 11:38 AM, Dick Visser  wrote:

If you just want the quickest option then go for a playbook.
If you can spend some time on this then you could create a role that is meant 
for patching ESX hosts, and that includes helper tasks to handle the 
maintenance mode and the reboot.
Endless possibilities to do this, from quick and dirty to nicely parametrised


On Wed, 10 May 2023 at 17:29, Tony Wong  wrote:
I got a few tasks i need to do on esxi host

1. put in maintenace mode
2. copy vib from my laptop to the the host shared datastore
3. install the patch
esxcli softare vib install -d /path/xxx.zip

4. reboot the host
5. take it out of maintenance mode


do i create roles for these or single playbook?

--
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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c8b949a8-2024-43eb-9d46-61eead48e170n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/c8b949a8-2024-43eb-9d46-61eead48e170n%40googlegroups.com?utm_medium=email_source=footer>.
--
Sent from Gmail Mobile

--
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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLaiFAKhAOWbcrbZXgZkfg66pFNMkan8Z8gfL7oXWQBY9Q%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAF8BbLaiFAKhAOWbcrbZXgZkfg66pFNMkan8Z8gfL7oXWQBY9Q%40mail.gmail.com?utm_medium=email_source=footer>.


--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9436cbdd-ab27-46f8-9e1e-8415c2db802an%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/9436cbdd-ab27-46f8-9e1e-8415c2db802an%40googlegroups.com?utm_medium=email_source=footer>.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/E6A9B1F6-E466-4580-BB95-C18A2DDB944D%40nist.gov.


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

On May 10, 2023, at 11:38 AM, Dick Visser  wrote:

If you just want the quickest option then go for a playbook.
If you can spend some time on this then you could create a role that is meant 
for patching ESX hosts, and that includes helper tasks to handle the 
maintenance mode and the reboot.
Endless possibilities to do this, from quick and dirty to nicely parametrised


On Wed, 10 May 2023 at 17:29, Tony Wong 
mailto:tdubb...@gmail.com>> wrote:
I got a few tasks i need to do on esxi host

1. put in maintenace mode
2. copy vib from my laptop to the the host shared datastore
3. install the patch
esxcli softare vib install -d /path/xxx.zip

4. reboot the host
5. take it out of maintenance mode


do i create roles for these or single playbook?

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/c8b949a8-2024-43eb-9d46-61eead48e170n%40googlegroups.com.
--
Sent from Gmail Mobile

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLaiFAKhAOWbcrbZXgZkfg66pFNMkan8Z8gfL7oXWQBY9Q%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/E998E348-A6FB-49C1-B388-696AD8B3EABC%40nist.gov.


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 was corrected.


- name: insert logggin file in log4j protperties
  lineinfile:
path: '{{ item.path }}'
insertafter: 'log4j.appender.kafkaAppender.layout.ConversionPattern=*'
line: '{{ item.line }}'
  with_items:
- { path: '/etc/kafka/confluent-6.2.10/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxFileSize=512MB' }
- { path: '/etc/kafka/confluent-7.2.5/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxFileSize=512MB' }
- { path: '/etc/kafka/confluent-6.2.10/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxBackupIndex=10' }
- { path: '/etc/kafka/confluent-7.2.5/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxBackupIndex=10' }



Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On May 1, 2023, at 11:24 AM, Sameer Modak  wrote:

Code==>

- name: insert logggin file in log4j protperties
lineinfile:
  path: '{{ item.path }}'
  insertafter: 'log4j.appender.kafkaAppender.layout.ConversionPattern=*'
  line: '{{ item.line }}'
with_items:
- { path: '/etc/kafka/confluent-6.2.10/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxFileSize=512MB' }
- { path: '/etc/kafka/confluent-7.2.5/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxFileSize=512MB' }
- { path: '/etc/kafka/confluent-6.2.10/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxBackupIndex=10' }
- { path: '/etc/kafka/confluent-7.2.5/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxBackupIndex=10' }

ERROR==>>>
item={'path': '/etc/kafka/confluent-7.2.5/zookeeper/log4j.properties', 'line': 
'log4j.appender.kafkaAppender.MaxBackupIndex=10'}) => {"ansible_loop_var": 
"item", "changed": false, "item": {"line": 
"log4j.appender.kafkaAppender.MaxBackupIndex=10", "path": 
"/etc/kafka/confluent-7.2.5/zookeeper/log4j.properties"}, "msg": "Destination { 
item.path }} does not exist !", "rc": 257}

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/f34a22cb-eaee-41b0-9573-5c09dc7b9517n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/49A6C361-C852-423E-8D61-86EB166E0C85%40nist.gov.


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 content is a virtual machine template created from the source virtual 
machine, using the supplied create specification. The virtual machine template 
is stored in a newly created library item.

According to the documentation the 
vmware.vmware_rest.vcenter_vmtemplate_libraryitems
 module creates a library item in the content library. It does NOT create a new 
VM.

If you want to create a new VM I think you need to use the 
vmware.vmware_rest.vcenter_vm
 module with state 'clone' and source of the library item you want to use to 
create the new VM.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 20, 2023, at 4:03 AM, shane cummins  wrote:

Hi all after recently changing over from AWX to AAP and changing from the 
community.VMware collection to VMware.rest collection.
I am running into some issues when deploying I am using the module,
VMware.vmware_rest.content_library_item_info:
deploying the VM from a template in the content library,
I am able to deploy the VM from the template without any problems,
using the below playbook.
but the issue I have is the newly deployed VM keeps the name of the,
name of the template the VM was created from and does not change the name at 
guest level,
just changes on the label of the VM.


---
- name: Deploy a VM from a library "Linux_Templates"
  hosts: localhost
  gather_facts: yes

  vars:
hostname: "{{ lookup('env', 'VMWARE_HOST') }}" # vCenter 
Server hostname or IP address
username: "{{ lookup('env', 'VMWARE_USER') }}" # vCenter 
Server username
password: "{{ lookup('env', 'VMWARE_PASSWORD') }}" # vCenter 
Server password
vm_name: "{{new_name}}"# Name to 
give to the new VM
esxi_hostname: "esx node name"  #ESX node name
datastore: "datastore name"  # Name 
of the datastore to use
cluster_ID: "cluster name"   # Cluster 
name
folder_path: "folder path name"   # Name of 
the folder to place the new VM in
content_library: "content library id"
library_item: "item id"
AD_Domain: "domain name"   # Domain name
AD_Domain_alt: "alt domain name"   # 
Alternative domain name
sudo_users: "{{sudo_user_add}}"# Sudo users 
to add to vm


  tasks:

- name: get the list of items of the NFS library
  vmware.vmware_rest.content_library_item_info:
vcenter_hostname: "{{hostname}}"
vcenter_username: "{{username}}"
vcenter_password: "{{password}}"
library_id: "{{content_library}}"
library_item_id: "{{library_item}}"
  register: content_library_result

- name: Create a new VM based on the template
  vmware.vmware_rest.vcenter_vmtemplate_libraryitems:
vcenter_hostname: "{{hostname}}"
vcenter_username: "{{username}}"
vcenter_password: "{{password}}"
name: "{{vm_name}}"
vcenter_validate_certs: false
library: "{{content_library}}"
template_library_item: "{{library_item}}"
placement:
  cluster: "{{cluster_ID}}"
  folder:  "{{folder_path}}"
  #resource_pool:  "{{ lookup('vmware.vmware_rest.resource_pool_moid', 
'/my_dc/host/my_cluster/Resources')}}"
state: deploy
powered_on: True
  register: my_new_vm

- name: Pause for 1 minutes for server to boot up
  ansible.builtin.pause:
seconds: 30

also when using the community collection i was able to just also add a task you 
use bash shell,
after VM was deployed in the same playbook like below
- name: "Join the VM to the Domain"
  shell: |
 timeout 60s echo '{{vcenter_password}}' | sudo realm join --verbose 
exsample.COM -U 'user' --install=/ any help would be appreciated here

thanks
Shane


--
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 visit 

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.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 19, 2023, at 12:08 PM, John Welby  wrote:

---
- name: Create a cronjob to patch dev instances
  hosts: controller
  tasks:
- name: Schedule cron
  ansible.builtin.cron:
name: This cronjob is scheduled by Ansible
minute: "15"
hour: "12"
day: "*"
month: "*"
weekday: "3"
user: ec2-user
job: "/home/jwelby/ansible/sub-playbooks/ansible-playbook -i dev-hosts 
/home/jwelby/ansible/sub-playbooks/patching.yml"
state: present

crontab -l
   30 15 * * 3 /home/jwelby/ansible/sub-playbooks/patching.yaml

crond.service is active and running


Thanks!

John
On Wednesday, April 19, 2023 at 10:56:07 AM UTC-4 Will McDonald wrote:
More information would be helpful here.

1. Can you share your usage of ansible.builtin.cron?
2. Can you share the output of crontab -l for the user you're creating the cron 
job for/as, or the contents of /etc/crontab and/or /etc/cron.* ?
3. What's in your cronlog or systemd journal?
4. Obvious question but you do have a vixie cron variant installed and the 
appropriate services started?


On Wed, 19 Apr 2023 at 15:26, John Welby  wrote:
All,

Can a playbook be run by 'job', i.e. instead of a script.

I created a playbook that creates an entry in crontab, which it does 
successfully, but it does not execute the playbook I specified in job:

Thanks!

John

--
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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/34c698f9-be82-4e15-a486-3dddb5ebf3ecn%40googlegroups.com.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/d31172bf-3b3a-4749-882f-437e0401d345n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/DFE1A099-5F3B-4992-8993-CB0B03F7BD26%40nist.gov.


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 {{ ansible_os_family }} family
include_vars: "{{ loop_vars }}"
with_first_found:
- files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}-{{ ansible_distribution_version }}-family.yml"
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-family.yml"
- "{{ ansible_os_family }}-family.yml"
- "{{ ansible_system }}.yml"
- "defaults.yml"
paths:
- "vars"
loop_control:
loop_var: loop_vars

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 18, 2023, at 12:56 PM, Todd Lewis  wrote:

It seems to me that you're re-implementing variable precedence, but only for 
one variable.
What if, in group_vars/all, you define
   access_conf_src_file: access.conf
Then in your group_vars/whatever (for relevant groups of course, for which the 
other one isn't specific enough), you define
   access_conf_src_file: access.conf_AGwhatever
Finally, if you have any hosts which need even more specificity, you define in 
your host_vars/snowflake1.your.dom
   access_conf_src_file: access.conf_AHsnowflake
Then your copy task can just use "{{ access_conf_src_file }}" without invoking 
magical expressions.

Admittedly, the appeal of having the Right Thing happen just by creating the 
appropriately named src file is compelling. But it isn't the way the rest of 
your playbook variables work, so, hmm.

But next, I start to wonder if the right answer isn't to put all the logic and 
magic in a template and use ansible.builtin.template instead of 
ansible.builtin.copy.

On 4/18/23 11:39 AM, Michael DiDomenico wrote:

i managed to come up with this, but seems like it could be cleaner

---
- name: copy pam etc/security/access.conf file
  vars:
findme: |
  {%- set findme = [] -%}
  {%- for groupn in group_names -%}
{{- findme.append('files/' + item.src + '_AG' + groupn) -}}
  {%- endfor -%}
  {{- findme.append("files/"+item.src+"_AH"+ansible_hostname) -}}
  {{- findme.append("files/"+item.src) -}}
  {{- findme | list -}}
#  debug:
#msg: "{{ lookup('ansible.builtin.first_found', findme) }}"
  ansible.builtin.copy:
src: "{{ lookup('ansible.builtin.first_found', findme) }}"
dest: "/{{item.src}}"
owner: "{{item.owner}}"
group: "{{item.group}}"
mode: "{{item.mode}}"
  with_items:
- { src: "etc/security/access.conf", owner: "root", group: "root",
mode: "0644" }

On Tue, Apr 18, 2023 at 11:09 AM Michael DiDomenico
 wrote:


the below block is an example block i use in a few places to copy in
config files and select a host specific file if it exists.  not sure
if it's the best way, but it works for now.  what i'd like to do is
add in group selection as well.  ie if there's group file look for
that first

so above line 5 you could have
"files/{{ansible_local.baseos.ver}}/{{item.src}}_AG{{group}}"  but
clearly that wont work because there likely is more then on group
attached to a host.  so i need to try all the groups of a host and see
if there's a matching file.  the only way i can think to do it is to
create a second task that looks in the repository for a matching group
file and then registers a variable which i can include in the below
block above line 5

is there a better way?

  1 ---
  2 - name: copy pam etc/security/access.conf file
  3   vars:
  4 findme:
  5   - "files/{{item.src}}_AH{{ansible_hostname}}"
  6   - "files/{{item.src}}"
  7   ansible.builtin.copy:
  8 src: "{{ lookup('ansible.builtin.first_found', findme) }}"
  9 dest: "/{{item.src}}"
 10 owner: "{{item.owner}}"
 11 group: "{{item.group}}"
 12 mode: "{{item.mode}}"
 13   with_items:
 14 - { src: "etc/security/access.conf", owner: "root", group:
"root", mode: "0644" }



--
Todd

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/0900869f-a82c-d022-3303-e783f71eef9f%40gmail.com.

-- 
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 

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 Ansible Project 
 wrote:

I just tested and this also works.

- debug: msg="{{ [listb] | sum(start=lista) }}"

Walter

On Apr 18, 2023, at 11:01 AM, Michael DiDomenico  wrote:

agreed, brillant.  i'll give that a whirl, but it looks like exactly
what i'm after.  thanks

On Tue, Apr 18, 2023 at 10:40 AM Todd Lewis  wrote:

Also, by using the sum() filter:

[utoddl@tango ansible]$ cat foo.yml
---
- name: test lists
 become: false
 gather_facts: false
 hosts: localhost
 vars:
   list_12:
 - { one: 'str1', two: 'str2' }
   list_34:
 - { three: 'str3', four: 'str4' }
   list_56:
 - { five: 'str5', six: 'str6' }
 tasks:
   - debug: msg="[ {{ list_12, list_34, list_56 }} ]"
   - debug: msg="{{ [list_12, list_34, list_56] | sum(start=[]) }}"

[utoddl@tango ansible]$ ansible-playbook foo.yml

PLAY [test lists] 
***

TASK [debug] 

ok: [localhost] => {
   "msg": [
   [
   [
   {
   "one": "str1",
   "two": "str2"
   }
   ],
   [
   {
   "four": "str4",
   "three": "str3"
   }
   ],
   [
   {
   "five": "str5",
   "six": "str6"
   }
   ]
   ]
   ]
}

TASK [debug] 

ok: [localhost] => {
   "msg": [
   {
   "one": "str1",
   "two": "str2"
   },
   {
   "four": "str4",
   "three": "str3"
   },
   {
   "five": "str5",
   "six": "str6"
   }
   ]
}

PLAY RECAP 
**
localhost  : ok=2changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


On 4/18/23 9:10 AM, 'Rowe, Walter P. (Fed)' via Ansible Project wrote:


% cat foo.yml

---

- name: test lists

 become: false

 gather_facts: false

 hosts: localhost

 vars:

   lista:

 - { one: 'str1', two: 'str2' }


   listb:

 - { three: 'str3', four: 'str4' }

 tasks:

   - debug: var=lista

   - debug: var=listb

   - set_fact:

   listb: [ "{{ lista + listb }}" ]

   - debug: var=listb




% ansible-playbook foo.yml


PLAY [test lists] 
**


TASK [debug] 
***

ok: [localhost] => {

   "lista": [

   {

   "one": "str1",

   "two": "str2"

   }

   ]

}


TASK [debug] 
***

ok: [localhost] => {

   "listb": [

   {

   "four": "str4",

   "three": "str3"

   }

   ]

}


TASK [set_fact] 


ok: [localhost]


TASK [debug] 
***

ok: [localhost] => {

   "listb": [

   [

   {

   "one": "str1",

   "two": "str2"

   },

   {

   "four": "str4",

   "three": "str3"

   }

   ]

   ]

}


PLAY RECAP 
*

localhost  : ok=4changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0



Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 18, 2023, at 9:07 AM, Michael DiDomenico  wrote:

On Tue, 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
I just tested and this also works.

- debug: msg="{{ [listb] | sum(start=lista) }}"

Walter

On Apr 18, 2023, at 11:01 AM, Michael DiDomenico  wrote:

agreed, brillant.  i'll give that a whirl, but it looks like exactly
what i'm after.  thanks

On Tue, Apr 18, 2023 at 10:40 AM Todd Lewis  wrote:

Also, by using the sum() filter:

[utoddl@tango ansible]$ cat foo.yml
---
- name: test lists
 become: false
 gather_facts: false
 hosts: localhost
 vars:
   list_12:
 - { one: 'str1', two: 'str2' }
   list_34:
 - { three: 'str3', four: 'str4' }
   list_56:
 - { five: 'str5', six: 'str6' }
 tasks:
   - debug: msg="[ {{ list_12, list_34, list_56 }} ]"
   - debug: msg="{{ [list_12, list_34, list_56] | sum(start=[]) }}"

[utoddl@tango ansible]$ ansible-playbook foo.yml

PLAY [test lists] 
***

TASK [debug] 

ok: [localhost] => {
   "msg": [
   [
   [
   {
   "one": "str1",
   "two": "str2"
   }
   ],
   [
   {
   "four": "str4",
   "three": "str3"
   }
   ],
   [
   {
   "five": "str5",
   "six": "str6"
   }
   ]
   ]
   ]
}

TASK [debug] 

ok: [localhost] => {
   "msg": [
   {
   "one": "str1",
   "two": "str2"
   },
   {
   "four": "str4",
   "three": "str3"
   },
   {
   "five": "str5",
   "six": "str6"
   }
   ]
}

PLAY RECAP 
**
localhost  : ok=2changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


On 4/18/23 9:10 AM, 'Rowe, Walter P. (Fed)' via Ansible Project wrote:


% cat foo.yml

---

- name: test lists

 become: false

 gather_facts: false

 hosts: localhost

 vars:

   lista:

 - { one: 'str1', two: 'str2' }


   listb:

 - { three: 'str3', four: 'str4' }

 tasks:

   - debug: var=lista

   - debug: var=listb

   - set_fact:

   listb: [ "{{ lista + listb }}" ]

   - debug: var=listb




% ansible-playbook foo.yml


PLAY [test lists] 
**


TASK [debug] 
***

ok: [localhost] => {

   "lista": [

   {

   "one": "str1",

   "two": "str2"

   }

   ]

}


TASK [debug] 
***

ok: [localhost] => {

   "listb": [

   {

   "four": "str4",

   "three": "str3"

   }

   ]

}


TASK [set_fact] 


ok: [localhost]


TASK [debug] 
***

ok: [localhost] => {

   "listb": [

   [

   {

   "one": "str1",

   "two": "str2"

   },

   {

   "four": "str4",

   "three": "str3"

   }

   ]

   ]

}


PLAY RECAP 
*

localhost  : ok=4changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0



Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 18, 2023, at 9:07 AM, Michael DiDomenico  wrote:

On Tue, Apr 18, 2023 at 8:56 AM 'Rowe, Walter P. (Fed)' via Ansible
Project  wrote:


TASK [debug] 
***
ok: [localhost] => {
  "listb": [
  [
  {
  "one": "str1",
  "two": "str2"
  },
  {
  "one": "str1",
  "two": "str2"
  }
  ]
  ]
}


i got to this point as well in my testing, but the double list
expansio

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"
   mode: "0644"

Very clever use of first_found and your find_me vars definition.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 18, 2023, at 11:39 AM, Michael DiDomenico  wrote:

i managed to come up with this, but seems like it could be cleaner

---
- name: copy pam etc/security/access.conf file
 vars:
   findme: |
 {%- set findme = [] -%}
 {%- for groupn in group_names -%}
   {{- findme.append('files/' + item.src + '_AG' + groupn) -}}
 {%- endfor -%}
 {{- findme.append("files/"+item.src+"_AH"+ansible_hostname) -}}
 {{- findme.append("files/"+item.src) -}}
 {{- findme | list -}}
#  debug:
#msg: "{{ lookup('ansible.builtin.first_found', findme) }}"
 ansible.builtin.copy:
   src: "{{ lookup('ansible.builtin.first_found', findme) }}"
   dest: "/{{item.src}}"
   owner: "{{item.owner}}"
   group: "{{item.group}}"
   mode: "{{item.mode}}"
 with_items:
   - { src: "etc/security/access.conf", owner: "root", group: "root",
mode: "0644" }

On Tue, Apr 18, 2023 at 11:09 AM Michael DiDomenico
 wrote:

the below block is an example block i use in a few places to copy in
config files and select a host specific file if it exists.  not sure
if it's the best way, but it works for now.  what i'd like to do is
add in group selection as well.  ie if there's group file look for
that first

so above line 5 you could have
"files/{{ansible_local.baseos.ver}}/{{item.src}}_AG{{group}}"  but
clearly that wont work because there likely is more then on group
attached to a host.  so i need to try all the groups of a host and see
if there's a matching file.  the only way i can think to do it is to
create a second task that looks in the repository for a matching group
file and then registers a variable which i can include in the below
block above line 5

is there a better way?

 1 ---
 2 - name: copy pam etc/security/access.conf file
 3   vars:
 4 findme:
 5   - "files/{{item.src}}_AH{{ansible_hostname}}"
 6   - "files/{{item.src}}"
 7   ansible.builtin.copy:
 8 src: "{{ lookup('ansible.builtin.first_found', findme) }}"
 9 dest: "/{{item.src}}"
10 owner: "{{item.owner}}"
11 group: "{{item.group}}"
12 mode: "{{item.mode}}"
13   with_items:
14 - { src: "etc/security/access.conf", owner: "root", group:
"root", mode: "0644" }

--
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 visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCABOsP2P4XX2iNZODMfYSAJnhBZUJXFmhyVe2HigxfW-Rhd_Uog%2540mail.gmail.com=05%7C01%7Cwalter.rowe%40nist.gov%7Cf9881777aa77426a7b6d08db40231fee%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638174291823594841%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=xtnK%2FYpA8DapkwjWOnJ%2FufK4TLvXZCBop9%2FFIKSG2ng%3D=0.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/3FD261BA-8FBB-4730-AC47-12E1777B2CF4%40nist.gov.


Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Brilliant!

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 18, 2023, at 10:40 AM, Todd Lewis  wrote:

Also, by using the sum() filter:

[utoddl@tango ansible]$ cat foo.yml
---
- name: test lists
  become: false
  gather_facts: false
  hosts: localhost
  vars:
list_12:
  - { one: 'str1', two: 'str2' }
list_34:
  - { three: 'str3', four: 'str4' }
list_56:
  - { five: 'str5', six: 'str6' }
  tasks:
- debug: msg="[ {{ list_12, list_34, list_56 }} ]"
- debug: msg="{{ [list_12, list_34, list_56] | sum(start=[]) }}"

[utoddl@tango ansible]$ ansible-playbook foo.yml

PLAY [test lists] 
***

TASK [debug] 

ok: [localhost] => {
"msg": [
[
[
{
"one": "str1",
"two": "str2"
}
],
[
{
"four": "str4",
"three": "str3"
}
],
[
{
"five": "str5",
"six": "str6"
}
]
]
]
}

TASK [debug] 

ok: [localhost] => {
"msg": [
{
"one": "str1",
"two": "str2"
},
{
"four": "str4",
"three": "str3"
},
{
"five": "str5",
"six": "str6"
}
]
}

PLAY RECAP 
**
localhost  : ok=2changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


On 4/18/23 9:10 AM, 'Rowe, Walter P. (Fed)' via Ansible Project wrote:

% cat foo.yml
---
- name: test lists
  become: false
  gather_facts: false
  hosts: localhost
  vars:
lista:
  - { one: 'str1', two: 'str2' }

listb:
  - { three: 'str3', four: 'str4' }
  tasks:
- debug: var=lista
- debug: var=listb
- set_fact:
listb: [ "{{ lista + listb }}" ]

- debug: var=listb




% ansible-playbook foo.yml

PLAY [test lists] 
**

TASK [debug] 
***
ok: [localhost] => {
"lista": [
{
"one": "str1",
"two": "str2"
}
]
}

TASK [debug] 
***
ok: [localhost] => {
"listb": [
{
"four": "str4",
"three": "str3"
}
]
}

TASK [set_fact] 

ok: [localhost]

TASK [debug] 
***
ok: [localhost] => {
"listb": [
[
{
"one": "str1",
"two": "str2"
},
{
"four": "str4",
"three": "str3"
    }
]
]
}

PLAY RECAP 
*
localhost  : ok=4changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0


Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 18, 2023, at 9:07 AM, Michael DiDomenico 
<mailto:mdidomeni...@gmail.com> wrote:

On Tue, Apr 18, 2023 at 8:56 AM 'Rowe, Walter P. (Fed)' via Ansible
Project 
<mailto:ansible-project@googlegroups.com> 
wrote:

TASK [debug] 
***
ok: [localhost] => {
   "listb": [
   [
   {
   "one": "str1",
   "two": "str2"
   },
   {
   "one": "str1",
   "two": "str2"
   }
   ]
   ]
}

i got to this point as well in my testing, but the double list
expansion of list

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project

% cat foo.yml

---

- name: test lists

  become: false

  gather_facts: false

  hosts: localhost

  vars:

lista:

  - { one: 'str1', two: 'str2' }


listb:

  - { three: 'str3', four: 'str4' }

  tasks:

- debug: var=lista

- debug: var=listb

- set_fact:

listb: [ "{{ lista + listb }}" ]

- debug: var=listb




% ansible-playbook foo.yml


PLAY [test lists] 
**


TASK [debug] 
***

ok: [localhost] => {

"lista": [

{

"one": "str1",

"two": "str2"

}

]

}


TASK [debug] 
***

ok: [localhost] => {

"listb": [

{

"four": "str4",

"three": "str3"

}

]

}


TASK [set_fact] 


ok: [localhost]


TASK [debug] 
***

ok: [localhost] => {

"listb": [

[

{

"one": "str1",

"two": "str2"

},

{

"four": "str4",

"three": "str3"

}

]

]

}


PLAY RECAP 
*

localhost  : ok=4changed=0unreachable=0failed=0
skipped=0rescued=0    ignored=0


Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 18, 2023, at 9:07 AM, Michael DiDomenico  wrote:

On Tue, Apr 18, 2023 at 8:56 AM 'Rowe, Walter P. (Fed)' via Ansible
Project  wrote:

TASK [debug] 
***
ok: [localhost] => {
   "listb": [
   [
   {
   "one": "str1",
   "two": "str2"
   },
   {
   "one": "str1",
   "two": "str2"
   }
   ]
   ]
}

i got to this point as well in my testing, but the double list
expansion of listb is a problem.

--
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 visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCABOsP2O0HyQCBDnpJ5a2KK9RsUttdf6M0AgYcEFsZfGeJiMrww%2540mail.gmail.com=05%7C01%7Cwalter.rowe%40nist.gov%7C430da7c2101944514b5008db400de987%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638174200717509337%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=QplBJpgoUM2d3gQ9IZShI5aEwCPgx8A3bmw%2BFfIZyM8%3D=0.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/6C71BFC3-34D5-4E2A-90E9-1CDB56B3CCE6%40nist.gov.


Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
This isn't a double expansion of listb. lista and listb happen to have the same 
values. change one of them and run the playbook to prove it.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 18, 2023, at 9:07 AM, Michael DiDomenico  wrote:

On Tue, Apr 18, 2023 at 8:56 AM 'Rowe, Walter P. (Fed)' via Ansible
Project  wrote:

TASK [debug] 
***
ok: [localhost] => {
   "listb": [
   [
   {
   "one": "str1",
   "two": "str2"
   },
   {
   "one": "str1",
   "two": "str2"
   }
   ]
   ]
}

i got to this point as well in my testing, but the double list
expansion of listb is a problem.

--
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 visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCABOsP2O0HyQCBDnpJ5a2KK9RsUttdf6M0AgYcEFsZfGeJiMrww%2540mail.gmail.com=05%7C01%7Cwalter.rowe%40nist.gov%7C430da7c2101944514b5008db400de987%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638174200717509337%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=QplBJpgoUM2d3gQ9IZShI5aEwCPgx8A3bmw%2BFfIZyM8%3D=0.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/403537D8-0F35-46FD-870F-1D2C2B4E7830%40nist.gov.


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 }}" ]
- debug: var=listb


% ansible-playbook foo.yml

PLAY [test lists] 
**

TASK [debug] 
***
ok: [localhost] => {
"lista": [
{
"one": "str1",
"two": "str2"
}
]
}

TASK [debug] 
***
ok: [localhost] => {
"listb": [
{
"one": "str1",
"two": "str2"
}
]
}

TASK [set_fact] 

ok: [localhost]

TASK [debug] 
***
ok: [localhost] => {
"listb": [
[
{
"one": "str1",
"two": "str2"
},
{
"one": "str1",
"two": "str2"
}
]
]
}

PLAY RECAP 
*
localhost  : ok=4changed=0unreachable=0failed=0
skipped=0rescued=0ignored=0




Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 17, 2023, at 6:22 PM, Michael DiDomenico  wrote:

i want to do this, but i'm not getting exactly what i want

lista:
- { one: 'str1', two: 'str2' }

listb:
- "{{ lookup('vars','lista') }}"
- { one: 'str1', two: 'str2' }

the output i want is

listb:
{ one: 'str1', two: 'str2' },
{ one: 'str1', two: 'str2' }

but what i get is

listb:
[ { one: 'str1', two: 'str2' } ],
{ one: 'str1', two: 'str2' }

is there a way to merge the two lists?

--
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 visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCABOsP2N_wX5OuviQeXHzhTV%252BfGq%252BsOgHguTzy%253D%253Dh8v%253D5erx%252BHg%2540mail.gmail.com=05%7C01%7Cwalter.rowe%40nist.gov%7C11c761941c2b4b87c06e08db3f923bbe%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638173669526803891%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=F6cPYHsoFbMUJ8lWJKDuG2ym1o5eZLCrPId0qytWK3Y%3D=0.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/474B3AA4-F21D-45B6-97EE-962E0F842B11%40nist.gov.


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 global devops team.  You should be
articulate and confident in all things ansible and automation; capable
of taking center stage in meetings, presentations and tech
conferences.  The position will be based in London and/or Singapore.
I had hoped that some members of this group may like to discuss
further.  I can be reached using "JamesBTobin (at) Gmail (dot) Com".
Kind regards, James

--
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 visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCAMyPCTTHXOQFotCNNykme81owvK5S%252B6xUbmULjnSHniMEcUK7A%2540mail.gmail.com=05%7C01%7Cwalter.rowe%40nist.gov%7Cbb27c9c9d7654e46f26408db34f14e84%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638161983234992352%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=RHP3jkeN57SVf2Mk9xQ84nwtJeXQ9NaQNUWvTaPevPk%3D=0.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/824C2627-96AC-4642-B868-8655D3E64FFC%40nist.gov.


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, 2023, at 3:49 PM, Nico Kadel-Garcia  wrote:

On Sat, Mar 25, 2023 at 2:24 AM 'Neil Young' via Ansible Project
 wrote:

Sounds legit and works. But isn't "StrictHostKeyChecking=no" dangerous? (To not 
start a religious war here :))

There is an increased risk. The risk of needing to clean up from reset
host keys is also a significant one, and
tuning and picking which keys are and are without that filter is a
burden. Tools like ansible can, in theory,
provide just such tuning on a server-by-server and SSH-service by
SSH-service basis. But I've several times
encountered git server setups where the admin copied over the Host's
private keys, but not the exposed
git related SSH service's keys because he *did not understand the
distinction*, and it's seriously screwed up
working setups both for the Ansible server and the clients. Manually
insertinig the options into all the SSH
commands eliminates those checks on a case-by-case basis, but frankly,
I have a day job, not the
time to go implant the workaround into every developer's SSH command
line settings.

--
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 visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCAOCN9ryTGixQioeW2%252Badz2vKfzHJoVCnvDgZRZKyEzGJ4j%253DMyw%2540mail.gmail.com=05%7C01%7Cwalter.rowe%40nist.gov%7C1264b2416c574c97927d08db2d6a076f%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638153705643785382%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=EOumR4tipuYsITEDjq8p3KCCzOjdrhpfYSZpL7t1x2Y%3D=0.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/EB3345E0-E8F1-450D-9FDF-3AA49941D6F1%40nist.gov.


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 everyone,

I'm using the cat command with the command module to retrieve remote files 
content. With a loop within a find module I get filename and call a task, so 
like this:
[...]
- name: Read the content of all files
  command: /usr/bin/cat {{ _files_folder.path }}/{{ file_item }}.yaml
  register: file_contents
  become: true
  become_user: root
[...]
I receive a list of string (with stdout_lines) or a normal output (with stdout) 
but I need to have a list

You say you receive a list, and you also say you want to have a list.
So, what is the problem then...?

Also, you didn't say what you are actually trying to achieve. Do you need the 
file content?  To do what?
In any case you could use the slurp module instead of command+cat:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/slurp_module.html

If you have more context we may be able to help you better



because a the end I want to make a diff with another list of dict, like this:
ok: [10.10.10.1] => {
"daten_content": [
{
"agents": [
"aaa",
"bbb"
],
"community": {
"from xyzzy"
},
"disableDimensions": true,
"Dimensions": {
"HostGroup": "abc",
"Type": "role",
"env": "TEST"
},
"fields": [
[...]
Unfortunately I cannot retrieve what I need with a split or to pipe in list.
As anyone an idea how to do that or using another module?


--
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 visit 
https://groups.google.com/d/msgid/ansible-project/d14aa8a7-fd9b-49f1-967e-cdeb38d3a506n%40googlegroups.com.
--
Sent from Gmail Mobile

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLYb2nGLxwcHamLCB5dqbBo469su5BWRE7%2B4HdU_o%3Dohow%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/E709998A-F1CF-468C-97EF-280730F628D1%40nist.gov.


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)? How to handle this prompt in 
ansible playbook task for aruba switches.
Thanks in advance.

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/c82f911b-c48c-4bae-ba6c-054e970fedcbn%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/63EF8972-FAAB-4DB6-BC02-9740084DEC10%40nist.gov.


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 structure of a Ansible role has the directories 
/default, /handlers, /meta, /tasks, /templates, /vars and /tests. I have basic 
question of the directory /tests in Ansible roles, but I can’t find the 
answers. Can you let me know what is the purpose this /tests directory? Is it 
for testing funtional tasks? Is it possible for Ansible to automatically find 
yml files in /tests from /tasks/main.yml using include_tasks method?

Thank you for your answer.

Kind regards,
Alex Pham

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/CAH6wOdM%2BddHr0f6wzDDM9HOimsT2f8SNimRxE%3DnRvv0RT6ZMPw%40mail.gmail.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/8E4CCE36-85E3-4C54-9291-7F3117DA6898%40nist.gov.


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 12:11 PM, Shawn Singh  wrote:

I have a service principal for authentication.

Based on this bullet:

  *
To authenticate via service principal, pass subscription_id, client_id, secret 
and tenant or set environment variables AZURE_SUBSCRIPTION_ID, AZURE_CLIENT_ID, 
AZURE_SECRET and AZURE_TENANT.

My takeaway is that I need to supply the subscription_id, client_id, tenant, 
and secret to tell Ansible that I want to authenticate using service principal.

Since the module accepts subscription_id, client_id, tenant, and secret, I'm 
passing the values to the module, figuring the module will attempt to perform 
authentication using my service principal.

I'm not getting an authentication failed type of message, so it seems that the 
module isn't using the values I'm supplying.
To test this out, I tried to set auth_source to "credential_file", as I've got 
the parameters required for service principal authentication stored in the 
default location (~/.azure/credentials); however, it fails the same way, so my 
guess is the module needs something so that when the constructor gets called 
... it can create the object; however, I don't see what I'm missing.

Thanks,

Shawn
On Wednesday, March 15, 2023 at 11:04:23 AM UTC-4 Rowe, Walter P. (Fed) wrote:

TypeError: ResourceManagementClient.__init__() missing 1 required positional 
argument: 'credential'.

What kind of authentication have you configured?

https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_resourcegroup_info_module.html#ansible-collections-azure-azcollection-azure-rm-resourcegroup-info-module<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.ansible.com%2Fansible%2Flatest%2Fcollections%2Fazure%2Fazcollection%2Fazure_rm_resourcegroup_info_module.html%23ansible-collections-azure-azcollection-azure-rm-resourcegroup-info-module=05%7C01%7Cwalter.rowe%40nist.gov%7C1c26f1c913e84790886a08db256ff4c3%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638144935000756704%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=%2Bc4%2B6g4dXnuF9pmJXgOiQ8QUqUwfuY7JW9mK7mQht10%3D=0>

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Mar 15, 2023, at 10:53 AM, Shawn Singh  wrote:

Hello,

I have a playbook where I am calling my az commands via the command module.
It works as expected.
I'm trying to convert it to PoSH (different thread) and as I'm seeing some 
issues there, falling back to using specific Azure Modules.

When I execute the following playbook, it fails.

My intent is just to check for the existence of a resource group, 
authenticating using service principal.

I've got more int he original playbook; however, trying to start small, so I've 
only coded a couple tasks.

# get the subscription_id, client_id, tenant, secret

- name: read secret

  include_vars:

file: ../files/spsecret

  no_log: true

# check if resource group exists, pass in the args retrieved in previous step 
for authentication

- name: check if the rg already exists

  azure.azcollection.azure_rm_resourcegroup_info:

name: "np-{{ custom_name }}-rg-east"

subscription_id: "{{ sub_id }}"

client_id: "{{ sp }}"

secret: "{{ secret }}"

tenant: "{{ tenant }}"

  register: rg_exists

The full traceback is:

Traceback (most recent call last):

  File 
"/Users/j8683/.ansible/tmp/ansible-tmp-1678891419.194826-50522-78867749364726/AnsiballZ_azure_rm_resourcegroup_info.py",
 line 107, in 

_ansiballz_main()

  File 
"/Users/j8683/.ansible/tmp/ansible-tmp-1678891419.194826-50522-78867749364726/AnsiballZ_azure_rm_resourcegroup_info.py",
 line 99, in _ansiballz_main

invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)

  File 
"/Users/j8683/.ansible/tmp/ansible-tmp-1678891419.194826-50522-78867749364726/AnsiballZ_azure_rm_resourcegroup_info.py",
 line 47, in invoke_module


runpy.run_module(mod_name='ansible_collections.azure.azcollection.plugins.modules.azure_rm_resourcegroup_info',
 
init_globals=dict(_module_fqn='ansible_collections.azure.azcollection.plugins.modules.azure_rm_resourcegroup_info',
 _modlib_path=modlib_path),

  File 
"/opt/homebrew/Cellar/pyt...@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py",
 line 224, in run_module

return _run_module_code(code, init_globals, run_name, mod_spec)

  File 
"/opt/homebrew/Cellar/pyt...@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py",
 line 96, in _run_module_code

_run_code(code, mod_glo

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?

https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_resourcegroup_info_module.html#ansible-collections-azure-azcollection-azure-rm-resourcegroup-info-module

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Mar 15, 2023, at 10:53 AM, Shawn Singh  wrote:

Hello,

I have a playbook where I am calling my az commands via the command module.
It works as expected.
I'm trying to convert it to PoSH (different thread) and as I'm seeing some 
issues there, falling back to using specific Azure Modules.

When I execute the following playbook, it fails.

My intent is just to check for the existence of a resource group, 
authenticating using service principal.

I've got more int he original playbook; however, trying to start small, so I've 
only coded a couple tasks.

# get the subscription_id, client_id, tenant, secret

- name: read secret

  include_vars:

file: ../files/spsecret

  no_log: true

# check if resource group exists, pass in the args retrieved in previous step 
for authentication

- name: check if the rg already exists

  azure.azcollection.azure_rm_resourcegroup_info:

name: "np-{{ custom_name }}-rg-east"

subscription_id: "{{ sub_id }}"

client_id: "{{ sp }}"

secret: "{{ secret }}"

tenant: "{{ tenant }}"

  register: rg_exists

The full traceback is:

Traceback (most recent call last):

  File 
"/Users/j8683/.ansible/tmp/ansible-tmp-1678891419.194826-50522-78867749364726/AnsiballZ_azure_rm_resourcegroup_info.py",
 line 107, in 

_ansiballz_main()

  File 
"/Users/j8683/.ansible/tmp/ansible-tmp-1678891419.194826-50522-78867749364726/AnsiballZ_azure_rm_resourcegroup_info.py",
 line 99, in _ansiballz_main

invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)

  File 
"/Users/j8683/.ansible/tmp/ansible-tmp-1678891419.194826-50522-78867749364726/AnsiballZ_azure_rm_resourcegroup_info.py",
 line 47, in invoke_module


runpy.run_module(mod_name='ansible_collections.azure.azcollection.plugins.modules.azure_rm_resourcegroup_info',
 
init_globals=dict(_module_fqn='ansible_collections.azure.azcollection.plugins.modules.azure_rm_resourcegroup_info',
 _modlib_path=modlib_path),

  File 
"/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py",
 line 224, in run_module

return _run_module_code(code, init_globals, run_name, mod_spec)

  File 
"/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py",
 line 96, in _run_module_code

_run_code(code, mod_globals, init_globals,

  File 
"/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py",
 line 86, in _run_code

exec(code, run_globals)

  File 
"/var/folders/51/76dtk91x4wq1lgdndd_ll604gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py",
 line 235, in 

  File 
"/var/folders/51/76dtk91x4wq1lgdndd_ll604gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py",
 line 231, in main

  File 
"/var/folders/51/76dtk91x4wq1lgdndd_ll604gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py",
 line 160, in __init__

  File 
"/var/folders/51/76dtk91x4wq1lgdndd_ll604gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py",
 line 472, in __init__

  File 
"/var/folders/51/76dtk91x4wq1lgdndd_ll604gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py",
 line 174, in exec_module

  File 
"/var/folders/51/76dtk91x4wq1lgdndd_ll604gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py",
 line 194, in get_item

  File 

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 discussion: Ansible powershell module to be run on remote 
powershell on Linux machine. 
(https://groups.google.com/g/ansible-project/c/YZzYNEevzro)

Where Matt suggests:
That it [the module] is meant to be used with a Windows machine / over WinRM:


Matt Davis
unread,
Oct 21, 2016, 1:24:06 PM



to Ansible Project
Some aspects of Ansible's Powershell support are currently built under the 
assumption that it would only ever run on Windows / over WinRM. There are a few 
things that would need to be moved around in order to allow "real" Ansible 
Powershell modules to work on Linux. By "real", I mean so that the module 
generation stuff works correctly whether the WinRM connection plugin runs it or 
something else, and that you can use our Powershell module API.

So maybe that's my issue... ie not meant to run against Azure...


On Tuesday, March 14, 2023 at 3:28:04 PM UTC-4 Shawn Singh wrote:
I'm trying to use Powershell from Ansible.

This is the code:


- name: Log into Azure

  ansible.windows.win_powershell:

script: |

  [CmdletBinding()]

  param (

[String]

$TenantID,


[String]

$AccountID,


[SecureString]

$Secret

  )

  Connect-AzAccount -ServicePrincipal -TenantId $TenantID -Credential 
$(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 
$AccountID, $Secret)

parameters:

  TenantID: "{{ tenant }}"

  AccountID: "{{ sp }}"

  Secret: "{{ secret }}"

The Connect-AzAccount command works, when executed from my machine (running OS 
X) under pwsh; however, it blows up pretty ugly when executed using 
ansible-playbook...


fatal: [localhost]: FAILED! => {

"changed": false,

"module_stderr": "\u001b[31;1mParserError: 
\u001b[0m/Users/j8683/.ansible/tmp/ansible-tmp-1678819559.972683-82400-269117048488035/AnsiballZ_win_powershell.ps1:159\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1mLine
 |\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1m\u001b[36;1m 159 | \u001b[0m 
\u001b[36;1m\u\u001b[0m\u\u\u{\"module_entry\": 
\"IyFwb3dlcnNoZWxsCgojIENvcHlyaWdodDogKGMpIDIwMjE 
…\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[0m\u001b[36;1m
 | \u001b[31;1m 
~\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[31;1m\u001b[31;1m\u001b[36;1m
 | \u001b[31;1munexpected token '\u', expected 'begin', 'process', 
'end', 'clean', 
or\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[31;1m\u001b[31;1m\u001b[36;1m\u001b[31;1m\u001b[36;1m
 | \u001b[31;1m'dynamicparam'.\u001b[0m\n",

"module_stdout": "",

"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",

"rc": 1


}

Any ideas on what the win_powershell module might not like?

This is the ansible version I'm using:

ansible [core 2.14.0]

  python version = 3.9.6 (default, Sep 26 2022, 11:37:49) [Clang 14.0.0 
(clang-1400.0.29.202)] (/Library/Developer/CommandLineTools/usr/bin/python3)


  jinja version = 3.1.2


Thanks,

Shawn

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/f3a8ab7d-ca56-44dd-a783-f54d5b816246n%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/C0FC9ADA-AEBA-4D3E-8838-7B3A3258842C%40nist.gov.


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

2023-03-13 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
- name: look for backup files

  find:

paths: /tmp

recurse: false

file_type: 'file'

patterns: '^{{ item.filename }}\.[0-9]{6}.*$'

use_regex: true

  loop: ['backup']

  register: found


- name: get list of files

  set_fact:

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, 'Rowe, Walter P. (Fed)' via Ansible Project 
 wrote:

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 ansible find module.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Mar 13, 2023, at 12:39 PM, Hiero-nymo  wrote:

Hi everyone,

I've tried to using a variable in find module by pattern by it doesn't seems to 
work. Here's below a example. I also looked at another solution with set_facts 
but I doesn't run too.
I want to list all the backup files in a directory. The files have a timestamp 
and it's filename will be defined by variable.
Does anyone have an idea how should I proceed? or in which way?

Thanks in advance for your help

Here's the variables:
---
file:
  - filename: backup
state: present
[...]

Here's the task:
---
[...]
find:
  paths: /tmp
  recurse: false
  file_type_ file
  patterns: '^{{ item.filename }}\.[0-9]{6}.*$'
  use_regex: yes
loop: {{ file }}

--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3419395b-36b0-4195-9278-de959fa763can%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F3419395b-36b0-4195-9278-de959fa763can%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter=05%7C01%7Cwalter.rowe%40nist.gov%7Cfa441b724f7344dd4f5308db23e60f14%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638143243221107121%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=B7MfItZ589Vi8qf9375GywGYBVTJyQc5n4u7Unvcg%2Bw%3D=0>.


--
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<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7E9B8E33-5171-4B7B-80D0-8AAEEA6A7E44%40nist.gov<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F7E9B8E33-5171-4B7B-80D0-8AAEEA6A7E44%2540nist.gov%3Futm_medium%3Demail%26utm_source%3Dfooter=05%7C01%7Cwalter.rowe%40nist.gov%7Cfa441b724f7344dd4f5308db23e60f14%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638143243221107121%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=Y%2BYq%2BehKuEBAHv6VpE0x0rZgwffq353SjFpD3j%2B8f%2Fk%3D=0>.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/D7179F38-74CE-4A16-B296-60874B87A5AF%40nist.gov.


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 ansible find module.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Mar 13, 2023, at 12:39 PM, Hiero-nymo  wrote:

Hi everyone,

I've tried to using a variable in find module by pattern by it doesn't seems to 
work. Here's below a example. I also looked at another solution with set_facts 
but I doesn't run too.
I want to list all the backup files in a directory. The files have a timestamp 
and it's filename will be defined by variable.
Does anyone have an idea how should I proceed? or in which way?

Thanks in advance for your help

Here's the variables:
---
file:
  - filename: backup
state: present
[...]

Here's the task:
---
[...]
find:
  paths: /tmp
  recurse: false
  file_type_ file
  patterns: '^{{ item.filename }}\.[0-9]{6}.*$'
  use_regex: yes
loop: {{ file }}

--
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 visit 
https://groups.google.com/d/msgid/ansible-project/3419395b-36b0-4195-9278-de959fa763can%40googlegroups.com.

-- 
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 visit 
https://groups.google.com/d/msgid/ansible-project/7E9B8E33-5171-4B7B-80D0-8AAEEA6A7E44%40nist.gov.


  1   2   3   4   5   >