Re: [ansible-project] Re: Issue about defining variable within the task does not work

2024-01-15 Thread ricardo barbosa
Thanks for the tip Evan :)

On Sat, Jan 13, 2024 at 1:25 PM Evan Hisey  wrote:

> Ricardo-
>  I would also recommend changing how you are sending the json to the
> playbook. I have done this a lot in AWS and found it is much cleaner to
> either A) use a variable group file, or B) pass it via a parameter file.
> Both methods help avoid some of what Todd is referring to.
>
> On Sat, Jan 13, 2024 at 10:53 AM Todd Lewis  wrote:
>
>> It's even stranger than that (until you realize what's going on).
>> Rather than commenting out the "ansible_ssh_user:" line, just misspell
>> the variable, like "ansible_ssh_userx". It'll work then, too — but with
>> the wrong user of course.
>>
>> What you're running into is a combination of things: set_fact,
>> delegate_to, and the bit you didn't show, which is your playbook's "
>> hosts:" line and/or your command's "--limit" specification. Also the
>> "special variable" function of the "ansible_ssh_user" variable itself.
>> Maybe throw in lazy variable template evaluation for good measure.
>>
>> The error message is correct but incomplete, in that "aws_region" is
>> undefined. What the message leaves out is "… in the context of the
>> delegation host 'ec2.instances.0.network_interfaces.0.private_ip_address'
>> ".
>>
>> You set the task variable "ansible_ssh_user" to a template. By lazy
>> template evaluation, that template isn't evaluated until the variable is
>> used, which is at the point of connection. So it's evaluated in the context
>> of a host *which has no set_fact-derived variables defined*:
>> 'ec2.instances.0.network_interfaces.0.private_ip_address'. Only your
>> play hosts will have set_fact-derived variables.
>>
>> Assuming your hosts line is something like "hosts: localhost", then you
>> can work around it by changing your variable definition to
>> ansible_ssh_user: "{{ amis[*hostvars['localhost'].*aws_region][
>> *hostvars['localhost'].*os_version].user }}"
>>
>> I'm reasonably sure (but could be wrong) that the "amis" dict is
>> defined, because it isn't a host variable. That's different from 
>> set_fact-derived
>> variables which are both host-specific and template resolved at their
>> creation.
>>
>> Let us know if this resolves your issue.
>> --
>> Todd
>>
>>
>> On Saturday, January 13, 2024 at 9:40:57 AM UTC-5 ricardo barbosa wrote:
>>
>>> Hello guys
>>>
>>> I created the following structure:
>>>
>>> ```
>>> amis:
>>>   us-east-1:
>>> amazonlinux:
>>>   owner_id: "137112412989"
>>>   x86_64: "ami-01bc990364452ab3e"
>>>   arm64: "ami-0900a8f768a21540a"
>>>   user: "ec2-user"
>>> ubuntu:
>>>   owner_id: "099720109477"
>>>   x86_64: "ami-0fc5d935ebf8bc3bc" # Ubuntu 22
>>>   arm64: "ami-016485166ec7fa705"  #
>>>   user: "ubuntu"
>>> ```
>>>
>>> and I have a json file that I fill in to raise an ec2 instance:
>>>
>>> ```json
>>> {
>>> "aws_region":"us-east-1",
>>> "architecture":"arm64",
>>> "os_version":"ubuntu",
>>> "instance_name":"test6",
>>> "domain":"example.corp",
>>> "subnet":"SUBNET-PUB-A",
>>> "instance_type":"t4g.micro",
>>> "security_groups": [ "sg-xx", "sg-"],
>>> "aws_role":"default-role",
>>> "root_volume_size":20,
>>> "ebs_swap_size": 4,
>>> "keyname": "ssh-key",
>>> "ebs_type": "gp3",
>>> "backup": "no",
>>> "boxenv":"DEV"
>>> }
>>> ```
>>>
>>> And I read this json and create the variables with the tasks:
>>>
>>> ```
>>> - name: Read json configuration
>>> shell: cat config-ec2-launch.json
>>> register: result
>>>
>>>   - name: save the Json data to a Variable as a Fact
>>> set_fact:
>>>   jsondata: "{{ result.stdout | from_json }}"
>>>
>>>   - name: Variable | Get aws_region variable
>>> set_fact:
>>>   aws_region: "{{ jsondata | json_query(jmesquery) }}"
>>> vars:
>>>   jmesquery: 'aws_region'
>>>
>>>   - name: Variable | Get architecture variable
>>> set_fact:
>>>   architecture: "{{ jsondata | json_query(jmesquery) }}"
>>> vars:
>>>   jmesquery: 'architecture'
>>>
>>>   - name: Variable | Get os_version variable
>>> set_fact:
>>>   os_version: "{{ jsondata | json_query(jmesquery) }}"
>>> vars:
>>>   jmesquery: 'os_version'
>>> ```
>>>
>>> and created the tasks right away:
>>>
>>> ```
>>> - name: AWS Ec2 Instance | Create the EC2 instance
>>> ec2_instance:
>>>   state: started   #  started state=running + waits for EC2 status
>>> checks to report OK if wait=true
>>>   image_id: "{{ newest_ami }}"
>>>   name: "{{ instance_name }}"
>>>   detailed_monitoring: false
>>>   metadata_options:
>>> http_tokens: required
>>>   instance_type: "{{ instance_type }}"
>>>   region: "{{ aws_region }}"
>>>   vpc_subnet_id: "{{ subnet_facts.subnets.0.id }}"
>>>   instance_initiated_shutdown_behavior: stop
>>>   instance_role: "{{ aws_roles[aws_role] }}"
>>>   volumes:
>>> - device_name: "{{
>>> 

[ansible-project] Re: Issue about defining variable within the task does not work

2024-01-15 Thread ricardo barbosa
Thanks Todd, 

It worked. So because "delegate_to" the localhost host variables are not 
available I need to pass the variables with hostvars[ host ], right?

Thank you I will correct the entire playbook

On Saturday, January 13, 2024 at 12:52:55 PM UTC-4 Todd Lewis wrote:

> It's even stranger than that (until you realize what's going on).
> Rather than commenting out the "ansible_ssh_user:" line, just misspell 
> the variable, like "ansible_ssh_userx". It'll work then, too — but with 
> the wrong user of course.
>
> What you're running into is a combination of things: set_fact, delegate_to, 
> and the bit you didn't show, which is your playbook's "hosts:" line 
> and/or your command's "--limit" specification. Also the "special 
> variable" function of the "ansible_ssh_user" variable itself. Maybe throw 
> in lazy variable template evaluation for good measure.
>
> The error message is correct but incomplete, in that "aws_region" is 
> undefined. What the message leaves out is "… in the context of the 
> delegation host 'ec2.instances.0.network_interfaces.0.private_ip_address'
> ".
>
> You set the task variable "ansible_ssh_user" to a template. By lazy 
> template evaluation, that template isn't evaluated until the variable is 
> used, which is at the point of connection. So it's evaluated in the context 
> of a host *which has no set_fact-derived variables defined*: 
> 'ec2.instances.0.network_interfaces.0.private_ip_address'. Only your play 
> hosts will have set_fact-derived variables.
>
> Assuming your hosts line is something like "hosts: localhost", then you 
> can work around it by changing your variable definition to
> ansible_ssh_user: "{{ amis[*hostvars['localhost'].*aws_region][
> *hostvars['localhost'].*os_version].user }}"
>
> I'm reasonably sure (but could be wrong) that the "amis" dict is defined, 
> because it isn't a host variable. That's different from set_fact-derived 
> variables which are both host-specific and template resolved at their 
> creation.
>
> Let us know if this resolves your issue.
> --
> Todd
>
>
> On Saturday, January 13, 2024 at 9:40:57 AM UTC-5 ricardo barbosa wrote:
>
>> Hello guys
>>
>> I created the following structure:
>>
>> ```
>> amis:
>>   us-east-1:
>> amazonlinux:
>>   owner_id: "137112412989"
>>   x86_64: "ami-01bc990364452ab3e"
>>   arm64: "ami-0900a8f768a21540a"
>>   user: "ec2-user"
>> ubuntu:
>>   owner_id: "099720109477"
>>   x86_64: "ami-0fc5d935ebf8bc3bc" # Ubuntu 22
>>   arm64: "ami-016485166ec7fa705"  # 
>>   user: "ubuntu"
>> ```
>>
>> and I have a json file that I fill in to raise an ec2 instance:
>>
>> ```json
>> {
>> "aws_region":"us-east-1",
>> "architecture":"arm64",
>> "os_version":"ubuntu",
>> "instance_name":"test6",
>> "domain":"example.corp",
>> "subnet":"SUBNET-PUB-A",
>> "instance_type":"t4g.micro",
>> "security_groups": [ "sg-xx", "sg-"],
>> "aws_role":"default-role",
>> "root_volume_size":20,
>> "ebs_swap_size": 4,
>> "keyname": "ssh-key",
>> "ebs_type": "gp3",
>> "backup": "no",
>> "boxenv":"DEV"
>> }
>> ```
>>
>> And I read this json and create the variables with the tasks:
>>
>> ```
>> - name: Read json configuration
>> shell: cat config-ec2-launch.json
>> register: result
>>   
>>   - name: save the Json data to a Variable as a Fact
>> set_fact: 
>>   jsondata: "{{ result.stdout | from_json }}"
>>
>>   - name: Variable | Get aws_region variable
>> set_fact:
>>   aws_region: "{{ jsondata | json_query(jmesquery) }}"
>> vars:
>>   jmesquery: 'aws_region'
>>   
>>   - name: Variable | Get architecture variable
>> set_fact:  
>>   architecture: "{{ jsondata | json_query(jmesquery) }}"
>> vars:
>>   jmesquery: 'architecture'
>>
>>   - name: Variable | Get os_version variable
>> set_fact:
>>   os_version: "{{ jsondata | json_query(jmesquery) }}"
>> vars:
>>   jmesquery: 'os_version'
>> ```
>>
>> and created the tasks right away:
>>
>> ```
>> - name: AWS Ec2 Instance | Create the EC2 instance
>> ec2_instance:
>>   state: started   #  started state=running + waits for EC2 status 
>> checks to report OK if wait=true
>>   image_id: "{{ newest_ami }}"
>>   name: "{{ instance_name }}"
>>   detailed_monitoring: false
>>   metadata_options:
>> http_tokens: required
>>   instance_type: "{{ instance_type }}"
>>   region: "{{ aws_region }}"
>>   vpc_subnet_id: "{{ subnet_facts.subnets.0.id }}"
>>   instance_initiated_shutdown_behavior: stop
>>   instance_role: "{{ aws_roles[aws_role] }}"
>>   volumes:
>> - device_name: "{{ name_device_root_ami.images.0.root_device_name 
>> }}"
>>   ebs:
>> volume_type: gp3
>> volume_size: "{{ root_volume_size }}"
>> delete_on_termination: true
>>   security_groups: "{{ security_groups }}"
>>   tags:
>> 

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Dick Visser
I think you'd need to explicitly iterate over the list for that:

