Re: [ansible-project] ansible variables for each os

2023-03-02 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
If you think of it as a JSON dictionary this might explain why you had to do 
that.

This format ...

auditd_pkg:
  CentOS: audit
  Rocky: audit
  Debian: auditd
  Ubuntu: auditd

... is effectively the same as ...

auditd_pkg: { "CentOS": "audit", "Rocky": "audit", "Debian": "auditd", 
"Ubuntu": "auditd" }

Just helping ..

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

On Mar 2, 2023, at 2:20 PM, Kathy L  wrote:

That works,  thanks!

On Thursday, March 2, 2023 at 12:33:32 PM UTC-5 Rowe, Walter P. (Fed) wrote:
You need use the ansible_os_family fact as a key into your auditd_pkg 
dictionary.

{{ auditd_pkg[ansible_os_family] }}

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

On Mar 2, 2023, at 11:57 AM, Kathy L  wrote:

In our playbooks, we used to load one OS-specific vars file for all our roles. 
Now we'd like to move the variables into each role.  A method I had to do this 
before does not seem to be working.  For our auditd role, in the vars/main.yml 
file I have this:

auditd_pkg:
  CentOS: audit
  Rocky: audit
  Debian: auditd
  Ubuntu: auditd

But it gives me this error:

argument 'package' is of type  and we were unable to convert to 
list:

How else can I list these variables without having specific os-related files in 
each role?


--
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/c58a3df2-0639-47fd-85fd-801897604f4cn%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/2a11a576-bdfb-417c-b2b0-5cc437101b39n%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/6CCE27B2-E5BE-4655-87AB-2EF681D57873%40nist.gov.


Re: [ansible-project] ansible variables for each os

2023-03-02 Thread Kathy L
That works,  thanks!

On Thursday, March 2, 2023 at 12:33:32 PM UTC-5 Rowe, Walter P. (Fed) wrote:

> You need use the ansible_os_family fact as a key into your auditd_pkg 
> dictionary. 
>
> {{ auditd_pkg[ansible_os_family] }}
>
> Walter
> --
> Walter Rowe, Division Chief
> Infrastructure Services, OISM
> Mobile: 202.355.4123 <(202)%20355-4123>
>
> On Mar 2, 2023, at 11:57 AM, Kathy L  wrote:
>
> In our playbooks, we used to load one OS-specific vars file for all our 
> roles. Now we'd like to move the variables into each role.  A method I had 
> to do this before does not seem to be working.  For our auditd role, in the 
> vars/main.yml file I have this:
>
> auditd_pkg:
>   CentOS: audit
>   Rocky: audit
>   Debian: auditd
>   Ubuntu: auditd
>
> But it gives me this error:
>
>
>
> *argument 'package' is of type  and we were unable to convert 
> to list: * 
> How else can I list these variables without having specific os-related 
> files in each role?
>
>
> -- 
> 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/c58a3df2-0639-47fd-85fd-801897604f4cn%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/2a11a576-bdfb-417c-b2b0-5cc437101b39n%40googlegroups.com.


Re: [ansible-project] please help on this

2023-03-02 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Sounds like user c8900509 doesn't have sudo permissions to become root.

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

On Mar 2, 2023, at 11:58 AM, Himasree chinthala  
wrote:


---

- name: os patching

  hosts: all

  gather_facts: yes

  become: true

  remote_user: c8900509

  connection: ssh

  tasks:

- name: update os patch

  yum:

name: "*"

state: latest



TASK [update os patch] 
**