content: |
  {% for host in ansible_play_hosts %}
  {{ host }}:
  The following packages will be updated:

  {% for package in hostvars[host]['output'] %}
  {{ package }}
  {% endfor %}
  {% endfor %}






On Mon, 15 Jan 2024 at 18:00, Dimitri Yioulos  wrote:

> Todd, just before your last posy, i tried  *| to_nice_json * and*|
> to_nice_yaml* ,  both of which worked, to a point.
>
> Here's what I'm after:
>
> myhost:
>
> The following packages will be updated
>
> paho-c-1.3.13-2.el9
> cpp-11.4.1-2.1.el9
> glibc-headers-2.34-83.el9_3.7
> gnutls-dane-3.7.6-23.el9
> insights-client-3.2.2-1.el9_2
> libblockdev-2.28-7.el9
>
> This is what the output looks like in json format:
>
> myhost:
>
> The following packages will be updated[
> "paho-c-1.3.13-2.el9",
> "cpp-11.4.1-2.1.el9",
> "glibc-headers-2.34-83.el9_3.7",
> "gnutls-dane-3.7.6-23.el9",
> "insights-client-3.2.2-1.el9_2",
> "libblockdev-2.28-7.el9",
> ~
> ]
>
> I would want to be rid of the square brackets at beginning and end. and be
> rid of the quotes and commas.
>
> Here's what the output looks like in yaml format:
>
> myhost:
>
> The following packages will be updated- paho-c-1.3.13-2.el9
> - cpp-11.4.1-2.1.el9
> - glibc-headers-2.34-83.el9_3.7
> - gnutls-dane-3.7.6-23.el9
> - insights-client-3.2.2-1.el9_2
> - libblockdev-2.28-7.el9
>
> The first package (- paho-c-1.3.13-2.el9) is in the wrong position, and I
> would want to be rid of the dashes and spaces.
>
> I hope I'm not being a pita.
>
>
> On Monday, January 15, 2024 at 11:12:49 AM UTC-5 Todd Lewis wrote:
>
>> What kind of list? You've got a YAML list (with single- instead of
>> double-quotes). You could get a JSON list (i.e. double-quotes) with
>> {{ output | to_json }}
>> or
>> {{ output | to_nice_json }}
>>
>> What kind of list did you have in mind?
>>
>> On Monday, January 15, 2024 at 10:53:29 AM UTC-5 Dimitri Yioulos wrote:
>>
>>> Ah, Todd, you were right. I changed the output path, and it worked. I'm
>>> not sure why i couldn't write to the /tmp directory, but, whatever. My last
>>> question (I hope) on this topic is how to get the output in a list format.
>>> This is what I get presently:
>>>
>>> myhost:
>>> The following packages will be updated['paho-c-1.3.13-2.el9',
>>> 'cpp-11.4.1-2.1.el9', 'glibc-headers-2.34-83.el9_3.7',
>>> 'gnutls-dane-3.7.6-23.el9', 'insights-client-3.2.2-1.el9_2',
>>> 'libblockdev-2.28-7.el9', 'libblockdev-loop-2.28-7.el9',
>>> 'libfastjson-0.99.9-5.el9', 'libvirt-daemon-9.5.0-7.el9_3',
>>> 'libvirt-daemon-driver-interface-9.5.0-7.el9_3',
>>> 'libvirt-daemon-driver-qemu-9.5.0-7.el9_3', 'openssl-devel-3.0.7-24.el9',
>>> 'python3-file-magic-5.39-14.el9', 'python3-pip-21.2.3-7.el9',
>>> 'python3-policycoreutils-3.5-2.el9', 'qemu-kvm-audio-pa-8.0.0-16.el9_3',
>>> 'qemu-kvm-core-8.0.0-16.el9_3', 'qemu-kvm-device-usb-host-8.0.0-16.el9_3',
>>> 'qemu-kvm-docs-8.0.0-16.el9_3',
>>> 'rpm-plugin-systemd-inhibit-4.16.1.3-25.el9', 'rsyslog-8.2102.0-117.el9',
>>> 'samba-client-4.18.6-100.el9', 'udisks2-iscsi-2.9.4-9.el9',
>>> 'fwupd-plugin-flashrom-1.8.16-1.el9', 'gcc-11.4.1-2.1.el9',
>>> 'gcc-plugin-annobin-11.4.1-2.1.el9', 'gnutls-utils-3.7.6-23.el9',
>>> 'libblockdev-fs-2.28-7.el9', 'libblockdev-lvm-2.28-7.el9',
>>> 'libblockdev-mdraid-2.28-7.el9', ~
>>>
>>> On Monday, January 15, 2024 at 10:31:16 AM UTC-5 Todd Lewis wrote:
>>>
 Your 'deploy' user doesn't have permission to rename a file over
 '/tmp/installed.txt'. Is there an existing file with that name? Are there
 unusual permissions set on '/tmp' itself?

 It's bad practice to omit the 'owner:', 'group:', and 'mode:' of files
 created with the copy or template modules. There may be issues created
 because you're taking the defaults. Or not. Just a thought.

 Presented with those messages, the first thing I'd check is whether a
 file name '/tmp/installed.txt' already exists on the controller.

 On Monday, January 15, 2024 at 10:19:08 AM UTC-5 Dimitri Yioulos wrote:

> For Vladimir's solution, I get the following error:
>
> *An exception occurred during task execution. To see the full
> traceback, use -vvv. The error was: PermissionError: [Errno 1] Operation
> not permitted: b'/tmp/.ansible_tmpkdy1r8msinstalled.txt' ->
> b'/tmp/installed.txt'*
>
> *fatal: [bed-test-9-dy2 -> localhost]: FAILED! => changed=false*
> *  checksum: 543ecd635e9686d0ae4915df6ee4e9d8c13ff300  msg: 'Unable to
> make
> b''/home/deploy/.ansible/tmp/ansible-tmp-1705331818.2910578-4160834-8270244954747/source''
> into to /tmp/installed.txt, failed final rename from
> b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'': [Errno 1] Operation not
> permitted: b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'' ->
> b''/tmp/installed.txt'''*
>
> On Monday, January 15, 2024 at 10:04:55 AM UTC-5 Dimitri Yioulos wrote:
>
>> As I have written the 

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Todd Lewis
content: |
  {% for host in ansible_play_hosts %}
  {{ host }}:
  The following packages will be updated
  {% for p in packages.results %}
  {{ p.name ~ '-' ~ p.version ~ '-' ~ p.release }}
  {% endfor %}

  {% endfor %}


On Monday, January 15, 2024 at 12:00:18 PM UTC-5 Dimitri Yioulos wrote:

> Todd, just before your last posy, i tried  *| to_nice_json * and*| 
> to_nice_yaml* ,  both of which worked, to a point.
>
> Here's what I'm after:
>
> myhost:
>
> The following packages will be updated
> 
> paho-c-1.3.13-2.el9
> cpp-11.4.1-2.1.el9
> glibc-headers-2.34-83.el9_3.7
> gnutls-dane-3.7.6-23.el9
> insights-client-3.2.2-1.el9_2
> libblockdev-2.28-7.el9
>
> This is what the output looks like in json format:
>
> myhost:
>
> The following packages will be updated[
> "paho-c-1.3.13-2.el9",
> "cpp-11.4.1-2.1.el9",
> "glibc-headers-2.34-83.el9_3.7",
> "gnutls-dane-3.7.6-23.el9",
> "insights-client-3.2.2-1.el9_2",
> "libblockdev-2.28-7.el9",
> ~
> ]
>
> I would want to be rid of the square brackets at beginning and end. and be 
> rid of the quotes and commas.
>
> Here's what the output looks like in yaml format:
>
> myhost:
>
> The following packages will be updated- paho-c-1.3.13-2.el9
>
> - cpp-11.4.1-2.1.el9
> - glibc-headers-2.34-83.el9_3.7
> - gnutls-dane-3.7.6-23.el9
> - insights-client-3.2.2-1.el9_2
> - libblockdev-2.28-7.el9
>
> The first package (- paho-c-1.3.13-2.el9) is in the wrong position, and I 
> would want to be rid of the dashes and spaces.
>
> I hope I'm not being a pita.
>
>
> On Monday, January 15, 2024 at 11:12:49 AM UTC-5 Todd Lewis wrote:
>
>> What kind of list? You've got a YAML list (with single- instead of 
>> double-quotes). You could get a JSON list (i.e. double-quotes) with
>> {{ output | to_json }}
>> or
>> {{ output | to_nice_json }}
>>
>> What kind of list did you have in mind?
>>
>> On Monday, January 15, 2024 at 10:53:29 AM UTC-5 Dimitri Yioulos wrote:
>>
>>> Ah, Todd, you were right. I changed the output path, and it worked. I'm 
>>> not sure why i couldn't write to the /tmp directory, but, whatever. My last 
>>> question (I hope) on this topic is how to get the output in a list format. 
>>> This is what I get presently:
>>>
>>> myhost:
>>> The following packages will be updated['paho-c-1.3.13-2.el9', 
>>> 'cpp-11.4.1-2.1.el9', 'glibc-headers-2.34-83.el9_3.7', 
>>> 'gnutls-dane-3.7.6-23.el9', 'insights-client-3.2.2-1.el9_2', 
>>> 'libblockdev-2.28-7.el9', 'libblockdev-loop-2.28-7.el9', 
>>> 'libfastjson-0.99.9-5.el9', 'libvirt-daemon-9.5.0-7.el9_3', 
>>> 'libvirt-daemon-driver-interface-9.5.0-7.el9_3', 
>>> 'libvirt-daemon-driver-qemu-9.5.0-7.el9_3', 'openssl-devel-3.0.7-24.el9', 
>>> 'python3-file-magic-5.39-14.el9', 'python3-pip-21.2.3-7.el9', 
>>> 'python3-policycoreutils-3.5-2.el9', 'qemu-kvm-audio-pa-8.0.0-16.el9_3', 
>>> 'qemu-kvm-core-8.0.0-16.el9_3', 'qemu-kvm-device-usb-host-8.0.0-16.el9_3', 
>>> 'qemu-kvm-docs-8.0.0-16.el9_3', 
>>> 'rpm-plugin-systemd-inhibit-4.16.1.3-25.el9', 'rsyslog-8.2102.0-117.el9', 
>>> 'samba-client-4.18.6-100.el9', 'udisks2-iscsi-2.9.4-9.el9', 
>>> 'fwupd-plugin-flashrom-1.8.16-1.el9', 'gcc-11.4.1-2.1.el9', 
>>> 'gcc-plugin-annobin-11.4.1-2.1.el9', 'gnutls-utils-3.7.6-23.el9', 
>>> 'libblockdev-fs-2.28-7.el9', 'libblockdev-lvm-2.28-7.el9', 
>>> 'libblockdev-mdraid-2.28-7.el9', ~
>>>
>>> On Monday, January 15, 2024 at 10:31:16 AM UTC-5 Todd Lewis wrote:
>>>
 Your 'deploy' user doesn't have permission to rename a file over 
 '/tmp/installed.txt'. Is there an existing file with that name? Are there 
 unusual permissions set on '/tmp' itself?

 It's bad practice to omit the 'owner:', 'group:', and 'mode:' of files 
 created with the copy or template modules. There may be issues created 
 because you're taking the defaults. Or not. Just a thought.

 Presented with those messages, the first thing I'd check is whether a 
 file name '/tmp/installed.txt' already exists on the controller.

 On Monday, January 15, 2024 at 10:19:08 AM UTC-5 Dimitri Yioulos wrote:

> For Vladimir's solution, I get the following error:
>
> *An exception occurred during task execution. To see the full 
> traceback, use -vvv. The error was: PermissionError: [Errno 1] Operation 
> not permitted: b'/tmp/.ansible_tmpkdy1r8msinstalled.txt' -> 
> b'/tmp/installed.txt'*
>
> *fatal: [bed-test-9-dy2 -> localhost]: FAILED! => changed=false*
> *  checksum: 543ecd635e9686d0ae4915df6ee4e9d8c13ff300  msg: 'Unable to 
> make 
> b''/home/deploy/.ansible/tmp/ansible-tmp-1705331818.2910578-4160834-8270244954747/source''
>  
> into to /tmp/installed.txt, failed final rename from 
> b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'': [Errno 1] Operation not 
> permitted: b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'' -> 
> b''/tmp/installed.txt'''*
>
> On Monday, January 15, 2024 

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Dimitri Yioulos
Todd, just before your last posy, i tried  *| to_nice_json * and*| 
to_nice_yaml* ,  both of which worked, to a point.

Here's what I'm after:

myhost:

The following packages will be updated

paho-c-1.3.13-2.el9
cpp-11.4.1-2.1.el9
glibc-headers-2.34-83.el9_3.7
gnutls-dane-3.7.6-23.el9
insights-client-3.2.2-1.el9_2
libblockdev-2.28-7.el9

This is what the output looks like in json format:

myhost:

The following packages will be updated[
"paho-c-1.3.13-2.el9",
"cpp-11.4.1-2.1.el9",
"glibc-headers-2.34-83.el9_3.7",
"gnutls-dane-3.7.6-23.el9",
"insights-client-3.2.2-1.el9_2",
"libblockdev-2.28-7.el9",
~
]

I would want to be rid of the square brackets at beginning and end. and be 
rid of the quotes and commas.

Here's what the output looks like in yaml format:

myhost:

The following packages will be updated- paho-c-1.3.13-2.el9
- cpp-11.4.1-2.1.el9
- glibc-headers-2.34-83.el9_3.7
- gnutls-dane-3.7.6-23.el9
- insights-client-3.2.2-1.el9_2
- libblockdev-2.28-7.el9

The first package (- paho-c-1.3.13-2.el9) is in the wrong position, and I 
would want to be rid of the dashes and spaces.

I hope I'm not being a pita.


On Monday, January 15, 2024 at 11:12:49 AM UTC-5 Todd Lewis wrote:

> What kind of list? You've got a YAML list (with single- instead of 
> double-quotes). You could get a JSON list (i.e. double-quotes) with
> {{ output | to_json }}
> or
> {{ output | to_nice_json }}
>
> What kind of list did you have in mind?
>
> On Monday, January 15, 2024 at 10:53:29 AM UTC-5 Dimitri Yioulos wrote:
>
>> Ah, Todd, you were right. I changed the output path, and it worked. I'm 
>> not sure why i couldn't write to the /tmp directory, but, whatever. My last 
>> question (I hope) on this topic is how to get the output in a list format. 
>> This is what I get presently:
>>
>> myhost:
>> The following packages will be updated['paho-c-1.3.13-2.el9', 
>> 'cpp-11.4.1-2.1.el9', 'glibc-headers-2.34-83.el9_3.7', 
>> 'gnutls-dane-3.7.6-23.el9', 'insights-client-3.2.2-1.el9_2', 
>> 'libblockdev-2.28-7.el9', 'libblockdev-loop-2.28-7.el9', 
>> 'libfastjson-0.99.9-5.el9', 'libvirt-daemon-9.5.0-7.el9_3', 
>> 'libvirt-daemon-driver-interface-9.5.0-7.el9_3', 
>> 'libvirt-daemon-driver-qemu-9.5.0-7.el9_3', 'openssl-devel-3.0.7-24.el9', 
>> 'python3-file-magic-5.39-14.el9', 'python3-pip-21.2.3-7.el9', 
>> 'python3-policycoreutils-3.5-2.el9', 'qemu-kvm-audio-pa-8.0.0-16.el9_3', 
>> 'qemu-kvm-core-8.0.0-16.el9_3', 'qemu-kvm-device-usb-host-8.0.0-16.el9_3', 
>> 'qemu-kvm-docs-8.0.0-16.el9_3', 
>> 'rpm-plugin-systemd-inhibit-4.16.1.3-25.el9', 'rsyslog-8.2102.0-117.el9', 
>> 'samba-client-4.18.6-100.el9', 'udisks2-iscsi-2.9.4-9.el9', 
>> 'fwupd-plugin-flashrom-1.8.16-1.el9', 'gcc-11.4.1-2.1.el9', 
>> 'gcc-plugin-annobin-11.4.1-2.1.el9', 'gnutls-utils-3.7.6-23.el9', 
>> 'libblockdev-fs-2.28-7.el9', 'libblockdev-lvm-2.28-7.el9', 
>> 'libblockdev-mdraid-2.28-7.el9', ~
>>
>> On Monday, January 15, 2024 at 10:31:16 AM UTC-5 Todd Lewis wrote:
>>
>>> Your 'deploy' user doesn't have permission to rename a file over 
>>> '/tmp/installed.txt'. Is there an existing file with that name? Are there 
>>> unusual permissions set on '/tmp' itself?
>>>
>>> It's bad practice to omit the 'owner:', 'group:', and 'mode:' of files 
>>> created with the copy or template modules. There may be issues created 
>>> because you're taking the defaults. Or not. Just a thought.
>>>
>>> Presented with those messages, the first thing I'd check is whether a 
>>> file name '/tmp/installed.txt' already exists on the controller.
>>>
>>> On Monday, January 15, 2024 at 10:19:08 AM UTC-5 Dimitri Yioulos wrote:
>>>
 For Vladimir's solution, I get the following error:

 *An exception occurred during task execution. To see the full 
 traceback, use -vvv. The error was: PermissionError: [Errno 1] Operation 
 not permitted: b'/tmp/.ansible_tmpkdy1r8msinstalled.txt' -> 
 b'/tmp/installed.txt'*

 *fatal: [bed-test-9-dy2 -> localhost]: FAILED! => changed=false*
 *  checksum: 543ecd635e9686d0ae4915df6ee4e9d8c13ff300  msg: 'Unable to 
 make 
 b''/home/deploy/.ansible/tmp/ansible-tmp-1705331818.2910578-4160834-8270244954747/source''
  
 into to /tmp/installed.txt, failed final rename from 
 b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'': [Errno 1] Operation not 
 permitted: b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'' -> 
 b''/tmp/installed.txt'''*

 On Monday, January 15, 2024 at 10:04:55 AM UTC-5 Dimitri Yioulos wrote:

> As I have written the playbook above, here's the error, which I hope 
> is enough for troubleshooting purposes:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> * ESTABLISH LOCAL 

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Todd Lewis
> I changed the output path, and it worked. I'm not sure why i couldn't 
write to the /tmp directory

ls -ld /tmp /tmp/installed.txt
would probably explain it.

On Monday, January 15, 2024 at 10:53:29 AM UTC-5 Dimitri Yioulos wrote:

> Ah, Todd, you were right. I changed the output path, and it worked. I'm 
> not sure why i couldn't write to the /tmp directory, but, whatever. My last 
> question (I hope) on this topic is how to get the output in a list format. 
> This is what I get presently:
>
> myhost:
> The following packages will be updated['paho-c-1.3.13-2.el9', 
> 'cpp-11.4.1-2.1.el9', 'glibc-headers-2.34-83.el9_3.7', 
> 'gnutls-dane-3.7.6-23.el9', 'insights-client-3.2.2-1.el9_2', 
> 'libblockdev-2.28-7.el9', 'libblockdev-loop-2.28-7.el9', 
> 'libfastjson-0.99.9-5.el9', 'libvirt-daemon-9.5.0-7.el9_3', 
> 'libvirt-daemon-driver-interface-9.5.0-7.el9_3', 
> 'libvirt-daemon-driver-qemu-9.5.0-7.el9_3', 'openssl-devel-3.0.7-24.el9', 
> 'python3-file-magic-5.39-14.el9', 'python3-pip-21.2.3-7.el9', 
> 'python3-policycoreutils-3.5-2.el9', 'qemu-kvm-audio-pa-8.0.0-16.el9_3', 
> 'qemu-kvm-core-8.0.0-16.el9_3', 'qemu-kvm-device-usb-host-8.0.0-16.el9_3', 
> 'qemu-kvm-docs-8.0.0-16.el9_3', 
> 'rpm-plugin-systemd-inhibit-4.16.1.3-25.el9', 'rsyslog-8.2102.0-117.el9', 
> 'samba-client-4.18.6-100.el9', 'udisks2-iscsi-2.9.4-9.el9', 
> 'fwupd-plugin-flashrom-1.8.16-1.el9', 'gcc-11.4.1-2.1.el9', 
> 'gcc-plugin-annobin-11.4.1-2.1.el9', 'gnutls-utils-3.7.6-23.el9', 
> 'libblockdev-fs-2.28-7.el9', 'libblockdev-lvm-2.28-7.el9', 
> 'libblockdev-mdraid-2.28-7.el9', ~
>
> On Monday, January 15, 2024 at 10:31:16 AM UTC-5 Todd Lewis wrote:
>
>> Your 'deploy' user doesn't have permission to rename a file over 
>> '/tmp/installed.txt'. Is there an existing file with that name? Are there 
>> unusual permissions set on '/tmp' itself?
>>
>> It's bad practice to omit the 'owner:', 'group:', and 'mode:' of files 
>> created with the copy or template modules. There may be issues created 
>> because you're taking the defaults. Or not. Just a thought.
>>
>> Presented with those messages, the first thing I'd check is whether a 
>> file name '/tmp/installed.txt' already exists on the controller.
>>
>> On Monday, January 15, 2024 at 10:19:08 AM UTC-5 Dimitri Yioulos wrote:
>>
>>> For Vladimir's solution, I get the following error:
>>>
>>> *An exception occurred during task execution. To see the full traceback, 
>>> use -vvv. The error was: PermissionError: [Errno 1] Operation not 
>>> permitted: b'/tmp/.ansible_tmpkdy1r8msinstalled.txt' -> 
>>> b'/tmp/installed.txt'*
>>>
>>> *fatal: [bed-test-9-dy2 -> localhost]: FAILED! => changed=false*
>>> *  checksum: 543ecd635e9686d0ae4915df6ee4e9d8c13ff300  msg: 'Unable to 
>>> make 
>>> b''/home/deploy/.ansible/tmp/ansible-tmp-1705331818.2910578-4160834-8270244954747/source''
>>>  
>>> into to /tmp/installed.txt, failed final rename from 
>>> b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'': [Errno 1] Operation not 
>>> permitted: b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'' -> 
>>> b''/tmp/installed.txt'''*
>>>
>>> On Monday, January 15, 2024 at 10:04:55 AM UTC-5 Dimitri Yioulos wrote:
>>>
 As I have written the playbook above, here's the error, which I hope is 
 enough for troubleshooting purposes:





















































 * ESTABLISH LOCAL CONNECTION FOR USER: deploy 
 EXEC /bin/sh -c 'echo ~deploy && sleep 0' EXEC /bin/sh -c '( 
 umask 77 && mkdir -p "` echo /home/deploy/.ansible/tmp `"&& mkdir "` echo 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
  
 `" && echo ansible-tmp-1705330892.3380399-4159921-3325212893501="` echo 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
  
 `" ) && sleep 0'Using module file 
 /usr/local/lib/python3.9/site-packages/ansible/modules/stat.py 
 PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmphdv1no20 TO 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
  
 EXEC /bin/sh -c 'chmod u+x 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
  
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
  
 && sleep 0' EXEC /bin/sh -c '/usr/bin/env python 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
  
 && sleep 0' PUT 
 /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpi_3sa5v9 TO 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
  
 EXEC /bin/sh -c 'chmod u+x 
 

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Todd Lewis
What kind of list? You've got a YAML list (with single- instead of 
double-quotes). You could get a JSON list (i.e. double-quotes) with
{{ output | to_json }}
or
{{ output | to_nice_json }}

What kind of list did you have in mind?

On Monday, January 15, 2024 at 10:53:29 AM UTC-5 Dimitri Yioulos wrote:

> Ah, Todd, you were right. I changed the output path, and it worked. I'm 
> not sure why i couldn't write to the /tmp directory, but, whatever. My last 
> question (I hope) on this topic is how to get the output in a list format. 
> This is what I get presently:
>
> myhost:
> The following packages will be updated['paho-c-1.3.13-2.el9', 
> 'cpp-11.4.1-2.1.el9', 'glibc-headers-2.34-83.el9_3.7', 
> 'gnutls-dane-3.7.6-23.el9', 'insights-client-3.2.2-1.el9_2', 
> 'libblockdev-2.28-7.el9', 'libblockdev-loop-2.28-7.el9', 
> 'libfastjson-0.99.9-5.el9', 'libvirt-daemon-9.5.0-7.el9_3', 
> 'libvirt-daemon-driver-interface-9.5.0-7.el9_3', 
> 'libvirt-daemon-driver-qemu-9.5.0-7.el9_3', 'openssl-devel-3.0.7-24.el9', 
> 'python3-file-magic-5.39-14.el9', 'python3-pip-21.2.3-7.el9', 
> 'python3-policycoreutils-3.5-2.el9', 'qemu-kvm-audio-pa-8.0.0-16.el9_3', 
> 'qemu-kvm-core-8.0.0-16.el9_3', 'qemu-kvm-device-usb-host-8.0.0-16.el9_3', 
> 'qemu-kvm-docs-8.0.0-16.el9_3', 
> 'rpm-plugin-systemd-inhibit-4.16.1.3-25.el9', 'rsyslog-8.2102.0-117.el9', 
> 'samba-client-4.18.6-100.el9', 'udisks2-iscsi-2.9.4-9.el9', 
> 'fwupd-plugin-flashrom-1.8.16-1.el9', 'gcc-11.4.1-2.1.el9', 
> 'gcc-plugin-annobin-11.4.1-2.1.el9', 'gnutls-utils-3.7.6-23.el9', 
> 'libblockdev-fs-2.28-7.el9', 'libblockdev-lvm-2.28-7.el9', 
> 'libblockdev-mdraid-2.28-7.el9', ~
>
> On Monday, January 15, 2024 at 10:31:16 AM UTC-5 Todd Lewis wrote:
>
>> Your 'deploy' user doesn't have permission to rename a file over 
>> '/tmp/installed.txt'. Is there an existing file with that name? Are there 
>> unusual permissions set on '/tmp' itself?
>>
>> It's bad practice to omit the 'owner:', 'group:', and 'mode:' of files 
>> created with the copy or template modules. There may be issues created 
>> because you're taking the defaults. Or not. Just a thought.
>>
>> Presented with those messages, the first thing I'd check is whether a 
>> file name '/tmp/installed.txt' already exists on the controller.
>>
>> On Monday, January 15, 2024 at 10:19:08 AM UTC-5 Dimitri Yioulos wrote:
>>
>>> For Vladimir's solution, I get the following error:
>>>
>>> *An exception occurred during task execution. To see the full traceback, 
>>> use -vvv. The error was: PermissionError: [Errno 1] Operation not 
>>> permitted: b'/tmp/.ansible_tmpkdy1r8msinstalled.txt' -> 
>>> b'/tmp/installed.txt'*
>>>
>>> *fatal: [bed-test-9-dy2 -> localhost]: FAILED! => changed=false*
>>> *  checksum: 543ecd635e9686d0ae4915df6ee4e9d8c13ff300  msg: 'Unable to 
>>> make 
>>> b''/home/deploy/.ansible/tmp/ansible-tmp-1705331818.2910578-4160834-8270244954747/source''
>>>  
>>> into to /tmp/installed.txt, failed final rename from 
>>> b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'': [Errno 1] Operation not 
>>> permitted: b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'' -> 
>>> b''/tmp/installed.txt'''*
>>>
>>> On Monday, January 15, 2024 at 10:04:55 AM UTC-5 Dimitri Yioulos wrote:
>>>
 As I have written the playbook above, here's the error, which I hope is 
 enough for troubleshooting purposes:





















































 * ESTABLISH LOCAL CONNECTION FOR USER: deploy 
 EXEC /bin/sh -c 'echo ~deploy && sleep 0' EXEC /bin/sh -c '( 
 umask 77 && mkdir -p "` echo /home/deploy/.ansible/tmp `"&& mkdir "` echo 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
  
 `" && echo ansible-tmp-1705330892.3380399-4159921-3325212893501="` echo 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
  
 `" ) && sleep 0'Using module file 
 /usr/local/lib/python3.9/site-packages/ansible/modules/stat.py 
 PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmphdv1no20 TO 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
  
 EXEC /bin/sh -c 'chmod u+x 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
  
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
  
 && sleep 0' EXEC /bin/sh -c '/usr/bin/env python 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
  
 && sleep 0' PUT 
 /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpi_3sa5v9 TO 
 /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
  
 EXEC /bin/sh -c 'chmod u+x 
 

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Dimitri Yioulos
Ah, Todd, you were right. I changed the output path, and it worked. I'm not 
sure why i couldn't write to the /tmp directory, but, whatever. My last 
question (I hope) on this topic is how to get the output in a list format. 
This is what I get presently:

myhost:
The following packages will be updated['paho-c-1.3.13-2.el9', 
'cpp-11.4.1-2.1.el9', 'glibc-headers-2.34-83.el9_3.7', 
'gnutls-dane-3.7.6-23.el9', 'insights-client-3.2.2-1.el9_2', 
'libblockdev-2.28-7.el9', 'libblockdev-loop-2.28-7.el9', 
'libfastjson-0.99.9-5.el9', 'libvirt-daemon-9.5.0-7.el9_3', 
'libvirt-daemon-driver-interface-9.5.0-7.el9_3', 
'libvirt-daemon-driver-qemu-9.5.0-7.el9_3', 'openssl-devel-3.0.7-24.el9', 
'python3-file-magic-5.39-14.el9', 'python3-pip-21.2.3-7.el9', 
'python3-policycoreutils-3.5-2.el9', 'qemu-kvm-audio-pa-8.0.0-16.el9_3', 
'qemu-kvm-core-8.0.0-16.el9_3', 'qemu-kvm-device-usb-host-8.0.0-16.el9_3', 
'qemu-kvm-docs-8.0.0-16.el9_3', 
'rpm-plugin-systemd-inhibit-4.16.1.3-25.el9', 'rsyslog-8.2102.0-117.el9', 
'samba-client-4.18.6-100.el9', 'udisks2-iscsi-2.9.4-9.el9', 
'fwupd-plugin-flashrom-1.8.16-1.el9', 'gcc-11.4.1-2.1.el9', 
'gcc-plugin-annobin-11.4.1-2.1.el9', 'gnutls-utils-3.7.6-23.el9', 
'libblockdev-fs-2.28-7.el9', 'libblockdev-lvm-2.28-7.el9', 
'libblockdev-mdraid-2.28-7.el9', ~

On Monday, January 15, 2024 at 10:31:16 AM UTC-5 Todd Lewis wrote:

> Your 'deploy' user doesn't have permission to rename a file over 
> '/tmp/installed.txt'. Is there an existing file with that name? Are there 
> unusual permissions set on '/tmp' itself?
>
> It's bad practice to omit the 'owner:', 'group:', and 'mode:' of files 
> created with the copy or template modules. There may be issues created 
> because you're taking the defaults. Or not. Just a thought.
>
> Presented with those messages, the first thing I'd check is whether a file 
> name '/tmp/installed.txt' already exists on the controller.
>
> On Monday, January 15, 2024 at 10:19:08 AM UTC-5 Dimitri Yioulos wrote:
>
>> For Vladimir's solution, I get the following error:
>>
>> *An exception occurred during task execution. To see the full traceback, 
>> use -vvv. The error was: PermissionError: [Errno 1] Operation not 
>> permitted: b'/tmp/.ansible_tmpkdy1r8msinstalled.txt' -> 
>> b'/tmp/installed.txt'*
>>
>> *fatal: [bed-test-9-dy2 -> localhost]: FAILED! => changed=false*
>> *  checksum: 543ecd635e9686d0ae4915df6ee4e9d8c13ff300  msg: 'Unable to 
>> make 
>> b''/home/deploy/.ansible/tmp/ansible-tmp-1705331818.2910578-4160834-8270244954747/source''
>>  
>> into to /tmp/installed.txt, failed final rename from 
>> b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'': [Errno 1] Operation not 
>> permitted: b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'' -> 
>> b''/tmp/installed.txt'''*
>>
>> On Monday, January 15, 2024 at 10:04:55 AM UTC-5 Dimitri Yioulos wrote:
>>
>>> As I have written the playbook above, here's the error, which I hope is 
>>> enough for troubleshooting purposes:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> * ESTABLISH LOCAL CONNECTION FOR USER: deploy EXEC 
>>> /bin/sh -c 'echo ~deploy && sleep 0' EXEC /bin/sh -c '( umask 77 
>>> && mkdir -p "` echo /home/deploy/.ansible/tmp `"&& mkdir "` echo 
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
>>>  
>>> `" && echo ansible-tmp-1705330892.3380399-4159921-3325212893501="` echo 
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
>>>  
>>> `" ) && sleep 0'Using module file 
>>> /usr/local/lib/python3.9/site-packages/ansible/modules/stat.py 
>>> PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmphdv1no20 TO 
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
>>>  
>>> EXEC /bin/sh -c 'chmod u+x 
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>>>  
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
>>>  
>>> && sleep 0' EXEC /bin/sh -c '/usr/bin/env python 
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
>>>  
>>> && sleep 0' PUT 
>>> /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpi_3sa5v9 TO 
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
>>>  
>>> EXEC /bin/sh -c 'chmod u+x 
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>>>  
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
>>>  
>>> && sleep 0'Using module file 
>>> /usr/local/lib/python3.9/site-packages/ansible/modules/copy.py 
>>> PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpyre28n8_ TO 
>>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
>>>  

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Todd Lewis
Your 'deploy' user doesn't have permission to rename a file over 
'/tmp/installed.txt'. Is there an existing file with that name? Are there 
unusual permissions set on '/tmp' itself?

It's bad practice to omit the 'owner:', 'group:', and 'mode:' of files 
created with the copy or template modules. There may be issues created 
because you're taking the defaults. Or not. Just a thought.

Presented with those messages, the first thing I'd check is whether a file 
name '/tmp/installed.txt' already exists on the controller.

On Monday, January 15, 2024 at 10:19:08 AM UTC-5 Dimitri Yioulos wrote:

> For Vladimir's solution, I get the following error:
>
> *An exception occurred during task execution. To see the full traceback, 
> use -vvv. The error was: PermissionError: [Errno 1] Operation not 
> permitted: b'/tmp/.ansible_tmpkdy1r8msinstalled.txt' -> 
> b'/tmp/installed.txt'*
>
> *fatal: [bed-test-9-dy2 -> localhost]: FAILED! => changed=false*
> *  checksum: 543ecd635e9686d0ae4915df6ee4e9d8c13ff300  msg: 'Unable to 
> make 
> b''/home/deploy/.ansible/tmp/ansible-tmp-1705331818.2910578-4160834-8270244954747/source''
>  
> into to /tmp/installed.txt, failed final rename from 
> b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'': [Errno 1] Operation not 
> permitted: b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'' -> 
> b''/tmp/installed.txt'''*
>
> On Monday, January 15, 2024 at 10:04:55 AM UTC-5 Dimitri Yioulos wrote:
>
>> As I have written the playbook above, here's the error, which I hope is 
>> enough for troubleshooting purposes:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> * ESTABLISH LOCAL CONNECTION FOR USER: deploy EXEC 
>> /bin/sh -c 'echo ~deploy && sleep 0' EXEC /bin/sh -c '( umask 77 
>> && mkdir -p "` echo /home/deploy/.ansible/tmp `"&& mkdir "` echo 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
>>  
>> `" && echo ansible-tmp-1705330892.3380399-4159921-3325212893501="` echo 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
>>  
>> `" ) && sleep 0'Using module file 
>> /usr/local/lib/python3.9/site-packages/ansible/modules/stat.py 
>> PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmphdv1no20 TO 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
>>  
>> EXEC /bin/sh -c 'chmod u+x 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>>  
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
>>  
>> && sleep 0' EXEC /bin/sh -c '/usr/bin/env python 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
>>  
>> && sleep 0' PUT 
>> /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpi_3sa5v9 TO 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
>>  
>> EXEC /bin/sh -c 'chmod u+x 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>>  
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
>>  
>> && sleep 0'Using module file 
>> /usr/local/lib/python3.9/site-packages/ansible/modules/copy.py 
>> PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpyre28n8_ TO 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
>>  
>> EXEC /bin/sh -c 'chmod u+x 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>>  
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
>>  
>> && sleep 0' EXEC /bin/sh -c '/usr/bin/env python 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
>>  
>> && sleep 0' EXEC /bin/sh -c 'rm -f -r 
>> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>>  
>> > /dev/null 2>&1 && sleep 0'The full traceback is:Traceback (most recent 
>> call last):  File 
>> "/tmp/ansible_ansible.legacy.copy_payload_rmpe1ef8/ansible_ansible.legacy.copy_payload.zip/ansible/module_utils/basic.py",
>>  
>> line 1700, in atomic_moveos.rename(b_src, b_dest)PermissionError: 
>> [Errno 1] Operation not permitted: 
>> b'/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source'
>>  
>> -> b'/tmp/installed.txt'During handling of the above exception, another 
>> exception occurred:Traceback (most recent call last):  File 
>> "/tmp/ansible_ansible.legacy.copy_payload_rmpe1ef8/ansible_ansible.legacy.copy_payload.zip/ansible/module_utils/basic.py",
>>  
>> line 1759, in atomic_moveos.rename(b_tmp_dest_name, 
>> b_dest)PermissionError: [Errno 1] Operation not permitted: 
>> b'/tmp/.ansible_tmp162o24fxinstalled.txt' -> b'/tmp/installed.txt'fatal: 
>> [bed-test-9-dy2 -> localhost]: FAILED! => changed=false  checksum: 
>> 

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Dimitri Yioulos
For Vladimir's solution, I get the following error:




*An exception occurred during task execution. To see the full traceback, 
use -vvv. The error was: PermissionError: [Errno 1] Operation not 
permitted: b'/tmp/.ansible_tmpkdy1r8msinstalled.txt' -> 
b'/tmp/installed.txt'fatal: [bed-test-9-dy2 -> localhost]: FAILED! => 
changed=false  checksum: 543ecd635e9686d0ae4915df6ee4e9d8c13ff300  msg: 
'Unable to make 
b''/home/deploy/.ansible/tmp/ansible-tmp-1705331818.2910578-4160834-8270244954747/source''
 
into to /tmp/installed.txt, failed final rename from 
b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'': [Errno 1] Operation not 
permitted: b''/tmp/.ansible_tmpkdy1r8msinstalled.txt'' -> 
b''/tmp/installed.txt'''*

On Monday, January 15, 2024 at 10:04:55 AM UTC-5 Dimitri Yioulos wrote:

> As I have written the playbook above, here's the error, which I hope is 
> enough for troubleshooting purposes:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> * ESTABLISH LOCAL CONNECTION FOR USER: deploy EXEC 
> /bin/sh -c 'echo ~deploy && sleep 0' EXEC /bin/sh -c '( umask 77 
> && mkdir -p "` echo /home/deploy/.ansible/tmp `"&& mkdir "` echo 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
>  
> `" && echo ansible-tmp-1705330892.3380399-4159921-3325212893501="` echo 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501
>  
> `" ) && sleep 0'Using module file 
> /usr/local/lib/python3.9/site-packages/ansible/modules/stat.py 
> PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmphdv1no20 TO 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
>  
> EXEC /bin/sh -c 'chmod u+x 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>  
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
>  
> && sleep 0' EXEC /bin/sh -c '/usr/bin/env python 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
>  
> && sleep 0' PUT 
> /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpi_3sa5v9 TO 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
>  
> EXEC /bin/sh -c 'chmod u+x 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>  
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
>  
> && sleep 0'Using module file 
> /usr/local/lib/python3.9/site-packages/ansible/modules/copy.py 
> PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpyre28n8_ TO 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
>  
> EXEC /bin/sh -c 'chmod u+x 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>  
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
>  
> && sleep 0' EXEC /bin/sh -c '/usr/bin/env python 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
>  
> && sleep 0' EXEC /bin/sh -c 'rm -f -r 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/
>  
> > /dev/null 2>&1 && sleep 0'The full traceback is:Traceback (most recent 
> call last):  File 
> "/tmp/ansible_ansible.legacy.copy_payload_rmpe1ef8/ansible_ansible.legacy.copy_payload.zip/ansible/module_utils/basic.py",
>  
> line 1700, in atomic_moveos.rename(b_src, b_dest)PermissionError: 
> [Errno 1] Operation not permitted: 
> b'/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source'
>  
> -> b'/tmp/installed.txt'During handling of the above exception, another 
> exception occurred:Traceback (most recent call last):  File 
> "/tmp/ansible_ansible.legacy.copy_payload_rmpe1ef8/ansible_ansible.legacy.copy_payload.zip/ansible/module_utils/basic.py",
>  
> line 1759, in atomic_moveos.rename(b_tmp_dest_name, 
> b_dest)PermissionError: [Errno 1] Operation not permitted: 
> b'/tmp/.ansible_tmp162o24fxinstalled.txt' -> b'/tmp/installed.txt'fatal: 
> [bed-test-9-dy2 -> localhost]: FAILED! => changed=false  checksum: 
> 590d9e59d7b819e4c8fb2068a91aec5e760afc8e  diff: []  invocation:
> module_args:  _original_basename: tmpi_3sa5v9  attributes: null
>   backup: false  checksum: 590d9e59d7b819e4c8fb2068a91aec5e760afc8e
>   content: null  dest: /tmp/installed.txt  directory_mode: null
>   follow: false  force: true  group: null  local_follow: null  
> mode: null  owner: null  remote_src: null  selevel: null
>   serole: null  setype: null  seuser: null  src: 
> /home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
>   
> unsafe_writes: false  validate: null  msg: 'Unable to make 
> 

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Dimitri Yioulos
As I have written the playbook above, here's the error, which I hope is 
enough for troubleshooting purposes:





















































* ESTABLISH LOCAL CONNECTION FOR USER: deploy EXEC 
/bin/sh -c 'echo ~deploy && sleep 0' EXEC /bin/sh -c '( umask 77 
&& mkdir -p "` echo /home/deploy/.ansible/tmp `"&& mkdir "` echo 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501 
`" && echo ansible-tmp-1705330892.3380399-4159921-3325212893501="` echo 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501 
`" ) && sleep 0'Using module file 
/usr/local/lib/python3.9/site-packages/ansible/modules/stat.py 
PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmphdv1no20 TO 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
 
EXEC /bin/sh -c 'chmod u+x 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/ 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
 
&& sleep 0' EXEC /bin/sh -c '/usr/bin/env python 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
 
&& sleep 0' PUT 
/home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpi_3sa5v9 TO 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
 
EXEC /bin/sh -c 'chmod u+x 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/ 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
 
&& sleep 0'Using module file 
/usr/local/lib/python3.9/site-packages/ansible/modules/copy.py 
PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpyre28n8_ TO 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
 
EXEC /bin/sh -c 'chmod u+x 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/ 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
 
&& sleep 0' EXEC /bin/sh -c '/usr/bin/env python 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
 
&& sleep 0' EXEC /bin/sh -c 'rm -f -r 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/ 
> /dev/null 2>&1 && sleep 0'The full traceback is:Traceback (most recent 
call last):  File 
"/tmp/ansible_ansible.legacy.copy_payload_rmpe1ef8/ansible_ansible.legacy.copy_payload.zip/ansible/module_utils/basic.py",
 
line 1700, in atomic_moveos.rename(b_src, b_dest)PermissionError: 
[Errno 1] Operation not permitted: 
b'/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source'
 
-> b'/tmp/installed.txt'During handling of the above exception, another 
exception occurred:Traceback (most recent call last):  File 
"/tmp/ansible_ansible.legacy.copy_payload_rmpe1ef8/ansible_ansible.legacy.copy_payload.zip/ansible/module_utils/basic.py",
 
line 1759, in atomic_moveos.rename(b_tmp_dest_name, 
b_dest)PermissionError: [Errno 1] Operation not permitted: 
b'/tmp/.ansible_tmp162o24fxinstalled.txt' -> b'/tmp/installed.txt'fatal: 
[bed-test-9-dy2 -> localhost]: FAILED! => changed=false  checksum: 
590d9e59d7b819e4c8fb2068a91aec5e760afc8e  diff: []  invocation:
module_args:  _original_basename: tmpi_3sa5v9  attributes: null
  backup: false  checksum: 590d9e59d7b819e4c8fb2068a91aec5e760afc8e
  content: null  dest: /tmp/installed.txt  directory_mode: null
  follow: false  force: true  group: null  local_follow: null  
mode: null  owner: null  remote_src: null  selevel: null
  serole: null  setype: null  seuser: null  src: 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
  
unsafe_writes: false  validate: null  msg: 'Unable to make 
b''/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source''
 
into to /tmp/installed.txt, failed final rename from 
b''/tmp/.ansible_tmp162o24fxinstalled.txt'': [Errno 1] Operation not 
permitted: b''/tmp/.ansible_tmp162o24fxinstalled.txt'' -> 
b''/tmp/installed.txt'''*
On Monday, January 15, 2024 at 9:21:26 AM UTC-5 Todd Lewis wrote:

> You say "the report play does not work", but you don't tell us in what way 
> it doesn't work. Is there a template error, undefined variable, or 
> something else? Does running with -vv -D indicate anything? "Does not work" 
> is too vague. Okay, so it didn't do what you expected, but what did it do? 
> Show us the play log.
>
>
> On 1/15/24 8:00 AM, Dimitri Yioulos wrote:
>
> Good morning. 
>
> Let me start by saying that I hope I'm not overdoing my asks. I only do it 
> when I've tried, but failed, at a solution. Nextly, I hope your kind 
> answers help others, as well. That said, the following playbook returns 
> packages that are set for update:
>
> ---
>
> - hosts: all
>   

Re: [ansible-project] Another report creation problem

2024-01-15 Thread Vladimir Botka
Create the variable(s) *output*

- set_fact:
output: "{{ packages.results
|json_query('[].[name, version, release]')
|map('join','-') }}"

Then, use it(them) in the *content*

- copy:
dest: /tmp/installed.txt
content: |
  {% for host in ansible_play_hosts %}
  {{ host }}:
  The following packages will be updated
  {{ hostvars[host]['output']|to_nice_yaml }}
  {% endfor %}
  run_once: true
  delegate_to: localhost

--
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/20240115160246.6e75ab7e%40gmail.com.


pgpgcxf_bpF7F.pgp
Description: OpenPGP digital signature


[ansible-project] error in asnible ""msg": "Failed to import the required Python library (botocore or boto3)"

2024-01-15 Thread 윤세호
After upgrading the ansible version and deploying, errors occur. (Ansible 
ver 2.9.15 -> 2.12.10)
"msg": "Failed to import the required Python library (botocore or boto3) on 
sap-sch-api01-a's Python /usr/bin/python3.8. Please read the module 
documentation and install it in the appropriate location. If the required 
library is installed, but Ansible is using the wrong Python interpreter, 
please consult the documentation on ansible_python_interpreter"

"The Ansible version on the Ansible Control node (Ubuntu 20.04) is 2.12, 
and Python has been upgraded from 3.6.9 to 3.8.10. Similarly, on the 
Ansible Managed node (Ubuntu 18.04), Python has been upgraded from 3.6.9 to 
3.8.0. Despite these upgrades, the same error persists. The boto-related 
packages on the Ansible Control node are installed as follows:"

ii  python3-botocore1.16.19+repack-1ubuntu0.20.04.1 
 all  Low-level, data-driven core of boto 3 (Python 3)
root@sap-tools-a:~# ansible --version
ansible [core 2.12.10]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = 
/root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Nov 22 2023, 10:22:35) [GCC 9.4.0]
  jinja version = 2.10.1
  libyaml = True

-- 
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/67503b94-7ef7-4ad4-a64b-837ed74a2e65n%40googlegroups.com.


Re: [ansible-project] Another report creation problem

2024-01-15 Thread Todd Lewis
You say "the report play does not work", but you don't tell us in what 
way it doesn't work. Is there a template error, undefined variable, or 
something else? Does running with -vv -D indicate anything? "Does not 
work" is too vague. Okay, so it didn't do what you expected, but what 
did it do? Show us the play log.


On 1/15/24 8:00 AM, Dimitri Yioulos wrote:

Good morning.

Let me start by saying that I hope I'm not overdoing my asks. I only 
do it when I've tried, but failed, at a solution. Nextly, I hope your 
kind answers help others, as well. That said, the following playbook 
returns packages that are set for update:


---

- hosts: all
  gather_facts: false

  tasks:
    - name: Check packages to upgrade
      dnf:
        list: updates
      register: packages

    - name: Show packages to upgrade
      debug:
        msg: >-
          {%- set output=[] -%}
          {%- for p in packages.results -%}
          {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ 
p.release)) }}

          {%- endfor -%}
          {{ output }}

    - local_action:
        module: copy
        content: |
          {% for host in ansible_play_hosts %}
          {{ host }}:
          The following packages will be updated

          {%- set output=[] -%}
          {%- for p in packages.results -%}
          {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ 
p.release)) }}

          {%- endfor -%}
          {{ output }}
          {% endfor -%}

        dest: "/tmp/installed.txt"
      run_once: yes
      tags:
        - report

It works fine through the debug play:

ok: [myhost] => {
    "msg": [
        "paho-c-1.3.13-2.el9",
        "cpp-11.4.1-2.1.el9",
        "glibc-headers-2.34-83.el9_3.7",
        "gnutls-dane-3.7.6-23.el9",
        "insights-client-3.2.2-1.el9_2",
        "libblockdev-2.28-7.el9",
        "libblockdev-loop-2.28-7.el9",
        "libfastjson-0.99.9-5.el9",
        ~

However, the report play does not work. I would have thought that 
setting it up like the debug play should do it, but no. How can I get 
that list of updates, along with the hostname, into a textfile report?


As ever, many 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/7348c423-e5f5-46d3-816c-95bb14712c0bn%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/c5cac57d-79d6-4e8d-a3f7-8403a398ae9e%40gmail.com.


[ansible-project] Re: Another report creation problem

2024-01-15 Thread Dimitri Yioulos
Fro what it may be worth, using the yaml  stdout_callback, the output of 
debug looks like this:

ok: [myhost] =>
  msg:
  - paho-c-1.3.13-2.el9
  - cpp-11.4.1-2.1.el9
  - glibc-headers-2.34-83.el9_3.7
  - gnutls-dane-3.7.6-23.el9
  - insights-client-3.2.2-1.el9_2
  - libblockdev-2.28-7.el9
  - libblockdev-loop-2.28-7.el9
  - libfastjson-0.99.9-5.el9

On Monday, January 15, 2024 at 8:00:13 AM UTC-5 Dimitri Yioulos wrote:

> Good morning.
>
> Let me start by saying that I hope I'm not overdoing my asks. I only do it 
> when I've tried, but failed, at a solution. Nextly, I hope your kind 
> answers help others, as well. That said, the following playbook returns 
> packages that are set for update:
>
> ---
>
> - hosts: all
>   gather_facts: false
>
>   tasks:
> - name: Check packages to upgrade
>   dnf:
> list: updates
>   register: packages
>
> - name: Show packages to upgrade
>   debug:
> msg: >-
>   {%- set output=[] -%}
>   {%- for p in packages.results -%}
>   {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ p.release)) 
> }}
>   {%- endfor -%}
>   {{ output }}
>
> - local_action:
> module: copy
> content: |
>   {% for host in ansible_play_hosts %}
>   {{ host }}:
>   The following packages will be updated
>
>   {%- set output=[] -%}
>   {%- for p in packages.results -%}
>   {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ p.release)) 
> }}
>   {%- endfor -%}
>   {{ output }}
>   {% endfor -%}
>
> dest: "/tmp/installed.txt"
>   run_once: yes
>   tags:
> - report
>
> It works fine through the debug play:
>
> ok: [myhost] => {
> "msg": [
> "paho-c-1.3.13-2.el9",
> "cpp-11.4.1-2.1.el9",
> "glibc-headers-2.34-83.el9_3.7",
> "gnutls-dane-3.7.6-23.el9",
> "insights-client-3.2.2-1.el9_2",
> "libblockdev-2.28-7.el9",
> "libblockdev-loop-2.28-7.el9",
> "libfastjson-0.99.9-5.el9",
> ~
>
> However, the report play does not work. I would have thought that setting 
> it up like the debug play should do it, but no. How can I get that list of 
> updates, along with the hostname, into a textfile report?
>
> As ever, many 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/155fc3a9-fd10-494b-a37b-038beb45969fn%40googlegroups.com.


[ansible-project] Another report creation problem

2024-01-15 Thread Dimitri Yioulos
Good morning.

Let me start by saying that I hope I'm not overdoing my asks. I only do it 
when I've tried, but failed, at a solution. Nextly, I hope your kind 
answers help others, as well. That said, the following playbook returns 
packages that are set for update:

---

- hosts: all
  gather_facts: false

  tasks:
- name: Check packages to upgrade
  dnf:
list: updates
  register: packages

- name: Show packages to upgrade
  debug:
msg: >-
  {%- set output=[] -%}
  {%- for p in packages.results -%}
  {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ p.release)) }}
  {%- endfor -%}
  {{ output }}

- local_action:
module: copy
content: |
  {% for host in ansible_play_hosts %}
  {{ host }}:
  The following packages will be updated

  {%- set output=[] -%}
  {%- for p in packages.results -%}
  {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ p.release)) }}
  {%- endfor -%}
  {{ output }}
  {% endfor -%}

dest: "/tmp/installed.txt"
  run_once: yes
  tags:
- report

It works fine through the debug play:

ok: [myhost] => {
"msg": [
"paho-c-1.3.13-2.el9",
"cpp-11.4.1-2.1.el9",
"glibc-headers-2.34-83.el9_3.7",
"gnutls-dane-3.7.6-23.el9",
"insights-client-3.2.2-1.el9_2",
"libblockdev-2.28-7.el9",
"libblockdev-loop-2.28-7.el9",
"libfastjson-0.99.9-5.el9",
~

However, the report play does not work. I would have thought that setting 
it up like the debug play should do it, but no. How can I get that list of 
updates, along with the hostname, into a textfile report?

As ever, many 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/7348c423-e5f5-46d3-816c-95bb14712c0bn%40googlegroups.com.


Re: [ansible-project] trying to debug ansible and win_package

2024-01-15 Thread Divan Santana
> I'm rather clueless with powershell.  I'm now stuck at, how can I
> execute this powershell script block[2] in the same manner as ansible is
> doing it, to see why it's failing to install?  Currently I take the
> scriptblock[2] as is and paste it in powershell which simply returns
> nothing to the screen.

OK, I think I run the powershell script like so via cmd:

powershell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted 
Invoke-Command -ScriptBlock {  param (  [String]  $Arguments,   [Int32[]]  
$ReturnCodes,   [Object]  $Module,   [String]  $Path,   [String]  $State,   
[String]  $WorkingDirectory,   [String]  $RegistryPath,   [Switch]  
$WaitChildren  )   $invokeParams = @{  Module = $Module  ReturnCodes = 
$ReturnCodes  WorkingDirectory = $WorkingDirectory  WaitChildren = 
$WaitChildren  }   if ($Path) {  $invokeParams.CommandLine = 
ConvertTo-EscapedArgument -InputObject $Path  }  else {  $registryProperties = 
Get-ItemProperty -LiteralPath $RegistryPath   if ('QuietUninstallString' -in 
$registryProperties.PSObject.Properties.Name) {  $command = 
$registryProperties.QuietUninstallString  }  elseif ('UninstallString' -in 
$registryProperties.PSObject.Properties.Name) {  $command = 
$registryProperties.UninstallString  }  else {  $module.FailJson("Failed to 
find registry uninstall string at registry path '$RegistryPath'")  }   # If the 
uninstall string starts with '%', we need to expand the env vars.  if 
($command.StartsWith('%') -or $command.StartsWith('"%')) {  $command = 
[System.Environment]::ExpandEnvironmentVariables($command)  }   # If the 
command is not quoted and contains spaces we need to see if it needs to be 
manually quoted for the executable.  if (-not $command.StartsWith('"') -and 
$command.Contains(' ')) {  $rawArguments = 
[System.Collections.Generic.List[String]]@()   $executable = New-Object 
-TypeName System.Text.StringBuilder  foreach ($cmd in ($command | 
ConvertFrom-EscapedArgument)) {  if ($rawArguments.Count -eq 0) {  # Still 
haven't found the path, append the arg to the executable path and see if it 
exists.  $null = $executable.Append($cmd)  $exe = $executable.ToString()  if 
(Test-Path -LiteralPath $exe -PathType Leaf) {  $rawArguments.Add($exe)  }  
else {  $null = $executable.Append(" ") # The arg had a space and we need to 
preserve that.  }  }  else {  $rawArguments.Add($cmd)  }  }   # If we still 
couldn't find a file just use the command literally and hope WIndows can handle 
it,  # otherwise recombine the args which will also quote whatever is needed.  
if ($rawArguments.Count -gt 0) {  $command = @($rawArguments | 
ConvertTo-EscapedArgument) -join ' '  }  }   $invokeParams.CommandLine = 
$command  }   if ($Arguments) {  $invokeParams.CommandLine += " $Arguments"  }  
 Invoke-Executable @invokeParams  }

That results in this error:

'ConvertFrom-EscapedArgument))' is not recognized as an internal or external 
command, operable program or batch file.

Anyone have a clue what's wrong?

My Powershell version is:

  Name   Value
     -
  PSVersion  5.1.17763.5328
  PSEdition  Desktop
  PSCompatibleVersions   {1.0, 2.0, 3.0, 4.0...}
  BuildVersion   10.0.17763.5328
  CLRVersion 4.0.30319.42000
  WSManStackVersion  3.0
  PSRemotingProtocolVersion  2.3
  SerializationVersion   1.1.0.1

.net version is:

  Release in one case says =0x00080eb1=
  InstallPath =C:\Windows\Microsoft.Net\Framework64\v4.0.30319=
  Version =4.8.03761=


-- 
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/87bk9n9d75.fsf%40swift.santanas.co.za.


Re: [ansible-project] Re: trying to debug ansible and win_package

2024-01-15 Thread Divan Santana
>> The win_package action failed to execute in the expected time frame (5) 
>> and was terminated.

> The only time this error ever appears is if you have a timeout set on the 
> task [1]. Check to ensure you don't have that config entry set 
> 'ansible-config dump --only-changed' or haven't set it on the task play.
>
> [1] 
> https://docs.ansible.com/ansible/latest/reference_appendices/config.html#task-timeout

No it's not that sadly.  It times out before 5 seconds anyway.

Checking ansible-config dump --only-changed it says:

ANSIBLE_NOCOWS(/home/opc/vb-ansible-core/ansible.cfg) = True
CALLBACKS_ENABLED(/home/opc/vb-ansible-core/ansible.cfg) = 
['ansible.posix.profile_tasks']
CONFIG_FILE() = /home/opc/vb-ansible-core/ansible.cfg
DEFAULT_BECOME(/home/opc/vb-ansible-core/ansible.cfg) = False
DEFAULT_FORKS(/home/opc/vb-ansible-core/ansible.cfg) = 100
DEFAULT_HOST_LIST(/home/opc/vb-ansible-core/ansible.cfg) = 
['/home/opc/vb-ansible-core/inventories/auto_inventory.oci.yml', 
'/home/opc/vb-ansible-core/invent>
DEFAULT_LOG_PATH(/home/opc/vb-ansible-core/ansible.cfg) = 
/home/opc/vb-ansible-core/.logs/ansible.log
DEFAULT_ROLES_PATH(/home/opc/vb-ansible-core/ansible.cfg) = 
['/home/opc/vb-ansible-core/roles_external', '/home/opc/vb-ansible-core/roles']
DEFAULT_TIMEOUT(/home/opc/vb-ansible-core/ansible.cfg) = 30
HOST_KEY_CHECKING(/home/opc/vb-ansible-core/ansible.cfg) = False
INTERPRETER_PYTHON(/home/opc/vb-ansible-core/ansible.cfg) = auto_silent
RETRY_FILES_ENABLED(/home/opc/vb-ansible-core/ansible.cfg) = True
RETRY_FILES_SAVE_PATH(/home/opc/vb-ansible-core/ansible.cfg) = 
/home/opc/.ansible-retry

Moreover explicitly setting task_timeout = 60 or 0 in ansible.cfg, results in 
the
same error.

-- 
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/87edej9f3i.fsf%40swift.santanas.co.za.