fatal: [rn-plecd-lapp01.rno.apple.com]: FAILED! => {"changed": true, "changes": 
{"installed": [], "updated": [["applejdk-17", "1:17.0.6.10.1-1.x86_64 from 
Apple-Internal-linux7"]]}, "msg": "You need to be root to perform this 
command.\n", "rc": 1, "results": ["Loaded plugins: langpacks\n"]}

--
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/e9df9afa-1254-46e0-bff9-437e00c71eean%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/AA8A835D-E528-476B-A83D-ECE6EE69FBF6%40nist.gov.


Re: [ansible-project] ansible variables for each os

2023-03-02 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
You need use the ansible_os_family fact as a key into your auditd_pkg 
dictionary.

{{ auditd_pkg[ansible_os_family] }}

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

On Mar 2, 2023, at 11:57 AM, Kathy L  wrote:

In our playbooks, we used to load one OS-specific vars file for all our roles. 
Now we'd like to move the variables into each role.  A method I had to do this 
before does not seem to be working.  For our auditd role, in the vars/main.yml 
file I have this:

auditd_pkg:
  CentOS: audit
  Rocky: audit
  Debian: auditd
  Ubuntu: auditd

But it gives me this error:

argument 'package' is of type  and we were unable to convert to 
list:

How else can I list these variables without having specific os-related files in 
each role?


--
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/c58a3df2-0639-47fd-85fd-801897604f4cn%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/C1792980-ED56-4299-9461-178182E14276%40nist.gov.


[ansible-project] please help on this

2023-03-02 Thread Himasree chinthala
 

---

- name: os patching

  hosts: all

  gather_facts: yes

  become: true

  remote_user: c8900509

  connection: ssh

  tasks:

- name: update os patch

  yum:

name: "*"

state: latest



TASK [update os patch] 
**

fatal: [rn-plecd-lapp01.rno.apple.com]: FAILED! => {"changed": true, 
"changes": {"installed": [], "updated": [["applejdk-17", 
"1:17.0.6.10.1-1.x86_64 from Apple-Internal-linux7"]]}, "msg": "You need to 
be root to perform this command.\n", "rc": 1, "results": ["Loaded plugins: 
langpacks\n"]}

-- 
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/e9df9afa-1254-46e0-bff9-437e00c71eean%40googlegroups.com.


[ansible-project] ansible variables for each os

2023-03-02 Thread Kathy L
In our playbooks, we used to load one OS-specific vars file for all our 
roles. Now we'd like to move the variables into each role.  A method I had 
to do this before does not seem to be working.  For our auditd role, in the 
vars/main.yml file I have this:

auditd_pkg:
  CentOS: audit
  Rocky: audit
  Debian: auditd
  Ubuntu: auditd

But it gives me this error:



*argument 'package' is of type  and we were unable to convert 
to list:*
How else can I list these variables without having specific os-related 
files in each role?

-- 
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/c58a3df2-0639-47fd-85fd-801897604f4cn%40googlegroups.com.


Re: [ansible-project] How can I pass variables to command module's argv parameter in Ansible?

2023-03-02 Thread tariver 16
I've opened an issue at Ansible GitHub and got explained how argv parameter 
works.
https://github.com/ansible/ansible/issues/79967

Summary:
This happens because of how module and redis-cli utility work with 
arguments.
When passing arguments this modules delimits them with single quotation 
marks, so
- name: Create Redis cluster
  ansible.builtin.command:
argv:
  - /usr/bin/redis-cli
  - "--user {{ redis_admin_user }}"
  - "--pass {{ redis_admin_password }}"
  - "--cluster create {{ redis_cluster_members }}"
  - "--cluster-replicas {{ redis_cluster_replicas }}"
  - --cluster-yes

is passed as (mind the quotation marks)
/usr/bin/redis-cli '--user admin' '--pass mypass' '--cluster create 
10.226.2.194:6379 10.226.2.196:6379 10.226.2.195:6379' '--cluster-replicas 
1' '--cluster-yes'

If you enter this command directly into command line you'll get the same 
error - "Unrecognized option or bad number of args for: '--user admin'".

This is because, quoting redis-cli documentation 
(https://redis.io/docs/ui/cli/#string-quoting-and-escaping),
> When redis-cli parses a command, whitespace characters automatically 
delimit the arguments. 

So the correct way to pass this command will be (mind the quotation marks)
/usr/bin/redis-cli '--user' 'admin' '--pass' 'mypass' '--cluster' 'create ' 
'10.226.2.194:6379' '10.226.2.196:6379' '10.226.2.195:6379' 
'--cluster-replicas' '1' '--cluster-yes' 

So I did a workaround constructing the command as a variable in 
vars/main.yml and then passing it to the module (I'm going to post it on 
stackoverflow).
четверг, 9 февраля 2023 г. в 17:06:24 UTC+3, Rowe, Walter P. (Fed): 

> I had a problem similar to this once. Your redis command might be getting 
> your cluster members as a single string vs separate ip:port args.
>
>
> Walter
> --
> Walter Rowe, Division Chief
> Infrastructure Services, OISM
> Mobile: 202.355.4123 <(202)%20355-4123>
>
> On Feb 9, 2023, at 8:57 AM, tariver 16  wrote:
>
> Thank you for your reply
>
> Changed the shell script to the following:
>
> #!/bin/sh
> ansible-playbook /etc/ansible/playbook-redis.yml -vv \
> --extra-vars "redis_admin_user=admin redis_admin_password=mypass" \
> --extra-vars "redis_cluster_members='10.226.2.194:6379 10.226.2.196:6379 
> 10.226.2.195:6379'" \
> --extra-vars "redis_cluster_replicas=1"
>
> Got the same error "Unrecognized option or bad number of args for: 
> '--cluster create'"
> четверг, 9 февраля 2023 г. в 16:00:41 UTC+3, walte...@nist.gov: 
>
>> #!/bin/sh ansible-playbook /etc/ansible/playbook-redis.yml -vv \
>> --extra-vars*=*'redis_admin_user=admin redis_admin_password=mypass' \
>> --extra-vars*=*'redis_cluster_members="10.226.2.194:6379 
>> 
>>  10.226.2.196:6379 
>> 
>>  10.226.2.195:6379 
>> "
>>  
>> redis_cluster_replicas=1'
>>
>>
>> Leave off the = and use a space for --extra_vars. 
>>
>>   -e EXTRA_VARS, --extra-vars EXTRA_VARS
>> set additional variables as key=value or 
>> YAML/JSON, if filename prepend with @
>>
>> Walter
>> --
>> Walter Rowe, Division Chief
>> Infrastructure Services, OISM
>> Mobile: 202.355.4123 <(202)%20355-4123>
>>
>> On Feb 9, 2023, at 7:01 AM, tariver 16  wrote:
>>
>> Greeting!
>> Asked it on stackoverflow 
>> ,
>>  
>> but didn't get an answer, so I'm trying my luck here.
>>
>> A bit condensed version:
>> I'm