Re: [ansible-project] become sudo not working for apt module

2024-05-13 Thread Stefan Hornburg (Racke)

On 14/05/2024 04:42, Gregory Machin wrote:

Hi

I have a number of ubuntu servers that I want to update using ansible via AWX. 
my current test playbook :

---
  - hosts: all
    tasks:
    - name: Test Connection
      ansible.builtin.ping:

    - name: Update Cache
      become: true
      apt:
        update_cache: true

is not work as expected on the ubuntu servers.
The servers that have the root user configured are fine. But the Ubuntu servers 
where the root user doesn't have a password set are failing with the following 
error:

"Failed to lock apt for exclusive operation: Failed to lock directory 
/var/lib/apt/lists/: E:Could not open lock file /var/lib/apt/lists/lock - open (13: 
Permission denied)"

In AWX I have configured privilege escalation to use sudo but this doesnt help.

I have tried moving the become: yes statement but this did help.

Doe the apt module support the sudo ?

What have I missed ?

Thank you

  Greg


Hello Greg,

you miss "become: true" in your playbook-

Regards
  Racke



--
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/5247dc46-a89e-4685-97af-53f8b91c8be8n%40googlegroups.com
 
.


--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper


--
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/a3c42b1e-fe51-4706-8f08-ce0ea1ceb130%40linuxia.de.


Re: [ansible-project] Get_url

2024-04-10 Thread Stefan Hornburg (Racke)

On 10/04/2024 09:55, Prady A wrote:

Thanks dick

Yes by default those commands doesn’t comes oob.

Tried with verbosity mode.
Request failed:”


It is possible that the SSL setup on the target is too old. You could check that
with the "testssl" script from the controller (https://testssl.sh/).

Regards
Racke



On Wed, 10 Apr 2024 at 16:15, Dick Visser mailto:dnmvis...@gmail.com>> wrote:

Too bad, that would have helped to indicate SSL issues on that remote host.
Try running with more verbosity (-vvv) and see what that returns.

-- 
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/CAF8BbLZmEaBXSvNPCJK7cAmxmm0uq%3DEwPq27omdkLiq8eL5beQ%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/CAEuB3ArncgH9yXxg_Gh_v8xqQ9NQcgNNV8xm_HABkN5kiBRRsA%40mail.gmail.com
 
.


--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper


--
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/1564c781-cba4-46f1-9228-9a4fac8ef2a7%40linuxia.de.


Re: [ansible-project] Re: restart service only if its successful

2023-07-12 Thread Stefan Hornburg (Racke)

On 12/07/2023 13:30, Dick Visser wrote:

Hii,


On Wed, 12 Jul 2023 at 12:53, Sameer Modak  wrote:

Hi Todd,

I tried to run script with shell module but it fails with below error,

[kafka-3: FAILED! => {"changed": true, "cmd": "if pkill --signal 9 -f zookeeper.properties ; then\nsystemctl start confluent-zookeeper510\nelse\nexit 1\nfi\nsystemctl status confluent-zookeeper510\n", "delta": 
"0:00:00.034111", "end": "2023-07-12 10:31:58.344951", "failed_when_result": true, "msg": "non-zero return code", "rc": -9, "start": "2023-07-12 10:31:58.310840", "stderr": 
"", "stderr_lines": [], "stdout": "", "stdout_lines": []}

fatal: [kafka-4]: FAILED! => {"changed": true, "cmd": "if pkill --signal 9 -f zookeeper.properties ; then\nsystemctl start confluent-zookeeper510\nelse\nexit 1\nfi\nsystemctl status confluent-zookeeper510\n", "delta": 
"0:00:00.032830", "end": "2023-07-12 10:31:59.744091", "failed_when_result": true, "msg": "non-zero return code", "rc": -9, "start": "2023-07-12 10:31:59.711261", "stderr": 
"", "stderr_lines": [], "stdout": "", "stdout_lines": []}

===

code:

- name: Kill running java processes and start newly configured systemd

throttle: 1

#ignore_errors: yes

any_errors_fatal: true

shell: |

if [ pkill --signal 9 -f zookeeper.properties ] ; then

systemctl start confluent-zookeeper510; sleep 2; echo "stat" | nc localhost 
2181;st="$?" systemctl status confluent-zookeeper510 -l | grep -v ERRROR;et="$?"


I feel we're going down a rabbit hole trying to fight ill designed systemd 
units with shell hacks (which include typos? ERRROR instead of ERROR).
My approach would be to make sure the systemd unit is doing what it should do, 
and then rely on that to do its job


Certainly!

Regards

 Racke



--
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/CAF8BbLZQ7v-K7vSnFkGsVYwm_6a9HO3f1Cf7r8yBM%2Bb_DQcj4A%40mail.gmail.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/782f4e8a-bc5f-5799-be22-8f9f66d9edb7%40linuxia.de.


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

2023-03-13 Thread Stefan Hornburg (Racke)

On 13/03/2023 17:39, 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 }}



Hello, you need to quote the argument for the loop:

  loop: '{{ file }}'

Regards
  Racke


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


--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper


--
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/c3f29330-5459-ea46-c912-eee5ed0c0eb3%40linuxia.de.


Re: [ansible-project] I want to show the group variables, looping over all groups

2023-02-08 Thread Stefan Hornburg (Racke)

On 08/02/2023 09:58, Norbert Klamann wrote:

Yes of course , it should look  like this
```
all                   - "alle interessierenden Hosts, auch nicht per ansible 
kontrollierbare"
controllable          - Alle Hosts, die mit ansible kontrolliert werden koennten
fm174                 - Alle Hosts in FM 174 (soweit Ansible-fähig)
hetzner               - Alle Hosts bei Hetzner (cloud)
virtual_ansible_hosts - Nicht per Ansible erreichbare Maschinen, aber sie 
sollen durch (Meta-) Variablen doukmentiert werden
virtual_FM174         - Virtuelle Ansible Hosts in FM174

```


Hello Norbert,

take a look at the Jinja sort filter: 
https://jinja.palletsprojects.com/en/3.0.x/templates/#jinja-filters.sort

Regards

    Racke


ra...@linuxia.de schrieb am Mittwoch, 8. Februar 2023 um 09:47:53 UTC+1:

On 08/02/2023 09:21, Norbert Klamann wrote:
> Hello all,
> i use Ansible to document and manage a small network of computers and 
other devices. So I bulit an inventory with several groups and hosts and defined a 
bunch of variables  on each level to describe what i want to achieve,  Each host 
and each group has for example a variable named `host_comment` or `group_comment` 
respectively.
>
> This is very useful on the host level, but i want to show the group 
variables separately in a loop over all groups.
>
> I can show a group variable via `hostvars[host].group_comment`but because 
every hosts belongs to several groups i cannot control, whicht name is displayed.
>
> This template
> ```
> {% forgroupingroupsifgroup!='ungrouped'%}
>   {% forhostingroups[group]%}
>   {% ifloop.first%}{% sethvh=hostvars[host]%}
> {{ group }}{{ hvh.group_comment }}
>   {% endif%}
>   {% endfor%}
> {% endfor%}
> ```
>
> gives
> ```
>   all     Nicht per Ansible erreichbare Maschinen, aber sie sollen durch 
(Meta-) Variablen doukmentiert werden
>   lxc_container     Alle Hosts in FM 174 (soweit Ansible-fähig)
>   fm174     Alle Hosts in FM 174 (soweit Ansible-fähig)
>   hetzner     Alle Hosts bei Hetzner (cloud)
>   controllable     Alle Hosts in FM 174 (soweit Ansible-fähig)
>   virtual_FM174     Virtuelle Ansible Hosts in FM174
>   virtual_ansible_hosts     Nicht per Ansible erreichbare Maschinen, aber 
sie sollen durch (Meta-) Variablen doukmentiert werden
>
> ```
> I think it is visible that this result makes no sense.

Hello Norbert,

can you give an example of the desired output?

Regards

    Racke


>
> Can anyone help here ?
>
> Thanks a lot !
>
> Norbert
>
>
> --
> 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/fadc4912-aaab-4cfa-aa18-22dd5fe1d12dn%40googlegroups.com
 
>.


-- 
Automation expert - Ansible and friends

Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/74860064-0aef-4a92-acb3-4ff9cdfd0efcn%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/f197ff9a-b4f1-eb55-c7ab-61b65fbb39c3%40linuxia.de.


Re: [ansible-project] I want to show the group variables, looping over all groups

2023-02-08 Thread Stefan Hornburg (Racke)

On 08/02/2023 09:21, Norbert Klamann wrote:

Hello all,
i use Ansible to document and manage a small network of computers and other 
devices. So I bulit an inventory with several groups and hosts and defined a 
bunch of variables  on each level to describe what i want to achieve,  Each 
host and each group has for example a variable named `host_comment` or 
`group_comment` respectively.

This is very useful on the host level, but i want to show the group variables 
separately in a loop over all groups.

I can show a group variable via `hostvars[host].group_comment`but because every 
hosts belongs to several groups i cannot control, whicht name is displayed.

This template
```
{% forgroupingroupsifgroup!='ungrouped'%}
  {% forhostingroups[group]%}
  {% ifloop.first%}{% sethvh=hostvars[host]%}
{{ group }}{{ hvh.group_comment }}
  {% endif%}
  {% endfor%}
{% endfor%}
```

gives
```
  all     Nicht per Ansible erreichbare Maschinen, aber sie sollen durch 
(Meta-) Variablen doukmentiert werden
  lxc_container     Alle Hosts in FM 174 (soweit Ansible-fähig)
  fm174     Alle Hosts in FM 174 (soweit Ansible-fähig)
  hetzner     Alle Hosts bei Hetzner (cloud)
  controllable     Alle Hosts in FM 174 (soweit Ansible-fähig)
  virtual_FM174     Virtuelle Ansible Hosts in FM174
  virtual_ansible_hosts     Nicht per Ansible erreichbare Maschinen, aber sie 
sollen durch (Meta-) Variablen doukmentiert werden

```
I think it is visible that this result makes no sense.


Hello Norbert,

can you give an example of the desired output?

Regards

    Racke




Can anyone help here ?

Thanks a lot !

Norbert


--
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/fadc4912-aaab-4cfa-aa18-22dd5fe1d12dn%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/337d16dc-9472-b46c-8bf1-08565fff84cd%40linuxia.de.


Re: [ansible-project] why does this loop/when fail

2022-11-21 Thread Stefan Hornburg (Racke)

On 21/11/2022 14:01, rjwagn...@gmail.com wrote:

Wow.  Never would have thought to try that.  Escaping in YAML/Jinja is such an 
unintuitive mess.  Thanks so much, Andrew.


It is easier though when you use single quotes for the arguments of the 
regex_replace filter.

Regards

   Racke




On Friday, November 18, 2022 at 4:59:47 PM UTC-5 lat...@gmail.com wrote:



ok, here it is. should be \\1 vs \1 in your replacement and test(is) on 
string contents(in)


  - name: task 3
    debug:
      msg: "{{ item }} is in the s"
    loop: "{{ t_list }}"
    when: ( item | regex_replace("^p(\d+).*$", "\\1") ) is in s

  - name: task 3.orig

    debug:
      msg: "{{ item }} is in s"
    loop: "{{ t_list }}"
    when: ( item | regex_replace("^p(\d+).*$", "\1") ) in s



TASK [task 3] 

ok: [localhost] => (item=p1_xyz) => {
   "msg": "p1_xyz is in the s"
}
ok: [localhost] => (item=p2_xyz) => {
   "msg": "p2_xyz is in the s"
}

TASK [task 3.orig] 
***
skipping: [localhost] => (item=p1_xyz)
skipping: [localhost] => (item=p2_xyz)
skipping: [localhost]

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


I did this in a hurry, so there may be mistakes or more awesome ways of 
doing this. YMMV


On Fri, Nov 18, 2022 at 2:05 PM Andrew Latham  wrote:

Rob

Trying to follow along, So on Task 3 you want to iterate over the list 
t_list and match if the digit is in variable s? First thought is that you are 
testing if an int is a string.





On Fri, Nov 18, 2022 at 12:00 PM rjwagn...@gmail.com 
 wrote:

Hey all - I think I'm losing my mind.  Can anyone explain why every 
iteration of task 3 is being skipped (compare w/ task 2, especially)?

(ansible2_12_8) rowagn@mlb656 client % cat d.yml
- hosts: all
  gather_facts: no
  vars:
    s: '1 2 3'
    t: p1_xyz
    t_list:
      - p1_xyz
      - p2_xyz

  tasks:
  - name: task 1
    debug:
      msg: '{{ ( t | regex_replace("^p(\d+).*$", "\1") ) in s }}'

  - name: task 2
    debug:
      msg: '{{ ( item | regex_replace("^p(\d+).*$", "\1") ) in s }}'
    loop: "{{ t_list }}"

  - name: task 3
    debug:
      msg: "{{ item }} is in s"
    loop: "{{ t_list }}"
    when: ( item | regex_replace("^p(\d+).*$", "\1") ) in s
(ansible2_12_8) rowagn@mlb656 client % ansible-playbook d.yml -i 
~/localhost

PLAY [all] 
**

TASK [task 1] 
***
ok: [localhost] => {
    "msg": true
}

TASK [task 2] 
***
ok: [localhost] => (item=p1_xyz) => {
    "msg": true
}
ok: [localhost] => (item=p2_xyz) => {
    "msg": true
}

TASK [task 3] 
***
skipping: [localhost] => (item=p1_xyz)
skipping: [localhost] => (item=p2_xyz)
skipping: [localhost]

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

I've started at this for hours.

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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/88a55b8c-718d-4a61-88c3-bf989525e65cn%40googlegroups.com
 
.



-- 
- Andrew "lathama" Latham -




-- 
- Andrew "lathama" Latham -


--
You received this message because you 

Re: [ansible-project] Archiving user home directories with a var_files

2022-11-01 Thread Stefan Hornburg (Racke)

On 01/11/2022 18:42, Kenady Inampudi wrote:

even with loop: "{{ users }}"  there is no difference


I think you need to loop over {{ user }} and in path/dest use {{ item }}, the 
default loop variable.

Regards

    Racke



archive_home_dir.yml
---
- hosts: all
  tasks:
     - archive:
          path: /home/{{ user }}
          dest: /home/archive/{{ user }}.tar.gz
          format: gz
       loop: "{{ users }}"

it still creates
-rw-r--r--    1 root     system           88 Nov 01 13:37 [u'user1', 
u'user2'].tar.gz

ansible-playbook -i test_host archive_home_dir.yml -e @users.yml

PLAY [all] 


TASK [archive] 

changed: [server1] => (item=user1)
ok: [server1] => (item=user2)
changed: [server2] => (item=user1)
ok: [server2] => (item=user2)
changed: [server3] => (item=user1)
ok: [server3] => (item=user2)

PLAY RECAP 

server1               : ok=1    changed=1    unreachable=0  failed=0    
skipped=0    rescued=0    ignored=0
server2                : ok=1    changed=1    unreachable=0  failed=0    
skipped=0    rescued=0    ignored=0
server3                : ok=1    changed=1    unreachable=0  failed=0    
skipped=0    rescued=0    ignored=0

On Tuesday, November 1, 2022 at 10:55:44 PM UTC+5:30 lat...@gmail.com wrote:

Kenady,

I think you are looking to loop[1] the users correct?

aka

loop: "{{ users }}"

1. https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html



On Tue, Nov 1, 2022 at 10:31 AM Kenady Inampudi  wrote:

Archiving user home directories


user.yml
---
user:
  - user1
  - user2

archive_home_dir.yml
---
- hosts: all
  tasks:
     - archive:
          path: /home/{{ user }}
          dest: /home/archive/{{ user }}.tar.gz
          format: gz
ansible-playbook archive_home_dir.yml -e @user.yml

i get
-rw-r--r--    1 root     system           88 Nov 01 11:58 [u'user1', 
u'user2'].tar.gz

i was expecting
-rw-r--r--    1 root     system           88 Nov 01 11:58 user1.tar.gz
-rw-r--r--    1 root     system           88 Nov 01 11:58 user2.tar.gz

-- 
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/3df53de7-82a5-4430-9146-8c03755f923an%40googlegroups.com
 
.



-- 
- Andrew "lathama" Latham -


--
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/4f42f266-404e-44b8-b851-1d6728d0cd14n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/6b01fa72-55bb-5931-e227-fca47410%40linuxia.de.


Re: [ansible-project] Doing su -c 'ssh {{ ssh_peer }}'

2022-10-13 Thread Stefan Hornburg (Racke)

On 12/10/2022 21:19, Axel Rau wrote:

If I install sudo, this seems to work:
- - -
shell: sudo -u {{ sk_user }} ssh {{ ssh_peer }} date
- - -


Ansible can do the privilege escalation to an arbitrary user as well:

  command: ssh {{ ssh_peer }} date

  become_user: "{{ sympa_unix_user }}"
  vars:
    ansible_ssh_pipelining: true

Regards

  Racke


Axel


Am 12.10.2022 um 19:48 schrieb Axel Rau :

OS is FreeBSD.

A.


Am 12.10.2022 um 19:31 schrieb Axel Rau :

Hi all,

This stopped working after some upgrade of ansible:

- - -
 - name: Test new ssh connection
   command: "su {{ sk_user }} -c 'ssh {{ ssh_peer }} date‘“
- - -

It just hungs in the shell.

How can this be done in 2.13.1?

Any help appreciated,
Axel
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius

--
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/1C3B0288-958C-4BC3-B3B2-59BB3DCCFCEF%40Chaos1.DE.


---
PGP-Key: CDE74120  ☀  computing @ chaos claudius


--
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/8663F1A6-8A70-4DF8-902C-75532D165EC2%40Chaos1.DE
 
.


---
PGP-Key: CDE74120  ☀  computing @ chaos claudius

--
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/1F508E13-30F7-4376-9A8F-1CDBD7AC8397%40Chaos1.DE
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/d3bf6751-c16c-80a1-fd5a-dee393cc8573%40linuxia.de.


Re: [ansible-project] Re: Ansible dict date to csv file

2022-09-10 Thread Stefan Hornburg (Racke)

On 10/09/2022 18:44, Sagan wrote:

IF you have your closters has dicts in your variable you can use a loop with 
dict2items and loop around it, as to writing it in your file you can use this 
module
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html


Using lineinfile doesn't make sense when your write the whole file. In this 
case the template module is the better choice.

Regards

 Racke




On Saturday, September 10, 2022 at 5:47:07 PM UTC+2 ahar...@gmail.com wrote:

Hello All,

I'm looking for help on below guery. As  bit new to Anisble I could not 
find solution thought I sent lot of time..

Thank you in advance.

I have data getting through set_fact/ *json_query* using *loop*  for 
multiple clusters as below example.
I have saved date to /*variable*/: *Clusters*
It would be like this when I read variable saved data.

*Clusters*:
192.168.1.1 :
- node: node1
  state: up

192.168.1.2 :
- node: nod2
   state: down

192.168.1.3 :
-node: node3
  state: up

and so on

How do I get this date to csv file like below?

Clusters,192.168.1.1,node1,up
Clusters,192.168.1.2,node2,down
Clusters,192.168.1.3,node3,up

--
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/24e2bebe-0759-4512-9347-d993a0b10f87n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/151098b0-98da-c694-4c36-f431d3b5e5ed%40linuxia.de.


Re: [ansible-project] Lineinfile - Remove line if the regexp match but the variable inside item is not defined.

2022-08-08 Thread Stefan Hornburg (Racke)

On 08/08/2022 14:19, farrukh ahmed wrote:

Hello Team,

Hope you all are doing well.

I'm stuck at lineinfile module.

how to check if a variable inside each item is defined then add the line in the 
file, otherwise if the regex found the match in the remote host file but the 
variable inside an item is not defined then remove only that regex matched line 
from the file. And continue to the next item (should not terminate the module 
execution and continue to next item if variable is not defined).

CASE:

### Here is my defaults > main.yml
```
command: /home/farrukh/idle.sh
autostart: true
autorestart: true
stderr_logfile: /var/log/idle.err.log
stdout_logfile: /var/log/idle.out.log
numprocs: 2
```

### Here is tasks > main.yml
```
- name: "Update Job Parameters in .conf file"
lineinfile:
path: "{{ supervisor_config_path }}/job_{{ job_name }}.conf"
backrefs: yes
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
when: item.line is not search(omit)
with_items:
- { regexp: '^command', line: "command={{ command | d(omit) }}M" }
- { regexp: '^autostart', line: "autostart={{ autostart | d(omit) }}" }
- { regexp: '^autorestart', line: "autorestart={{ autorestart | d(omit) }}M" }
- { regexp: '^stderr_logfile', line: "stderr_logfile={{ stderr_logfile | d(omit) 
}}" }
- { regexp: '^stdout_logfile', line: "stdout_logfile={{ stdout_logfile | d(omit) 
}}" }
- { regexp: '^numprocs', line: "numprocs={{ numprocs | d(omit) }}" }
```

### Here is the file on the remote host "job_idle.conf"
```
[program:job_idle]
command=/home/ubuntu/idle.sh
autostart=true
autorestart=true
stderr_logfile=/var/log/idle.err.log
stdout_logfile=/var/log/idle.out.log
```

Now, for instance, If I comment out the variable "autorestart" from the defaults 
> main.yml. like below:

### defaults > main.yml
```
command: /home/farrukh/idle.sh
autostart: true
#autorestart: true
stderr_logfile: /var/log/idle.err.log
stdout_logfile: /var/log/idle.out.log
numprocs: 2
```

Then running playbook, should get the desired result of job_idle.conf like 
below:
## The file on the remote host "job_idle.conf"
```
[program:job_idle]
command=/home/ubuntu/idle.sh
autostart=true
stderr_logfile=/var/log/idle.err.log
stdout_logfile=/var/log/idle.out.log
```

It should remove the line autorestart. As the variable "autorestart" was commented 
out from defaults > main.yml and not defined.

It is this case achievable with this module?



Looking at your output file it is a real candidate for the template module. 
lineinfile is a bit tricky, but it can be useful to replace
a few lines in a larger file.

Regards
 Racke


--
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/37833105-7d83-4b60-a5d5-2d90d4366b3en%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/e745abd2-9a69-64da-4df0-02488ea21d35%40linuxia.de.


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

2022-08-05 Thread Stefan Hornburg (Racke)

On 05/08/2022 13:31, farrukh ahmed wrote:

Thanks for your reply Vladimir Botka.

This is my actual case:

 defaults > main.yml
---
# defaults file for redis_configs
redis_config_path: /etc/redis/redis.conf

# Default Params Values
MAX_MEM: 3000
TCP_KEEPALIVE: 0
TCP_BACKLOG: 511
MAX_CLIENTS: 15000
TIMEOUT: 1500


And this is:

Tasks > main.yml

---

- name: "Update Redis Parameters in {{ redis_config_path }}"
  lineinfile:
    path: "{{ redis_config_path }}"
  backrefs: yes
  regexp: "{{ item.regexp }}"
  line: "{{ item.line }}"
  with_items:
    - { regexp: '^maxmemory', line: "maxmemory {{ MAX_MEM }}mb", when: {{ 
MAX_MEM }} is defined }
    - { regexp: '^tcp-keepalive', line: "tcp-keepalive {{ TCP_KEEPALIVE }}", 
when: {{ TCP_KEEPALIVE }} is defined }
    - { regexp: '^tcp-backlog', line: "tcp-backlog {{ TCP_BACKLOG }}", when: {{ 
TCP_BACKLOG }} is defined}
    - { regexp: '^maxclients', line: "maxclients {{ MAX_CLIENTS }}", when: {{ 
MAX_CLIENTS }} is defined}
    - { regexp: '^timeout', line: "timeout {{ TIMEOUT }}" }


I want this to check if each variable inside an item is defined then make the 
changes to the line in the file, otherwise skip only those items which 
variables is not defined.
For Instance, If I comment out the variable MAX_MEM from the defaults > 
main.yml. like below:

# Default Params Values
##MAX_MEM: 3000
TCP_KEEPALIVE: 0
TCP_BACKLOG: 511
MAX_CLIENTS: 15000
TIMEOUT: 1500

Then the execution should skip changes to the line where MAX_MEM is undefined, 
and the rest lines should be changed as they defined.

Is it possible?


Sorry, but it eludes me why you didn't come up with the actual case in the 
first place.  I see no point in wasting everyone's time.

Regards

    Racke



On Friday, August 5, 2022 at 2:18:05 PM UTC+5 vbo...@gmail.com wrote:

On Thu, 4 Aug 2022 23:43:59 -0700 (PDT)
farrukh ahmed  wrote:

> with_items:
> - { regexp: '^text1', line: "text1 = {{ VAR1 }}", when: VAR1 is defined }
> - { regexp: '^text2', line: "text2 = {{ VAR2 }}" }
> - { regexp: '^text3', line: "text3 = {{ VAR3 }}" }

Set *default* to avoid errors, add attribute *def*, and select lines.
For example,

shell> cat pb.yml
---
- hosts: localhost
gather_facts: false
vars:
lines:
- regexp: '^text1'
line: 'text1 = {{ VAR1|d("undef") }}'
def: '{{ VAR1 is defined }}'
- regexp: '^text2'
line: 'text2 = {{ VAR2|d("undef") }}'
def: '{{ VAR2 is defined }}'
- regexp: '^text3'
line: 'text3 = {{ VAR3|d("undef") }}'
def: '{{ VAR3 is defined }}'
tasks:
- debug:
var: item
loop: "{{ lines|selectattr('def') }}"

gives

shell> ansible-playbook pb.yml -e VAR1=test

PLAY [localhost]
*

TASK [debug]
*
ok: [localhost] => (item={'regexp': '^text1', 'line': 'text1 = test',
'def': True}) => ansible_loop_var: item item:
def: true
line: text1 = test
regexp: ^text1

-- 
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/0eaa1c36-727c-47a8-bebc-6f38db9f4971n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/4a22e810-d112-6d68-1a57-72661775e675%40linuxia.de.


Re: [ansible-project] Unarchive module

2022-08-03 Thread Stefan Hornburg (Racke)

On 03/08/2022 17:21, rajthecomputerguy wrote:

Hi Team,

below code failing. Any help would be appreciated

- name: unarchive the patch
   unarchive:
       src: ***
       dest: **
       remote_src: yes

zip file is 1.5 gb
 error is  msg: "fail to connect host to host vis ssh:"
other few files are unzipping without issue
Ansible version: >2.9
platform: Redhat


The target server might not have enough resources to unpack the archive.

Regards

   Racke




--
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/8ab7b960-0baf-41dc-9ea7-0d2936662bd0n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/319974f2-70ab-e7f8-b2cc-5567bc790781%40linuxia.de.


Re: [ansible-project] moving a folder on a remote whether it exists

2022-07-27 Thread Stefan Hornburg (Racke)

On 27/07/2022 13:11, dulhaver via Ansible Project wrote:

On 07/27/2022 11:09 AM CEST Stefan Hornburg (Racke)  wrote:

  
On 27/07/2022 10:33, dulhaver via Ansible Project wrote:

I am trying to rename/move a folder on a remote host and try to do this based 
on whether it exists

That doesn't look like a proper path: "path": " /opt/db/backup/postgres/backups 
".

Also it doesn't coincide with your playbook.

sorry, my bad. I have several identical actions and mixed up the TASK of one 
with the return of another. So in reality they match up. The installation path 
/opt/db/postgres is what we do here in my context (despite the standard 
/var/lib/pgsql/...).


You still have spurious white space in your path:

"invocation": {
"module_args": {
"checksum_algorithm": "sha1",
"follow": false,
"get_attributes": true,
"get_checksum": true,
"get_md5": false,
"get_mime": true,
"path": " /opt/db/postgres "
}
},

That's the reason why the next task is skipped.

Regards

    Racke




 my TASK 
###

- name: move legacy postgres - stat postgres_base
   stat: path=/opt/db/postgres
   register: postgres_base_stat

- name: move legacy postgres - move postgres_base to postgres_base_legacy
   command: mv /opt/db/postgres /opt/db/postgres/legacy"
   when: postgres_base_stat.stat.exists


 feedback  
#

TASK [postgres_disable : move legacy postgres - stat postgres_base] 
**
task path: 
/home/gwagner/repos/ansible/open_source/postgres_upgrade/roles/postgres_disable/tasks/main.yml:16
 ESTABLISH SSH CONNECTION FOR USER: None
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 
KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/8ca9f05e1f"' 
rhel8-vm.local '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
 (0, b'/home/gwagner\n', b'')
 ESTABLISH SSH CONNECTION FOR USER: None
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 
'ControlPath="/home/gwagner/.ansible/cp/8ca9f05e1f"' rhel8-vm.local '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/gwagner/.ansible/tmp 
`"&& mkdir "` echo /home/gwagner/.ansible/tmp/ansible-tmp-1658919873.2246733-63503-154421168863718 `" && echo 
ansible-tmp-1658919873.2246733-63503-154421168863718="` echo /home/gwagner/.ansible/tmp/ansible-tmp-1658919873.2246733-63503-154421168863718 `" ) && sleep 
0'"'"''
 (0, 
b'ansible-tmp-1658919873.2246733-63503-154421168863718=/home/gwagner/.ansible/tmp/ansible-tmp-1658919873.2246733-63503-154421168863718\n',
 b'')
Using module file /usr/lib/python3.8/site-packages/ansible/modules/stat.py
 PUT 
/home/gwagner/.ansible/tmp/ansible-local-63470u1tpvd24/tmp5yf_h4ad TO 
/home/gwagner/.ansible/tmp/ansible-tmp-1658919873.2246733-63503-154421168863718/AnsiballZ_stat.py
 SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o 
StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
'ControlPath="/home/gwagner/.ansible/cp/8ca9f05e1f"' '[rhel8-vm.local]'
 (0, b'sftp> put 
/home/gwagner/.ansible/tmp/ansible-local-63470u1tpvd24/tmp5yf_h4ad 
/home/gwagner/.ansible/tmp/ansible-tmp-1658919873.2246733-63503-154421168863718/AnsiballZ_stat.py\n',
 b'')
 ESTABLISH SSH CONNECTION FOR USER: None
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 
KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/8ca9f05e1f"' 
rhel8-vm.local '/bin/sh -c '"'"'chmod u+x 
/home/gwagner/.ansible/tmp/ansible-tmp-1658919873.2246733-63503-154421168863718/ 
/home/gwagner/.ansible/tmp/ansible-tmp-1658919873.2246733-63503-154421168863718/AnsiballZ_stat.py && sleep 
0'"'"''
 (0, b'', b'')
 ESTABLISH SSH CONNECTION FOR USER: None
 SSH: EXEC ssh -C -o ControlMaster=auto -o 

Re: [ansible-project] moving a folder on a remote whether it exists

2022-07-27 Thread Stefan Hornburg (Racke)

On 27/07/2022 10:33, dulhaver via Ansible Project wrote:

I am trying to rename/move a folder on a remote host and try to do this based 
on whether it exists


That doesn't look like a proper path: "path": " /opt/db/backup/postgres/backups 
".

Also it doesn't coincide with your playbook.

Regards

    Racke



2 TASKS should be doing this

- name: move legacy postgres - stat postgres_base
  stat: path=/opt/db/postgres
  register: postgres_base_stat
- name: move legacy postgres - move postgres_base to postgres_base_legacy
    command: mv /opt/db/postgres /opt/db/postgres/legacy"
    when: postgres_base_stat.stat.exists

The TASKS run through, but do not move the folder as intended, apparently because the stat TASK 
does not return the right value ("skip_reason": "Conditional result was False")
Do I have to reverse the when clause?
below the detailed output
TASK [postgres_disable : move legacy postgres - stat "postgres_back"] 
***
task path: 
/home/gwagner/repos/ansible/open_source/postgres_upgrade/roles/postgres_disable/tasks/main.yml:32
 ESTABLISH SSH CONNECTION FOR USER: None
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 
KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/8ca9f05e1f"' 
rhel8-vm.local '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
 (0, b'/home/gwagner\n', b'')
 ESTABLISH SSH CONNECTION FOR USER: None
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 
'ControlPath="/home/gwagner/.ansible/cp/8ca9f05e1f"' rhel8-vm.local '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/gwagner/.ansible/tmp 
`"&& mkdir "` echo /home/gwagner/.ansible/tmp/ansible-tmp-1658907975.2889578-62723-197073820787608 `" && echo 
ansible-tmp-1658907975.2889578-62723-197073820787608="` echo /home/gwagner/.ansible/tmp/ansible-tmp-1658907975.2889578-62723-197073820787608 `" ) && sleep 
0'"'"''
 (0, 
b'ansible-tmp-1658907975.2889578-62723-197073820787608=/home/gwagner/.ansible/tmp/ansible-tmp-1658907975.2889578-62723-197073820787608\n',
 b'')
Using module file /usr/lib/python3.8/site-packages/ansible/modules/stat.py
 PUT 
/home/gwagner/.ansible/tmp/ansible-local-626726_zsgrbg/tmpxz0n4329 TO 
/home/gwagner/.ansible/tmp/ansible-tmp-1658907975.2889578-62723-197073820787608/AnsiballZ_stat.py
 SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o 
StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
'ControlPath="/home/gwagner/.ansible/cp/8ca9f05e1f"' '[rhel8-vm.local]'
 (0, b'sftp> put 
/home/gwagner/.ansible/tmp/ansible-local-626726_zsgrbg/tmpxz0n4329 
/home/gwagner/.ansible/tmp/ansible-tmp-1658907975.2889578-62723-197073820787608/AnsiballZ_stat.py\n',
 b'')
 ESTABLISH SSH CONNECTION FOR USER: None
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 
KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/8ca9f05e1f"' 
rhel8-vm.local '/bin/sh -c '"'"'chmod u+x 
/home/gwagner/.ansible/tmp/ansible-tmp-1658907975.2889578-62723-197073820787608/ 
/home/gwagner/.ansible/tmp/ansible-tmp-1658907975.2889578-62723-197073820787608/AnsiballZ_stat.py && sleep 
0'"'"''
 (0, b'', b'')
 ESTABLISH SSH CONNECTION FOR USER: None
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 
KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/8ca9f05e1f"' -tt 
rhel8-vm.local '/bin/sh -c '"'"'/usr/libexec/platform-python 
/home/gwagner/.ansible/tmp/ansible-tmp-1658907975.2889578-62723-197073820787608/AnsiballZ_stat.py && sleep 
0'"'"''
 (0, b'\r\n{"changed": false, "stat": {"exists": false}, "invocation": {"module_args": {"path": " /opt/db/backup/postgres/backups ", 
"follow": false, "get_md5": false, "get_checksum": true, "get_mime": true, "get_attributes": true, "checksum_algorithm": "sha1"}}}\r\n', b'Shared 
connection to rhel8-vm.local closed.\r\n')
 ESTABLISH SSH CONNECTION FOR USER: None
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 
KbdInteractiveAuthentication=no -o 

Re: [ansible-project] 'copy' TASK won't copy a file - eventhough reporting 'ok'

2022-07-14 Thread Stefan Hornburg (Racke)

On 14/07/2022 15:41, dulhaver via Ansible Project wrote:

I have a TASK that should copy *~/files/repo_pgbackrest.conf* to the remote as 
*/etc/pgbackrest/pgbackrest.conf* (note the differing file name).
however, despite that fact playbook exection returns an 'ok' an that TASK, the 
file is *not pushed* to the remote.
==
- name: install preps - push config file
   copy:
     src: files/repo_pgbackrest.conf # was: repo_pgbackrest.conf
     dest: " {{ item }} "
     mode: '0640'
owner: pgbackrest
     group: pgbackrest
   become: true
   loop:
     - /etc/pgbackrest/pgbackrest.conf
==
Knowing that sometimes things only work after several re-runs I executed this 
about 5 times with the exact same, unwanted behavior.
So ... what am I doing wrong here?


My suspicion would be that you are looking at the wrong target.

Regards
   Racke


--
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/1699810404.552239.1657806094344%40office.mailbox.org
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/3598550b-2738-e7de-024b-59326633d7a4%40linuxia.de.


Re: [ansible-project] Unable to create the partition

2022-07-08 Thread Stefan Hornburg (Racke)

On 08/07/2022 10:04, Ashok Reddy wrote:

Hi,

I am trying to create the partition, but got the following error:


I think that the error message is clear about the problem. The device doesn't 
exist.

Regards
 Racke



---

- hosts: default

   become: true

   become_method: sudo

   tasks:

     - name: part1

       parted:

         device: "/dev/vdb"

         number: 1

         state: present

     - name: filesystem

       filesystem:

         fstype: ext4

         dev: /dev/vdb

     - name: mounted

       mount:

         path: /opt

         src: /dev/vdb

         fstype: ext4

         state: mounted


     - name: partition

       lvg:

         vg: "datavg"

         pvs: "/dev/vdb"

         state: present

     - name: resize pv

       command: "pvresize /dev/vdb"


     - name: activate vg

       command: "vgchange -a y datavg"


     - name: Ensure

       lvol:

         vg: datavg

         lv: datalv

         size: "100%FREE"

       ignore_errors: true


     - name: sql file

       filesystem:

         dev: "/dev/datavg/datalv"

         fstype: ext4

Error:

TASK [part1] 
**

fatal: [localhost]: FAILED! => {"changed": false, "err": "Error: Could not stat device /dev/vdb - No such file or directory.\n", 
"msg": "Error while getting device information with parted script: '/sbin/parted -s -m /dev/vdb -- unit 'KiB' print'", "out": 
"", "rc": 1}



--
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/3a39c550-240b-40c9-ac52-508089cd14c4n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/1bf1b040-365d-a91d-6a8d-af700bf35476%40linuxia.de.


Re: [ansible-project] Unable to execute ansible playbook

2022-07-07 Thread Stefan Hornburg (Racke)

On 07/07/2022 12:50, Ashok Reddy wrote:

cat hosts

[default]

localhost

ansible_user=cloud-user



[default]
localhost ansible_user=cloud-user

Regards
 Racke
 


odsec-test ~]# vi hosts

[root@modsec-test ~]# ansible-playbook -i ./hosts modsec-compile.yml 
--private-key nonprod


PLAY [default] 



TASK [Gathering Facts] 


fatal: [ansible_user=cloud-user]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect 
to the host via ssh: ssh: Could not resolve hostname ansible_user=cloud-user: Name or service not known", 
"unreachable": true}

fatal: [localhost]: UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote 
tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \"` echo Please login as the user \"cloud-user\" rather than the user 
\"root\"./.ansible/tmp `\"&& mkdir \"` echo Please login as the user \"cloud-user\" rather than the user \"root\"./.ansible/tmp/ansible-tmp-1657190959.6394126-3019-148910985051576 `\" && echo 
ansible-tmp-1657190959.6394126-3019-148910985051576=\"` echo Please login as the user \"cloud-user\" rather than the user \"root\"./.ansible/tmp/ansible-tmp-1657190959.6394126-3019-148910985051576 `\" ), exited with result 142, stdout 
output: Please login as the user \"cloud-user\" rather than the user \"root\".\n\n", "unreachable": true}


PLAY RECAP 
********

ansible_user=cloud-user: 
ok=0changed=0unreachable=1failed=0skipped=0rescued=0ignored=0

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



On Thu, Jul 7, 2022 at 3:47 PM Stefan Hornburg (Racke) mailto:ra...@linuxia.de>> wrote:

On 07/07/2022 11:48, Ashok Reddy wrote:
 > - hosts: default
 >
 > ansible_user: cloud-user
 >
 > become: yes
 >
 > become_method: sudo
 >
 > gather_facts: true
 >
 >
 > Error:
 >
 > ERROR! 'ansible_user' is not a valid attribute for a Play

Hello,

the ansible_user needs to be set in the inventory.

Regards
          Racke

 >
 > The error appears to be in '/root/modsec-compile.yml': line 2, column 3, 
but may
     >
 > be elsewhere in the file depending on the exact syntax problem.
 >
 >
 > The offending line appears to be:
 >
 >
 > ---
 >
 > - hosts: default
 >
 > ^ here
 >
 >
 >
 > On Thu, Jul 7, 2022 at 1:43 PM Stefan Hornburg (Racke) mailto:ra...@linuxia.de> <mailto:ra...@linuxia.de <mailto:ra...@linuxia.de>>> wrote:
 >
 >     On 07/07/2022 10:05, Ashok Reddy wrote:
 >      > the same issue happens even I have provided with -K argument:
 >
 >     You need to login as the cloud-user and use privilege escalation 
(https://docs.ansible.com/ansible/latest/user_guide/become.html 
<https://docs.ansible.com/ansible/latest/user_guide/become.html> 
<https://docs.ansible.com/ansible/latest/user_guide/become.html 
<https://docs.ansible.com/ansible/latest/user_guide/become.html>>) to execute the tasks as 
root user.
 >
 >     ansible_user: cloud-user
 >     become: yes
 >     become_method: sudo
 >
 >     Regards
 >                Racke
 >
 >      >
 >      > SSH password:
 >      >
 >      >
 >      > PLAY [default] 

 >      >
 >      >
 >      > TASK [Gathering Facts] 

 >      >
 >      > fatal: [localhost]: UNREAC

Re: [ansible-project] Unable to execute ansible playbook

2022-07-07 Thread Stefan Hornburg (Racke)

On 07/07/2022 11:48, Ashok Reddy wrote:

- hosts: default

ansible_user: cloud-user

become: yes

become_method: sudo

gather_facts: true


Error:

ERROR! 'ansible_user' is not a valid attribute for a Play


Hello,

the ansible_user needs to be set in the inventory.

Regards
Racke



The error appears to be in '/root/modsec-compile.yml': line 2, column 3, but may

be elsewhere in the file depending on the exact syntax problem.


The offending line appears to be:


---

- hosts: default

^ here



On Thu, Jul 7, 2022 at 1:43 PM Stefan Hornburg (Racke) mailto:ra...@linuxia.de>> wrote:

On 07/07/2022 10:05, Ashok Reddy wrote:
 > the same issue happens even I have provided with -K argument:

You need to login as the cloud-user and use privilege escalation 
(https://docs.ansible.com/ansible/latest/user_guide/become.html 
<https://docs.ansible.com/ansible/latest/user_guide/become.html>) to execute 
the tasks as root user.

ansible_user: cloud-user
become: yes
become_method: sudo

Regards
           Racke

 >
 > SSH password:
 >
 >
 > PLAY [default] 

 >
 >
 > TASK [Gathering Facts] 

 >
 > fatal: [localhost]: UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did not have 
permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 && 
mkdir -p \"` echo /var/tmp `\"&& mkdir \"` echo /var/tmp/ansible-tmp-1657181023.834322-2338-216353050127500 `\" && echo 
ansible-tmp-1657181023.834322-2338-216353050127500=\"` echo /var/tmp/ansible-tmp-1657181023.834322-2338-216353050127500 `\" ), exited with result 142, stdout output: Please login as the user 
\"cloud-user\" rather than the user \"root\".\n\n", "unreachable": true}
 >
 >
 > PLAY RECAP 

 >
 > localhost: ok=0changed=0unreachable=1failed=0skipped=0rescued=0ignored=0
 >
 >
 >
 >
 > On Thu, Jul 7, 2022 at 12:14 PM Prady A mailto:pradyumna@gmail.com> <mailto:pradyumna@gmail.com 
<mailto:pradyumna@gmail.com>>> wrote:
 >
 >     While executing the command provide -k option and provide the root 
password or
 >     Authenticate your localhost.
 >
 >
 >     On Thu, Jul 7, 2022 at 14:44, Ashok Reddy mailto:ashokrd...@gmail.com> <mailto:ashokrd...@gmail.com 
<mailto:ashokrd...@gmail.com>>> wrote:
 >
 >         Hi all,
 >
 >         I got the following error, while trying to execute ansible 
playbook:
 >
 >         TASK [Gathering Facts] 

 >
 >         fatal: [localhost]: UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did 
not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 
&& mkdir -p \"` echo /var/tmp `\"&& mkdir \"` echo /var/tmp/ansible-tmp-1657172514.8192306-2106-9375282374437 `\" && echo 
ansible-tmp-1657172514.8192306-2106-9375282374437=\"` echo /var/tmp/ansible-tmp-1657172514.8192306-2106-9375282374437 `\" ), exited with result 142, stdout output: Please login as the user 
\"cloud-user\" rather than the user \"root\".\n\n", "unreachable": 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 
<mailto:ansible-project%2bunsubscr...@googlegroups.c

Re: [ansible-project] Unable to execute ansible playbook

2022-07-07 Thread Stefan Hornburg (Racke)

On 07/07/2022 10:05, Ashok Reddy wrote:

the same issue happens even I have provided with -K argument:


You need to login as the cloud-user and use privilege escalation 
(https://docs.ansible.com/ansible/latest/user_guide/become.html) to execute the 
tasks as root user.

ansible_user: cloud-user
become: yes
become_method: sudo

Regards
 Racke



SSH password:


PLAY [default] 



TASK [Gathering Facts] 


fatal: [localhost]: UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did not have 
permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 
&& mkdir -p \"` echo /var/tmp `\"&& mkdir \"` echo /var/tmp/ansible-tmp-1657181023.834322-2338-216353050127500 `\" && echo 
ansible-tmp-1657181023.834322-2338-216353050127500=\"` echo /var/tmp/ansible-tmp-1657181023.834322-2338-216353050127500 `\" ), exited with result 142, stdout output: Please login as the user 
\"cloud-user\" rather than the user \"root\".\n\n", "unreachable": true}


PLAY RECAP 


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




On Thu, Jul 7, 2022 at 12:14 PM Prady A mailto:pradyumna@gmail.com>> wrote:

While executing the command provide -k option and provide the root password 
or
Authenticate your localhost.


On Thu, Jul 7, 2022 at 14:44, Ashok Reddy mailto:ashokrd...@gmail.com>> wrote:

Hi all,

I got the following error, while trying to execute ansible playbook:

TASK [Gathering Facts] 


fatal: [localhost]: UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did not have 
permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 
&& mkdir -p \"` echo /var/tmp `\"&& mkdir \"` echo /var/tmp/ansible-tmp-1657172514.8192306-2106-9375282374437 `\" && echo 
ansible-tmp-1657172514.8192306-2106-9375282374437=\"` echo /var/tmp/ansible-tmp-1657172514.8192306-2106-9375282374437 `\" ), exited with result 142, stdout output: Please login as the user 
\"cloud-user\" rather than the user \"root\".\n\n", "unreachable": 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/f2a0e03c-b35f-47ee-afa6-0a1f8b907005n%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/CAEuB3Ap8rvefKQxLXiKkWLSJ2%2BNj%2Brk1SjZ%2Bx6SDFJMy%2Bc2Gqw%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/CAKRLcHjW%3DGa3VVyVKyrG07z8L2BDFewh31ZzYJMPQGjQZTvU6g%40mail.gmail.com
 

Re: [ansible-project] ansible output not shown

2022-06-19 Thread Stefan Hornburg (Racke)

On 19/06/2022 14:08, High Raccoon wrote:

also, the hostname is altered.



Try

hosts: "test1-host:test2-host"

Regards
Racke


воскресенье, 19 июня 2022 г. в 17:07:49 UTC+5, High Raccoon:

it's a host, not a group.

воскресенье, 19 июня 2022 г. в 02:49:01 UTC+5, dnmv...@gmail.com:

Group names can't include dashes ('-')



On Sat, 18 Jun 2022 at 17:44, High Raccoon  wrote:

an extremely simple playbook:
```
---
- hosts:
    - test-host
  tasks:
    - name: AAA
       ansible.builtin.debug:
    msg: AAA
```

shows results like this:
```
[WARNING]: Invalid characters were found in group names but not 
replaced, use - to see details

PLAY [test-host] 
**

PLAY RECAP 
***
test-host                   : ok=2    changed=0    unreachable=0    
failed=0    skipped=0    rescued=0    ignored=0
```

so the debug task is either ignored, or had its output suppressed. 
please, help me make sense of ansible's behavior and try to figure out which 
settings could have influenced it.

-- 
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/2577e03f-d182-479f-92e1-60dc96526789n%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/4316813d-307a-4ab9-8740-cf3322a269afn%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/89b1bdd1-f40e-b104-113a-2318fda0ec8f%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] ssh issue over non root account

2022-06-16 Thread Stefan Hornburg (Racke)

On 15/06/2022 17:58, Dick Visser wrote:

Your course should mention that SSH access is a requirement for the course :)
In any case as you pointed out it's not really an ansible specific problem but 
rather a generic system administration issue.
Read
https://docs.ansible.com/ansible/latest/user_guide/connection_details.html for 
some hints

Reg 'asap' - I wouldn't expect people to hurry because of poor planning and 
preparation on your side...


Yes, definitely agree with this.

@Orkhan you need to add the target user to your ssh command, e.g ssh 
@.

Regards

 Racke



On Wed, 15 Jun 2022 at 17:37, Orkhan Mammadov  wrote:

Hi guys,

I have issue with connecting over ssh to other machine using non root account. First of 
all, I create new fresh non root user. When I try to ssh , it gives 
permission denied message. Then I created key pairs using ssh-keygen and tried ssh-copy-id 
, it gives the same message. I added id_rsa.pub key tp authorized_keys 
file, however, the same issue. Could you please help to setup it asap, I can't start 
ansible course due to this issue.

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/7feb759c-807d-441a-9b4f-0a4448dcd14en%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/CAF8BbLa_39XDDyh1MC2u4ieBkzmHkrzo4yFUwFruh9MOOjbo6w%40mail.gmail.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/04ed6cb5-8e32-05d1-8d61-8e4496573b58%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] sudo privilege's are not working

2022-06-14 Thread Stefan Hornburg (Racke)

On 14/06/2022 10:21, 'Shivakumar Venkataswamy' via Ansible Project wrote:

ansible is user account we created and member of  sudor's ( /etc/sudoers) with 
full privileges' same as root.


IMHO the privileges are only the same when using the "sudo" command.

Regards

  Racke




On Tuesday, 14 June 2022 at 13:16:48 UTC+5:30 ra...@linuxia.de wrote:

On 14/06/2022 09:16, 'Shivakumar Venkataswamy' via Ansible Project wrote:
> Hi team,
>  look at my playbook
> ---
> -  hosts: all
>    become: true
>    become_user: ansible
>    tasks:
>    - name: add a user to the list of AllowUsers if not present
>      vars:
>        usernames:
>           - shivakumar.venkataswamy
>           - karthik.reddy
>           - aman.saxena
>      lineinfile:
>        path: /etc/ssh/sshd_config
>        backrefs: yes
>        backup: yes
>        state: absent
>        regexp: '^AllowUsers((?:(?:\s+\S+(?!\S))(?        line: 'AllowUsers\1 shivakumar.venkataswamy karthik.reddy 
aman.saxena\2'
>        validate: /usr/sbin/sshd -t -f %s
>
Permission denied: '/etc/ssh/sshd_config'

The ansible user can't edit the file, so try "become_user: root" in your 
task.

Regards
 Racke

> I'm facing below error,
> SSH password:
> 1
> BECOME password[defaults to SSH password]:
> 2
> 3
> PLAY [all] 
*12:45:29
> 4
> 5
> TASK [Gathering Facts] 
*12:45:29
> 6
> ok: [172.16.13.254]
> 7
> 8
> TASK [add a user to the list of AllowUsers if not present] 
*12:45:31
> 9
> An exception occurred during task execution. To see the full traceback, 
use -vvv. The error was: IOError: [Errno 13] Permission denied: 
'/etc/ssh/sshd_config'
> 10
> fatal: [172.16.13.254]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 172.16.13.254 closed.\r\n", 
"module_stdout": "Traceback (most recent call last):\r\n File 
\"/home/ansible/.ansible/tmp/ansible-tmp-1655190931.6542027-6944-29566285149733/AnsiballZ_lineinfile.py\", line 102, in \r\n _ansiballz_main()\r\n 
File \"/home/ansible/.ansible/tmp/ansible-tmp-1655190931.6542027-6944-29566285149733/AnsiballZ_lineinfile.py\", line 94, in _ansiballz_main\r\n 
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File 
\"/home/ansible/.ansible/tmp/ansible-tmp-1655190931.6542027-6944-29566285149733/AnsiballZ_lineinfile.py\", line 40, in invoke_module\r\n 
runpy.run_module(mod_name='ansible.modules.files.lineinfile', init_globals=None, run_name='__main__', alter_sys=True)\r\n File \"/usr/lib64/python2.7…
> 11
> 12
> PLAY RECAP 
*12:45:32
> 13
> 172.16.13.254 : ok=1 changed=0 unreachable=0 failed=1 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-proje...@googlegroups.com.
> To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/551f8529-2fc7-409c-bac9-06216fb7c6d5n%40googlegroups.com
 
>.


-- 
Automation expert - Ansible and friends

Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/2ea9555c-aa77-4f44-8ef7-e68946e80917n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/2ce21b25-df75-0483-ac58-1a21affd03bc%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] sudo privilege's are not working

2022-06-14 Thread Stefan Hornburg (Racke)

On 14/06/2022 09:16, 'Shivakumar Venkataswamy' via Ansible Project wrote:

Hi team,
 look at my playbook
---
-  hosts: all
   become: true
   become_user: ansible
   tasks:
   - name: add a user to the list of AllowUsers if not present
     vars:
       usernames:
          - shivakumar.venkataswamy
          - karthik.reddy
          - aman.saxena
     lineinfile:
       path: /etc/ssh/sshd_config
       backrefs: yes
       backup: yes
       state: absent
       regexp: '^AllowUsers((?:(?:\s+\S+(?!\S))(?
Permission denied: '/etc/ssh/sshd_config'

The ansible user can't edit the file, so try "become_user: root" in your task.

Regards
 Racke


I'm facing below error,
SSH password:
1
BECOME password[defaults to SSH password]:
2
3
PLAY [all] 
*12:45:29
4
5
TASK [Gathering Facts] 
*12:45:29
6
ok: [172.16.13.254]
7
8
TASK [add a user to the list of AllowUsers if not present] 
*12:45:31
9
An exception occurred during task execution. To see the full traceback, use 
-vvv. The error was: IOError: [Errno 13] Permission denied: 
'/etc/ssh/sshd_config'
10
fatal: [172.16.13.254]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 172.16.13.254 closed.\r\n", 
"module_stdout": "Traceback (most recent call last):\r\n File 
\"/home/ansible/.ansible/tmp/ansible-tmp-1655190931.6542027-6944-29566285149733/AnsiballZ_lineinfile.py\", line 102, in \r\n 
_ansiballz_main()\r\n File \"/home/ansible/.ansible/tmp/ansible-tmp-1655190931.6542027-6944-29566285149733/AnsiballZ_lineinfile.py\", line 94, in 
_ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File 
\"/home/ansible/.ansible/tmp/ansible-tmp-1655190931.6542027-6944-29566285149733/AnsiballZ_lineinfile.py\", line 40, in invoke_module\r\n 
runpy.run_module(mod_name='ansible.modules.files.lineinfile', init_globals=None, run_name='__main__', alter_sys=True)\r\n File \"/usr/lib64/python2.7…
11
12
PLAY RECAP 
*12:45:32
13
172.16.13.254 : ok=1 changed=0 unreachable=0 failed=1 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/551f8529-2fc7-409c-bac9-06216fb7c6d5n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/73f0f858-f5e5-0b8c-cf95-874386d29e98%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project]

2022-06-13 Thread Stefan Hornburg (Racke)

On 13/06/2022 13:38, 'Walter Rowe' via Ansible Project wrote:

Then that /home/yum.repos.d must be on the control host running the ansible 
playbook. The copy task always copies from local to remote.


That is not correct:

remote_src: yes

Regards

   Racke




On Monday, June 13, 2022 at 7:21:30 AM UTC-4 ra...@linuxia.de wrote:

On 13/06/2022 13:17, 'Walter Rowe' via Ansible Project wrote:
> yum.repos.d is in /etc .. not /home .. not sure how its getting that path.


>     - name: Copying the Directory and its contents
>       copy:
>         src: /home/yum.repos.d

Regards Racke

>
> On Monday, June 13, 2022 at 7:14:50 AM UTC-4 shivakumar@medgenome.com 
wrote:
>
> Hi racke,
> I trailed with root also same error facing..  i think some interpreter 
issue.. please check once.
>
> PLAY [Copy Directory Example Local to Remote] 
***
>
> TASK [Copying the Directory and its contents] 
***
> fatal: [172.16.13.160]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": 
"/usr/bin/python"}, "changed": false, "msg": "Source /home/yum.repos.d not found"}
>
> PLAY RECAP 
**
> 172.16.13.160              : ok=0    changed=0  unreachable=0    failed=1 
   skipped=0    rescued=0  ignored=0
>
> On Monday, 13 June 2022 at 15:31:28 UTC+5:30 ra...@linuxia.de wrote:
>
> On 13/06/2022 11:28, 'Shivakumar Venkataswamy' via Ansible Project wrote:
> > Hi team,
> >
> > I'm facing   "Source /home/yum.repos.d not found" error while running 
playbook .. my playbook view like this .. please help out.
>
> I suppose this directory is either missing on the remote machine or the 
ansible user doesn't have the proper permissions to access it.
>
> Regards
>
>    Racke
>
> > ---
> > - name: Copy Directory Example Local to Remote
> >   hosts: 172.16.13.160
> >   become: true
> >   become_user: ansible
> >   tasks:
> >     - name: Copying the Directory and its contents
> >       copy:
> >         src: /home/yum.repos.d
> >         dest: /etc/
> >         remote_src: yes
> >         owner: root
> >         group: root
> >         mode: 0644
> >
> >     - name: Copying the Directory and its contents
> >       become: yes
> >       become_user: ansible
> >       copy:
> >         src: /home/rpm-gpg
> >         dest: /etc/pki/
> >         remote_src: yes
> >         owner: root
> >         group: root
> >         mode: 0644
> >
> >     - name: upgrade
> >       command: "{{ item }}"
> >       with_items:
> >         - yum update -y
> >         - yum upgrade -y
> >
> > Error:
> > PLAY [Copy Directory Example Local to Remote] 
***
> >
> > TASK [Gathering Facts] 
**
> > ok: [172.16.13.160]
> >
> > TASK [Copying the Directory and its contents] 
***
> > fatal: [172.16.13.160]: FAILED! => {"changed": false, "msg": "Source 
/home/yum.repos.d not found"}
> >
> > PLAY RECAP 
**
> > 172.16.13.160              : ok=1    changed=0  unreachable=0    
failed=1    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-proje...@googlegroups.com.
> > To view this discussion on the web visit 

Re: [ansible-project]

2022-06-13 Thread Stefan Hornburg (Racke)

On 13/06/2022 13:17, 'Walter Rowe' via Ansible Project wrote:

yum.repos.d is in /etc .. not /home .. not sure how its getting that path.



>     - name: Copying the Directory and its contents
>       copy:
>         src: /home/yum.repos.d

Regards Racke



On Monday, June 13, 2022 at 7:14:50 AM UTC-4 shivakumar@medgenome.com wrote:

Hi racke,
I trailed with root also same error facing..  i think some interpreter 
issue.. please check once.

PLAY [Copy Directory Example Local to Remote] 
***

TASK [Copying the Directory and its contents] 
***
fatal: [172.16.13.160]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": 
"/usr/bin/python"}, "changed": false, "msg": "Source /home/yum.repos.d not found"}

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

On Monday, 13 June 2022 at 15:31:28 UTC+5:30 ra...@linuxia.de wrote:

On 13/06/2022 11:28, 'Shivakumar Venkataswamy' via Ansible Project 
wrote:
> Hi team,
>
> I'm facing   "Source /home/yum.repos.d not found" error while running 
playbook .. my playbook view like this .. please help out.

I suppose this directory is either missing on the remote machine or the 
ansible user doesn't have the proper permissions to access it.

Regards

   Racke

> ---
> - name: Copy Directory Example Local to Remote
>   hosts: 172.16.13.160
>   become: true
>   become_user: ansible
>   tasks:
>     - name: Copying the Directory and its contents
>       copy:
>         src: /home/yum.repos.d
>         dest: /etc/
>         remote_src: yes
>         owner: root
>         group: root
>         mode: 0644
>
>     - name: Copying the Directory and its contents
>       become: yes
>       become_user: ansible
>       copy:
>         src: /home/rpm-gpg
>         dest: /etc/pki/
>         remote_src: yes
>         owner: root
>         group: root
>         mode: 0644
>
>     - name: upgrade
>       command: "{{ item }}"
>       with_items:
>         - yum update -y
>         - yum upgrade -y
>
> Error:
> PLAY [Copy Directory Example Local to Remote] 
***
>
> TASK [Gathering Facts] 
**
> ok: [172.16.13.160]
>
> TASK [Copying the Directory and its contents] 
***
> fatal: [172.16.13.160]: FAILED! => {"changed": false, "msg": "Source 
/home/yum.repos.d not found"}
>
> PLAY RECAP 
**
> 172.16.13.160              : ok=1    changed=0  unreachable=0    
failed=1    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-proje...@googlegroups.com.
> To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGq4xMTD4RP2AN%3DDZxs6Sg5X0HhhPaQ%3DZq9uvZS44dYMf9tq7g%40mail.gmail.com
 


Re: [ansible-project]

2022-06-13 Thread Stefan Hornburg (Racke)

On 13/06/2022 11:28, 'Shivakumar Venkataswamy' via Ansible Project wrote:

Hi team,

I'm facing   "Source /home/yum.repos.d not found" error while running playbook 
.. my playbook view like this .. please help out.


I suppose this directory is either missing on the remote machine or the ansible 
user doesn't have the proper permissions to access it.

Regards

   Racke


---
- name: Copy Directory Example Local to Remote
  hosts: 172.16.13.160
  become: true
  become_user: ansible
  tasks:
    - name: Copying the Directory and its contents
      copy:
        src: /home/yum.repos.d
        dest: /etc/
        remote_src: yes
        owner: root
        group: root
        mode: 0644

    - name: Copying the Directory and its contents
      become: yes
      become_user: ansible
      copy:
        src: /home/rpm-gpg
        dest: /etc/pki/
        remote_src: yes
        owner: root
        group: root
        mode: 0644

    - name: upgrade
      command: "{{ item }}"
      with_items:
        - yum update -y
        - yum upgrade -y

Error:
PLAY [Copy Directory Example Local to Remote] 
***

TASK [Gathering Facts] 
**
ok: [172.16.13.160]

TASK [Copying the Directory and its contents] 
***
fatal: [172.16.13.160]: FAILED! => {"changed": false, "msg": "Source 
/home/yum.repos.d not found"}

PLAY RECAP 
**
172.16.13.160              : ok=1    changed=0  unreachable=0    failed=1    
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/CAGq4xMTD4RP2AN%3DDZxs6Sg5X0HhhPaQ%3DZq9uvZS44dYMf9tq7g%40mail.gmail.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/6e30a8f4-be5d-7d31-7348-9ae5ed285f58%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Running Ansible playbook using AWS Systems Manager (skipping: no hosts matched)

2022-06-10 Thread Stefan Hornburg (Racke)

On 10/06/2022 12:40, Prasanth S Nair wrote:

Hi Racke,

It is defined under hosts file. Please see the links below:

https://github.com/prasanthcambridge/ansible
https://stackoverflow.com/questions/72547240/running-ansible-playbook-using-aws-systems-manager-skipping-no-hosts-matched

Kind regards,
Prasanth



Hello Pransath,

you are using -i localhost in the playbook command, maybe that's the problem?


Regards

   Racke



On Fri, Jun 10, 2022 at 9:53 AM Stefan Hornburg (Racke)  
wrote:


On 10/06/2022 10:49, Prasanth S Nair wrote:
> Hi Dick.
>
> I also get the below warning message:
>
> [WARNING]: Could not match supplied host pattern, ignoring: dev
>
>
Where did you define that host group?

Regards

 Racke

>
> On Thu, Jun 9, 2022 at 3:14 PM Prasanth S Nair  
wrote:
>
>     Hi Dick,
>
>     Thank you for your reply. This is the Git repo 
https://github.com/prasanthcambridge/ansible
>
>     Basically, I'm running the Ansible playbook from the AWS Systems Manager Console 
--> Run command --> AWS-ApplyAnsiblePlaybooks --> Specify the Github repo location 
--> Choose the target instances --> Run.
>
>     It works fine if I change 'hosts: all' in the playbook instead of the 
group name 'dev'. But, I just only want to run against a group.
>
>     Is there anything I'm doing wrong here? I'm very new to Ansible.
>
>     Kind regards,
>     Prasanth
>
>
>     On Wed, Jun 8, 2022 at 7:58 PM Dick Visser  
wrote:
>
>
>
>         On Wed, 8 Jun 2022 at 17:13, Prasanth S Nair 
 wrote:
>
>             Hi All,
>
>             I'm not sure this is the right place to ask this question.
>
>             I'm trying to run an ansible playbook from Github using AWS 
Systems Manager. My repo has a hosts (ini format) file as shown below:
>
>             /[dev] server.example.com <http://server.example.com> 
<http://server.example.com> /
>
>             And my playbook looks like below:
>
>             /--- - name: test run
>             /
>             /  hosts: dev
>             /
>             /  become: true /
>
>
>         This isn't valid nor complete.
>         Please provide the entire playbook using a correct formatting
>
>             When I run the playbook, I get the error below:
>
>             PLAY [test run] 
 skipping: no hosts matched
>
>             Any idea why it is not picking up the hosts? Can someone help 
me to resolve this issue?
>
>             --
>             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/440f9002-5195-43c9-9538-eb2e4fc91bf3n%40googlegroups.com
 
<https://groups.google.com/d/msgid/ansible-project/440f9002-5195-43c9-9538-eb2e4fc91bf3n%40googlegroups.com?utm_medium=email_source=footer
 
<https://groups.google.com/d/msgid/ansible-project/440f9002-5195-43c9-9538-eb2e4fc91bf3n%40googlegroups.com?utm_medium=email_source=footer>>.
>
>         --
>         Sent from Gmail Mobile
>         --
>         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/zpA94Hzj92c/unsubscribe.
>         To unsubscribe from this group and all its topics, 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/CAF8BbLaJX%3Dyb%3DDJTG3S1iPswvDkEMk4A16-dcXgvA7RKuME%2BkQ%40mail.gmail.com
 
<https://groups.google.com/d/msgid/ansible-project/CAF8BbLaJX%3Dyb%3DDJTG3S1iPswvDkEMk4A16-dcXgvA7RKuME%2BkQ%40mail.gmail.com?utm_medium=email_source=footer
 
<https://groups.google.com/d/msgid/ansible-project/CAF8BbLaJX%3Dyb%3DDJTG3S1iPswvDkEMk4A16-dcXgvA7RKuME%2BkQ%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 receiv

Re: [ansible-project] Running Ansible playbook using AWS Systems Manager (skipping: no hosts matched)

2022-06-10 Thread Stefan Hornburg (Racke)

On 10/06/2022 10:49, Prasanth S Nair wrote:

Hi Dick.

I also get the below warning message:

[WARNING]: Could not match supplied host pattern, ignoring: dev



Where did you define that host group?

Regards

    Racke



On Thu, Jun 9, 2022 at 3:14 PM Prasanth S Nair  wrote:

Hi Dick,

Thank you for your reply. This is the Git repo 
https://github.com/prasanthcambridge/ansible

Basically, I'm running the Ansible playbook from the AWS Systems Manager Console --> 
Run command --> AWS-ApplyAnsiblePlaybooks --> Specify the Github repo location --> 
Choose the target instances --> Run.

It works fine if I change 'hosts: all' in the playbook instead of the group 
name 'dev'. But, I just only want to run against a group.

Is there anything I'm doing wrong here? I'm very new to Ansible.

Kind regards,
Prasanth


On Wed, Jun 8, 2022 at 7:58 PM Dick Visser  wrote:



On Wed, 8 Jun 2022 at 17:13, Prasanth S Nair  
wrote:

Hi All,

I'm not sure this is the right place to ask this question.

I'm trying to run an ansible playbook from Github using AWS Systems 
Manager. My repo has a hosts (ini format) file as shown below:

/[dev] server.example.com  /

And my playbook looks like below:

/--- - name: test run
/
/  hosts: dev
/
/  become: true /


This isn't valid nor complete.
Please provide the entire playbook using a correct formatting

When I run the playbook, I get the error below:

PLAY [test run] 
 skipping: no hosts 
matched

Any idea why it is not picking up the hosts? Can someone help me to 
resolve this issue?

-- 
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/440f9002-5195-43c9-9538-eb2e4fc91bf3n%40googlegroups.com
 
.

-- 
Sent from Gmail Mobile
-- 
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/zpA94Hzj92c/unsubscribe.
To unsubscribe from this group and all its topics, 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/CAF8BbLaJX%3Dyb%3DDJTG3S1iPswvDkEMk4A16-dcXgvA7RKuME%2BkQ%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/CAN-bB3Tw_C62h%2BgRDjGN9fpqcUcZisj6XyTBxnvj9YMzO1rrQA%40mail.gmail.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/ba4f8454-59d2-8aa2-4338-bb0730bb12c4%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] LDAP setup??

2022-06-09 Thread Stefan Hornburg (Racke)

On 10/06/2022 06:48, 'Shivakumar Venkataswamy' via Ansible Project wrote:

Hi..
I'm facing this kind issue while running this playbook.


Looks like you have a typo in the command line options:

"authconfig: error: no such option: --enableforcelegancy"],

Regards

    Racke




 PLAYBOOK: LDAP.yml 
**
1 plays in LDAP.yml

PLAY [172.16.13.244] 


TASK [Gathering Facts] 
**
task path: /var/lib/awx/projects/playbook/LDAP.yml:2
ok: [172.16.13.244]
META: ran handlers

TASK [install nss-pam-ldap] 
*
task path: /var/lib/awx/projects/playbook/LDAP.yml:6
ok: [172.16.13.244] => {"changed": false, "msg": "", "rc": 0, "results": 
["openldap-clients-2.4.44-25.el7_9.x86_64 providing openldap-clients is already installed", "nss-pam-ldapd-0.8.13-25.el7.x86_64 providing 
nss-pam-ldapd is already installed"]}

TASK [join a node to an LDAP server] 

task path: /var/lib/awx/projects/playbook/LDAP.yml:11
fatal: [172.16.13.244]: FAILED! => {"changed": true, "cmd": "authconfig --enableldap --enableldapauth --ldapserver=\"pdc.medgenome.com\" --ldapbasedn=\"dc=medgenome,dc=com\" --enablemkhomedir --enableforcelegancy --update", "delta": "0:00:00.058063", 
"end": "2022-06-10 10:15:15.112762", "msg": "non-zero return code", "rc": 2, "start": "2022-06-10 10:15:15.054699", "stderr": "Usage: authconfig [options] {--update|--updateall|--test|--probe|--restorebackup |--savebackup 
|--restorelastbackup}\n\nauthconfig: error: no such option: --enableforcelegancy", "stderr_lines": ["Usage: authconfig [options] {--update|--updateall|--test|--probe|--restorebackup |--savebackup |--restorelastbackup}", "", "authconfig: error: no such option: 
--enableforcelegancy"], "stdout": "", "stdout_lines": []}

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


On Thursday, 9 June 2022 at 17:24:13 UTC+5:30 dnmv...@gmail.com wrote:

Thx much appreciated.
But what is the error you are referring to?

On Thu, 9 Jun 2022 at 11:01, 'Shivakumar Venkataswamy' via Ansible Project 
 wrote:

my play book look like this

---
- hosts: 172.16.13.143
  user: root
  become: true
  tasks:
   - name: install nss-pam-ldap
     yum:
       name:  openldap-clients,nss-pam-ldapd
       state: present

   - name: join a node to an LDAP server
     ansible.builtin.shell:
                     cmd: 'authconfig --enableldap --enableldapauth 
--ldapserver="pdc.medgenome.com " 
--ldapbasedn="dc=medgenome,dc=com" --enablemkhomedir --enableforcelegancy --update'

On Thursday, 9 June 2022 at 12:01:16 UTC+5:30 dnmv...@gmail.com wrote:

What kind of trouble do you have?
What does your playbook look like?

On Thu, 9 Jun 2022 at 06:57, 'Shivakumar Venkataswamy' via Ansible 
Project  wrote:

Hi all,
 Any one can share the playbook for which are details mentioned 
below.

Step1: yum -y install openldap-clients nss-pam-ldapd
Step2: Execute below command

authconfig --enableldap \
--enableldapauth \
--ldapserver=pdc.example.com  \
--ldapbasedn="dc=example,dc=com" \
--enablemkhomedir \
--update

Step3: authconfig --enableforcelegacy --update

I'm touble to write a playbook for command with entries. please 
help me out.

Regards,
shivu

-- 
You received this message because you are subscribed to 

Re: [ansible-project] Playbook structure

2022-05-12 Thread Stefan Hornburg (Racke)

On 12/05/2022 12:57, Marc Haber wrote:

Hi Dirk,

On Tue, May 10, 2022 at 08:30:13AM +0200, Dick Visser wrote:

On 2022-05-09 (Mon) 22:06, Marc Haber wrote:

after using ansible for quite a while, my project to manage my own
servers has grown to a respectable size. I was a puppet user before, so
I have a single big playbook containing everything. I have the feeling
this is like holding ansible wrong, and I also have the feeling that I
have my playbook structured wrong. Judging from the single "name"
setting, I took the wrong turn in the very beginning. The playbook does
what it is intended to do, however.

Here is an excerpt from my playbook.

---
- name: apply common configuration
   hosts: all
   remote_user: zgansible
   become: "yes"


What is the reason for quoting this boolean? It is usually done to force it
to be a string, but AFAIK this parameter requires a boolean.


Historical reasons, fixed. I probably didnt know any better, and it's
still a matter of try-and-err whether to find out whether ansible
wants/insists on things being quoted or not.

[snip]


I don't see anything totally wrong with the above approach.
Perhaps try to avoid the inline lists but that's cosmetics.


How would I write them any better?


In the other news, where would I correctly place (and activate) this handler:

---
- name: apt update
command: "apt-get update"

if I intend to notify this handler from any role that might use the apt
provider to install packages?


What is the use case for this?
If you want to make sure this is always run prior to any package task, then
you should use the update_cache parameters of the apt module:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html#parameter-update_cache


updating the package lists after fiddling with things in /etc/apt, for
example preparing a release upgrade or adding an external repository
(docker *cough*). Doing an apt update right before any check whether any
required package is already installed seems overkill, but I need to
ponder about that.


You can add/modify/delete the external repo with Ansible and run the apt update 
only when the repo changed.

The equivalent for "apt-get update" is:

- name: Update APT cache
  apt:
update_cache: yes

Regards
   Racke



Greetings
Marc




--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/1a200e5e-9c3c-3ab5-84c5-deb494f6f073%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Playbook structure

2022-05-12 Thread Stefan Hornburg (Racke)

On 09/05/2022 22:06, Marc Haber wrote:

Hi,

after using ansible for quite a while, my project to manage my own
servers has grown to a respectable size. I was a puppet user before, so
I have a single big playbook containing everything. I have the feeling
this is like holding ansible wrong, and I also have the feeling that I
have my playbook structured wrong. Judging from the single "name"
setting, I took the wrong turn in the very beginning. The playbook does
what it is intended to do, however.


My two cents:

- host name / remote user should be in the inventory and not in the playbook
- consider using import_role instead of include_role

Regards
   Racke



Here is an excerpt from my playbook.

---
- name: apply common configuration
   hosts: all
   remote_user: zgansible
   become: "yes"
   tasks:
   ⦙ - name: install ansible dependencies
   ⦙ ⦙ apt:
   ⦙ ⦙ ⦙ name: ['python3', 'python3-apt']
   ⦙ ⦙ ⦙ state: present
   ⦙ - name: get package facts
   ⦙ ⦙ package_facts:
   ⦙ ⦙ ⦙ manager: "auto"
   ⦙ ⦙ tags: always
   ⦙ - name: print facts
   ⦙ ⦙ debug:
   ⦙ ⦙ ⦙ var: ansible_facts
   ⦙ ⦙ tags: [never, debug, printfacts]
   ⦙ - name: print package facts
   ⦙ ⦙ debug:
   ⦙ ⦙ ⦙ var: ansible_facts.packages
   ⦙ ⦙ tags: [never, debug, printpackagefacts]
   ⦙ - include_role:
   ⦙ ⦙ ⦙ name: clean-motd
   ⦙ ⦙ ⦙ apply:
   ⦙ ⦙ ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ ⦙ ⦙ - clean-motd
   ⦙ ⦙ ⦙ ⦙ ⦙ - clean-all
   ⦙ ⦙ ⦙ ⦙ ⦙ - never
   ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ - clean-motd
   ⦙ ⦙ ⦙ - clean-all
   ⦙ ⦙ ⦙ - never
   ⦙ - include_role:
   ⦙ ⦙ ⦙ name: sysctl
   ⦙ ⦙ ⦙ apply:
   ⦙ ⦙ ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ ⦙ ⦙ - sysctl
   ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ - sysctl
(LOTS of other include_role stanzas defining roles that are on all machines)

- name: apply configuration for bind9 servers
   hosts:
   ⦙ - alemana
   ⦙ - cadencia
   ⦙ - gancho
   ⦙ - impetus
   ⦙ - lasso
   ⦙ - torres
   ⦙ - dns1
   remote_user: zgansible
   become: "yes"
   vars:
   ⦙ bind_role: "{{ (bind|default({}))|combine(bind_group|default({}), 
recursive=true, list_merge='append') }}"
   tasks:
   ⦙ - include_role:
   ⦙ ⦙ ⦙ name: bind9
   ⦙ ⦙ ⦙ apply:
   ⦙ ⦙ ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ ⦙ ⦙ - bind9
   ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ - bind9

- name: apply configuration for DHCP servers
   hosts:
   ⦙ - chasse
   ⦙ - cadencia
   remote_user: zgansible
   become: "yes"
   tasks:
   ⦙ - include_role:
   ⦙ ⦙ ⦙ name: isc-dhcp-server
   ⦙ ⦙ ⦙ apply:
   ⦙ ⦙ ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ ⦙ ⦙ - isc-dhcp-server
   ⦙ ⦙ tags:
   ⦙ ⦙ ⦙ - isc-dhcp-server

Is this the way to do it? Any comments will be appreciated.

In the other news, where would I correctly place (and activate) this handler:

---
- name: apt update
   command: "apt-get update"

if I intend to notify this handler from any role that might use the apt
provider to install packages?

Thank you in advance!

Greetings
Marc




--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/b4b9b565-4a21-74f4-2874-ffaeab056549%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Define hostname for group based on index+1

2022-04-15 Thread Stefan Hornburg (Racke)

On 15/04/2022 12:45, dudu.c...@gmail.com wrote:

First of all thank you - it works.

But, can i spare  the following definition  ? *groups['web-server']*
Basically in the begging of the playbook I'm defining the group under hosts

- hosts: web-server


You could try ansible_play_hosts instead.

Regards
Racke



ב-יום שישי, 15 באפריל 2022 בשעה 11:58:31 UTC+3, ra...@linuxia.de כתב/ה:

On 15/04/2022 09:18, dudu.c...@gmail.com wrote:
 > Hi,
 >
 > I have X amount of server inside a defined group (For example - web 
server)
 > I want to loop the server a define there hostname based on index+1
 >
 > For example, if the group have 3 server , so server one should be "web-server1" , 
second , "web-server-2" etc.
 >
 > The below didnt do the trick - since it is looping the sequence for each 
server
 > - hosts: web-server
 >   remote_user: user
 >   become: yes
 >   tasks:
 >     - name: Set a hostname
 >       hostname:
 >         name: web-server-{{ item }}
 >
 >
 >       with_sequence: count=3

Using a loop is futile here, as you found out. But you can do that with a 
bit Python:

- name: Set a hostname
hostname:
name: "web-server-{{ groups['web-server'].index(inventory_hostname) }}"

Regards
Racke

 >
 > --
 > 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/4d7a9bb7-6403-4ac9-b77f-4212fafc5680n%40googlegroups.com 

 
>.


-- 
Automation expert - Ansible and friends

Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/fe43e1e3-ea11-4626-8855-2039a1b786a4n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/a89f9e14-2faa-73a0-8db5-13bbbade3c98%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Define hostname for group based on index+1

2022-04-15 Thread Stefan Hornburg (Racke)

On 15/04/2022 09:18, dudu.c...@gmail.com wrote:

Hi,

I have X amount of server inside a defined group (For example - web server)
I want to loop the server a define there hostname based on index+1

For example, if the group have 3 server , so server one should be "web-server1" , second 
, "web-server-2" etc.

The below didnt do the trick - since it is looping the sequence for each server
- hosts: web-server
   remote_user: user
   become: yes
   tasks:
     - name: Set a hostname
       hostname:
         name: web-server-{{ item }}


       with_sequence: count=3


Using a loop is futile here, as you found out. But you can do that with a bit 
Python:

- name: Set a hostname
  hostname:
name: "web-server-{{ groups['web-server'].index(inventory_hostname) }}"

Regards
  Racke



--
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/4d7a9bb7-6403-4ac9-b77f-4212fafc5680n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/e3a48943-6392-fd5d-7454-d989dd8e8bba%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] How ansible vault is safe when using scripts?

2022-03-22 Thread Stefan Hornburg (Racke)

On 22/03/2022 12:05, R Batchen wrote:

Hey,
I dont understand how ansible vault is safe if i want to use in a script  i 
need to give ansible
the file where the password  is saved in plain text.. so i dont get it

i do get it being safe if i do a prompts for the password with --ask-vault-pass
but when i point to ansible using --vault-password-file or export global 
variable with pass it is saved on the system\file as plain text

what am i missing?


You can use a GPG encrpyted password file with a wrapper script.

Regards
   Racke



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/4ae3f1e6-f4c0-4214-b0a4-d2c5208dcfd6n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/918761a2-9f59-b7db-860a-f3d4456a58d3%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] ansible.builtin.apt - Updating all installed packages to latest gives "parameters are mutually exclusive deb|package|upgrade

2022-03-21 Thread Stefan Hornburg (Racke)

On 19/03/2022 01:05, John Himpel wrote:

The following ansible block:
- name: Block update APT hosts
   block:
     - name: main - Update APT repo and cache
       ansible.builtin.apt:
         update_cache: true
         force_apt_get: true
         cache_valid_time: 3600   # 1 Hour

     - name: main - Update APT hosts
       ansible.builtin.apt:
         upgrade: dist
         force_apt_get: true
       register: apt_return

     - name: main - Display APT log
       ansible.builtin.debug:
         var: apt_return.stdout_lines
       when: apt_return.stdout_lines is defined

     - name: main - Check if reboot is needed
       ansible.builtin.stat:
         path: /var/run/reboot-required
         get_md5: false
       register: reboot_required_file

     - name: main - Reboot APT host
       ansible.builtin.reboot:
         msg: "Reboot initiated by Ansible due to kernel updates"
         connect_timeout: 5
         reboot_timeout: 300
         pre_reboot_delay: 0
         post_reboot_delay: 30
         test_command: uptime
       when: reboot_required_file.stat.exists
   when: ansible_pkg_mgr == "apt"
   become: true

Yields:
TASK [update_software : main - update APT hosts] ***
fatal: [testRadicale.jlhimpel.net]: FAILED! => {"changed": false, "msg": "parameters 
are mutually exclusive: deb|package|upgrade"}

Ansible version: 2.2.12
Python version: 3.10.3
Ansible Controller: Fedora 36 (same issue occurs on Fedora 35)
Ansible target: Ubuntu 18.04.5 (Bionic Beaver)
Ansible target: python 3..6.9


Try with a recent version of Ansible.

Regards
  Racke



--
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/11cb52e9-3c7e-4714-94d5-739d56bcdbdan%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/fd4691c4-016f-95c3-ddfd-9522b8448006%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Re: create a dict from a list (value of another dict)

2022-03-16 Thread Stefan Hornburg (Racke)

On 16/03/2022 17:46, Hiero-nymo wrote:

I've try some subelements but cannot retrieve the right data.
ie


I don't get why you use the dict2items filter on a list of dicts. You can start producing 
output from the "linux_file_list" variable directly.

Regards
Racke



On Wednesday, March 16, 2022 at 10:41:58 AM UTC+1 h...@startx.fr wrote:

try the *subelement *filter
Le mardi 15 mars 2022 à 16:51:19 UTC+1, Hiero-nymo a écrit :

Hi Team,

My playbook role receive a dict coming from a lookup file, 
*linux_file_list* is the variable name of this lookup. This dict has only one 
key and some lists as value. Elements of these lists are dict too.

Here's my debug to see the content:

- Name: debugging
   debug:
     msg:"{{ linux_file_list | dict2items }}"

And here's the result (a part...):

TASK [reposync : debugging] 
***

ok: [] => {

     "msg": [

     [

     {

     "key": "list_of_linux",

     "value": [

 {

 "description": "linux SLES",

     "enabled": 1,

     "version": 15,

     "name": "sles"

     },

     {

     "description": "linux RHEL",

     "enabled": 1,

     "version": 8.4,

     "name": "rhel"

     }

     ]

     }

     ]

     ]

}

Now, I want to define the name value as a dict to loop on this to have  
at the end a loop to retrieve these variables, like so…

"name: {{ item['name'] }}"
"description: {{ item['description'] }}"
"version: {{ item['version'] }}"
etc…

Unfortunately I don't find how can i do that. I've try many things, 
like item.value[0][0] to have the first element of the first list but it 
doesn't run.

With set_fact i cannot do a dict on the list too:

- set_fact:
      dict: “{{ dict(_keys|zip(linux_file_list)) }}"
   vars:
     _keys: "{{ item['value']|map(attribute='name')|list }}"
   loop: "{{ linux_file_list | dict2items }}"

As anyone an Idea how can I resolve this? I can't see my problem 
clearly anymore and I need your help

Thanks in advance for your help, H

--
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/b172badc-0b9d-4d86-9437-37d07b387dddn%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/eb86286e-2e77-34e0-4223-0d6fe734e47f%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Ansible private key passphrase

2022-03-14 Thread Stefan Hornburg (Racke)

On 14/03/2022 04:09, Dip Giri wrote:

How to use private key passphrase in ansible inventory file


What about using ssh agent on the controller machine and add that key with 
ssh-add?

Regards
Racke



--
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/6ac72028-6e2a-46d5-a446-e93d40dbc497n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/bca9ee1f-3bcb-ef8d-c992-2599f9f923af%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] how to execute playbook task on Host-B directly from control machine

2022-03-13 Thread Stefan Hornburg (Racke)

On 12/03/2022 19:17, Dip Giri wrote:

First i have to connect *Host-A*then i can connect *Host-B*. i can’t connect 
Host-B directly. So in this case how to execute playbook task on *Host-B *from 
*Control Machine. *Because my control machine is centralised where have running 
*Ansible AWX. * and i can't install ansible on Host-A because there have 
restriction they wouldn't allow it.

So my question is how to execute playbooktask on *Host-B *directly from control 
machine


Screenshot from 2022-03-12 23-46-07.png


Use Host-A as a jump host, e.g. 
https://www.jeffgeerling.com/blog/2022/using-ansible-playbook-ssh-bastion-jump-host

Regards
  Racke



--
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/e50b7e7c-ecf3-49b8-8375-a3b895892e1bn%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/c6edac69-16f0-85cb-6c97-1c4b1657508a%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Run playbook against multiple hosts

2022-03-01 Thread Stefan Hornburg (Racke)

On 01/03/2022 16:51, Nitrous wrote:

I have defined my hosts in the variable file:

[servers]

server1 ansible_host=ip address of server 1

server2 ansible_host=ip address of server 2

etc

I have a playbook that looks like this:

- hosts: '{{ hostname }}'
   gather_facts: no
   tasks:
   - name: Include vars for vcenter
     include_vars:
         file: /etc/ansible/roles/createvm/vars/main.yml
         name: vcenter
     vars:
       ansible_become_password: "{{ domain_password }}"

   - name: Include vars of server.yaml file
     include_vars:
         file: /etc/ansible/servers/{{ hostname }}.yaml
         name: server

   - name: Wait For Connection to Continue
     wait_for_connection:
       connect_timeout: 30

   - name: Reboot to check for second round of updates
     ansible.windows.win_reboot:
       msg: "Reboot to check for second round of updates"

   - import_role:
       name: windowsupdates

This playbook works fine if I run the command to specify 1 hostname:


ansible-playbook playbooks/file.yml -e "hostname=server1" -.

How can I run my file.yml against server1,server2 etc at the same time?


I suppose that -e "hostname=servers" should do the trick.

Regards
 Racke



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/adaee4d9-0c58-4d00-a355-eeb4fe8bdba2n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/a89fe0ef-bf32-9d0e-7a1d-f0f9111b8d54%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Ansible execute remote shell script with source to other files

2022-02-10 Thread Stefan Hornburg (Racke)

On 10/02/2022 16:15, SysAdmin EM wrote:

I changed source by "." inside the shell script and it’s still not running.

#!/bin/bash

. config-dev.cfg
. functions.sh

Within the playbook I am already using the parameter "executable: /bin/bash".


That's true, but you again calling the shell again with "sh ..". Makes no sense 
to me.

Regards
Racke



Playbook
---
- name: Test SH
   hosts: schedule-dev
   become: yes
   gather_facts: no
   tasks:
     - name: Test Shell Ansible
       shell: |
         sh create_partition_db.sh {{ carrier }}
       args:
         chdir: /opt/app/automation
         executable: /bin/bash
       register: output
     - name: ouput
       debug:
         var: output.stdout

On Thu, Feb 10, 2022 at 11:56 AM Stefan Hornburg (Racke) mailto:ra...@linuxia.de>> wrote:

On 10/02/2022 14:48, SysAdmin EM wrote:
 > Hello,
 > I’m trying to run a playbook which executes a shell script in a remote 
instance.
 >
 > Playbook
 > ---
 > - name: Test SH
 >    hosts: schedule-dev
 >    become: yes
 >    gather_facts: no
 >    tasks:
 >      - name: Test Shell Ansible
 >        shell: |
 >          sh create_partition_db.sh {{ carrier }}
 >        args:
 >          chdir: /opt/app/automation
 >          executable: /bin/bash
 >        register: output
 >      - name: ouput
 >        debug:
 >          var: output.stdout
 > The value of the variable {{ carrier }} is sent through the command line:
 >
 > ansible-playbook -i hosts-dev --extra-vars "carrier=dev" 
playbook/step-2.yaml
 >
 > When I run the playbook I see this error:
 >
 > fatal: [schedule01-dev]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": true, "cmd": "sh create_partition_db.sh 00CN\n", "delta": "0:00:00.003453", "end": 
"2022-02-10 13:27:23.244718", "msg": "non-zero return code", "rc": 2, "start": "2022-02-10 13:27:23.241265", "stderr": "create_partition_db.sh: 3: create_partition_db.sh: source: not found\ncreate_partition_db.sh: 4: 
create_partition_db.sh: source: not found\ncreate_partition_db.sh: 6: create_partition_db.sh: get_partitions: not found\ncreate_partition_db.sh: 8: create_partition_db.sh: function: not found\ncreate_partition_db.sh: 34: create_partition_db.sh: Syntax error: \"}\" unexpected", 
"stderr_lines": ["create_partition_db.sh: 3: create_partition_db.sh: source: not found", "create_partition_db.sh: 4: create_partition_db.sh: source: not found", "create_partition_db.sh: 6: create_partition_db.sh: get_partitions: not found", "create_partition_db.sh: 
8:
create_partition_db.sh:
 > function: not found", "create_partition_db.sh: 34: create_partition_db.sh: Syntax error: \"}\" 
unexpected"], "stdout": "", "stdout_lines": []}
 >
 > PLAY RECAP 
*
 > schedule01-dev             : ok=0    changed=0    unreachable=0    
failed=1    skipped=0    rescued=0    ignored=0
 > When I run the script from the instance I don’t see any errors, I think 
it has to do with the fact that in the script I use the source command to call 
other files:
 >
 > #!/bin/bash
 >
 > source config-dev.cfg
 > source functions.sh
 >
 >
 > Any sugestion?

Looks like the default shell on the target doesn't know about "source". Use 
"." instead or force the usage of bash with:

    executable: "/bin/bash"

in your shell task.

Regards
         Racke

 >
 > --
 > 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> 
<mailto: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/CAGUDtn%3DHeuyr5kyXPYODJKCvn06d6QhmMne9USsxWxD%3D8O%2B-zw%40mail.gmail.com
 
<https://groups.google.com/d/msgid/ansible-project/CAGUDtn%3DHeuyr5kyXPYODJKCvn06d6QhmMne9USsxWxD%3D8O%2B-zw%40mail.gmail.com>
 
<https://groups.google.com/d/msgid/ansible-project/CAGUDtn%3DHeuyr5kyXPYODJKCvn06d6QhmMne

Re: [ansible-project] Ansible execute remote shell script with source to other files

2022-02-10 Thread Stefan Hornburg (Racke)

On 10/02/2022 14:48, SysAdmin EM wrote:

Hello,
I’m trying to run a playbook which executes a shell script in a remote instance.

Playbook
---
- name: Test SH
   hosts: schedule-dev
   become: yes
   gather_facts: no
   tasks:
     - name: Test Shell Ansible
       shell: |
         sh create_partition_db.sh {{ carrier }}
       args:
         chdir: /opt/app/automation
         executable: /bin/bash
       register: output
     - name: ouput
       debug:
         var: output.stdout
The value of the variable {{ carrier }} is sent through the command line:

ansible-playbook -i hosts-dev --extra-vars "carrier=dev" playbook/step-2.yaml

When I run the playbook I see this error:

fatal: [schedule01-dev]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": true, "cmd": "sh create_partition_db.sh 00CN\n", "delta": "0:00:00.003453", "end": "2022-02-10 13:27:23.244718", "msg": "non-zero return code", "rc": 2, "start": "2022-02-10 13:27:23.241265", "stderr": "create_partition_db.sh: 3: create_partition_db.sh: source: not found\ncreate_partition_db.sh: 4: create_partition_db.sh: source: not found\ncreate_partition_db.sh: 6: create_partition_db.sh: get_partitions: not found\ncreate_partition_db.sh: 8: create_partition_db.sh: function: not found\ncreate_partition_db.sh: 34: create_partition_db.sh: Syntax error: \"}\" unexpected", "stderr_lines": ["create_partition_db.sh: 3: create_partition_db.sh: source: not found", "create_partition_db.sh: 4: create_partition_db.sh: source: not found", "create_partition_db.sh: 6: create_partition_db.sh: get_partitions: not found", "create_partition_db.sh: 8: create_partition_db.sh: 
function: not found", "create_partition_db.sh: 34: create_partition_db.sh: Syntax error: \"}\" unexpected"], "stdout": "", "stdout_lines": []}


PLAY RECAP 
*
schedule01-dev             : ok=0    changed=0    unreachable=0    failed=1    
skipped=0    rescued=0    ignored=0
When I run the script from the instance I don’t see any errors, I think it has 
to do with the fact that in the script I use the source command to call other 
files:

#!/bin/bash

source config-dev.cfg
source functions.sh


Any sugestion?


Looks like the default shell on the target doesn't know about "source". Use "." 
instead or force the usage of bash with:

  executable: "/bin/bash"

in your shell task.

Regards
   Racke



--
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/CAGUDtn%3DHeuyr5kyXPYODJKCvn06d6QhmMne9USsxWxD%3D8O%2B-zw%40mail.gmail.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/04e71d13-c95f-fc60-14d6-9ff8e9d21c7b%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Re: Getting Timed Out Error when running the playbook using `vagrant provision`

2022-02-03 Thread Stefan Hornburg (Racke)

On 03/02/2022 14:39, arjungoel 1995 wrote:

This is the output I am getting after running `vagrant ssh-config`

image.png

Also want to know why I am experiencing the timeout error while running the 
ansible playbook using ansible-playbook command.


Vagrant uses 127.0.0.1 and port .

Ansible uses 172.30.240.1.

Again: *Vagrant didn't setup **172.30.240.1 properly*

Regards

   Racke



On Thu, Feb 3, 2022 at 6:59 PM Stefan Hornburg (Racke)  wrote:

On 03/02/2022 14:22, arjungoel 1995 wrote:
> `vagrant ssh` is working but when I tried to run the playbook using 
`ansible-playbook ` command I am getting a timeout error again.
>
> image.png
>
> I have checked the /etc/ansible/hosts file and the IP address is there. 
How I can fix the timeout issue with both ways?

What does `vagrant ssh-config` say?  Does it use the IP 172.30.240.1?

I don't think so. Looks like Vagrant didn't set up the IP properly.

Regards

  Racke


>
> Thanks
>
> On Thu, Feb 3, 2022 at 6:21 PM Stefan Hornburg (Racke)  
wrote:
>
>     On 03/02/2022 13:47, arjungoel 1995 wrote:
>     > Hi, I tried to ping the port and IP address using SSH and getting 
timeout error. Can you please help me how to fix this?
>     >
>     >
>     > image.png
>     >
>     Does "vagrant ssh" work?
>
>     Regards
>
>       Racke
>
>
>     > On Thu, Feb 3, 2022 at 5:37 PM Roberto Paz  wrote:
>     >
>     >     Have you tried to manually run an *ssh *command to that IP 
address and port? If ssh command also returns a timeout, then that is the main source 
of the issue.
>     >
>     >     El miércoles, 2 de febrero de 2022 a la(s) 14:29:08 UTC-3, 
arjung...@gmail.com escribió:
>     >
>     >         Hi,
>     >
>     >         I am trying to run a basic ansible playbook using vagrant 
provision but while doing so experiencing this error:
>     >
>     >         I even added the ip in my Vagrantfile:
>     >
>     >         # -*- mode: ruby -*-
>     >         # vi: set ft=ruby :
>     >         Vagrant.configure("2") do |config|
>     >           config.vm.box = "centos/7"
>     >         *  config.vm.network "private_network", ip: "172.30.240.1"*
>     >           config.vm.provision "ansible" do |ansible|
>     >             ansible.playbook = "playbook.yaml"
>     >           end
>     >         Also I am not able to install ansible on windows using pip 
and like you know git bash won't support installation of ansible.
>     >         While I am getting version compatibility issues while 
trying the same using WSL.
>     >         Please help.
>     >         Thanks
>     >         Arjun Goel
>     >         But still experiencing the issue.ansible_timeout_error.PNG
>     >         end
>     >
>     >     --
>     >     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> 
<mailto:ansible-project%2bunsubscr...@googlegroups.com 
<mailto:ansible-project%252bunsubscr...@googlegroups.com>>.
>     >     To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ac2f697a-ee8d-483f-b9df-c08f8142a182n%40googlegroups.com 
<https://groups.google.com/d/msgid/ansible-project/ac2f697a-ee8d-483f-b9df-c08f8142a182n%40googlegroups.com?utm_medium=email_source=footer
 
<https://groups.google.com/d/msgid/ansible-project/ac2f697a-ee8d-483f-b9df-c08f8142a182n%40googlegroups.com?utm_medium=email_source=footer>
 
<https://groups.google.com/d/msgid/ansible-project/ac2f697a-ee8d-483f-b9df-c08f8142a182n%40googlegroups.com?utm_medium=email_source=footer
 
<https://groups.google.com/d/msgid/ansible-project/ac2f697a-ee8d-483f-b9df-c08f8142a182n%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%2bunsubscr...@googlegroups.com> 
<mailto:ansible-project%2bunsubscr...@googlegroups.com 
<mailto:ansib

Re: [ansible-project] Re: Getting Timed Out Error when running the playbook using `vagrant provision`

2022-02-03 Thread Stefan Hornburg (Racke)

On 03/02/2022 14:22, arjungoel 1995 wrote:

`vagrant ssh` is working but when I tried to run the playbook using `ansible-playbook 
` command I am getting a timeout error again.

image.png

I have checked the /etc/ansible/hosts file and the IP address is there. How I 
can fix the timeout issue with both ways?


What does `vagrant ssh-config` say?  Does it use the IP 172.30.240.1?

I don't think so. Looks like Vagrant didn't set up the IP properly.

Regards

 Racke




Thanks

On Thu, Feb 3, 2022 at 6:21 PM Stefan Hornburg (Racke)  wrote:

On 03/02/2022 13:47, arjungoel 1995 wrote:
> Hi, I tried to ping the port and IP address using SSH and getting timeout 
error. Can you please help me how to fix this?
>
>
> image.png
>
Does "vagrant ssh" work?

Regards

  Racke


> On Thu, Feb 3, 2022 at 5:37 PM Roberto Paz  wrote:
>
>     Have you tried to manually run an *ssh *command to that IP address 
and port? If ssh command also returns a timeout, then that is the main source of 
the issue.
>
>     El miércoles, 2 de febrero de 2022 a la(s) 14:29:08 UTC-3, 
arjung...@gmail.com escribió:
>
>         Hi,
>
>         I am trying to run a basic ansible playbook using vagrant 
provision but while doing so experiencing this error:
>
>         I even added the ip in my Vagrantfile:
>
>         # -*- mode: ruby -*-
>         # vi: set ft=ruby :
>         Vagrant.configure("2") do |config|
>           config.vm.box = "centos/7"
>         *  config.vm.network "private_network", ip: "172.30.240.1"*
>           config.vm.provision "ansible" do |ansible|
>             ansible.playbook = "playbook.yaml"
>           end
>         Also I am not able to install ansible on windows using pip and 
like you know git bash won't support installation of ansible.
>         While I am getting version compatibility issues while trying the 
same using WSL.
>         Please help.
>         Thanks
>         Arjun Goel
>         But still experiencing the issue.ansible_timeout_error.PNG
>         end
>
>     --
>     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/ac2f697a-ee8d-483f-b9df-c08f8142a182n%40googlegroups.com
 
<https://groups.google.com/d/msgid/ansible-project/ac2f697a-ee8d-483f-b9df-c08f8142a182n%40googlegroups.com?utm_medium=email_source=footer
 
<https://groups.google.com/d/msgid/ansible-project/ac2f697a-ee8d-483f-b9df-c08f8142a182n%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%2bunsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALh2VP%2B4HhMTofFOuJ%3DuMQdSqzBi1RmJnOK1pgv%2B3wqHgUeGfw%40mail.gmail.com
 
<https://groups.google.com/d/msgid/ansible-project/CALh2VP%2B4HhMTofFOuJ%3DuMQdSqzBi1RmJnOK1pgv%2B3wqHgUeGfw%40mail.gmail.com?utm_medium=email_source=footer
 
<https://groups.google.com/d/msgid/ansible-project/CALh2VP%2B4HhMTofFOuJ%3DuMQdSqzBi1RmJnOK1pgv%2B3wqHgUeGfw%40mail.gmail.com?utm_medium=email_source=footer>>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.

Debian and Sympa administration.

-- 
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/9f3e4a8f-61c1-b7fd-5900-9593636b0f2f%40linuxia.de.

--
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/CALh2VPJcjJ6VVwVa02_k9Awp9W37bgyQUU_nELjK%2BLJoCa-%3DEg%40mail.gmail.co

Re: [ansible-project] Re: Getting Timed Out Error when running the playbook using `vagrant provision`

2022-02-03 Thread Stefan Hornburg (Racke)

On 03/02/2022 13:47, arjungoel 1995 wrote:

Hi, I tried to ping the port and IP address using SSH and getting timeout 
error. Can you please help me how to fix this?


image.png


Does "vagrant ssh" work?

Regards

 Racke



On Thu, Feb 3, 2022 at 5:37 PM Roberto Paz  wrote:

Have you tried to manually run an *ssh *command to that IP address and 
port? If ssh command also returns a timeout, then that is the main source of 
the issue.

El miércoles, 2 de febrero de 2022 a la(s) 14:29:08 UTC-3, 
arjung...@gmail.com escribió:

Hi,

I am trying to run a basic ansible playbook using vagrant provision but 
while doing so experiencing this error:

I even added the ip in my Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
*  config.vm.network "private_network", ip: "172.30.240.1"*
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "playbook.yaml"
  end
Also I am not able to install ansible on windows using pip and like you 
know git bash won't support installation of ansible.
While I am getting version compatibility issues while trying the same 
using WSL.
Please help.
Thanks
Arjun Goel
But still experiencing the issue.ansible_timeout_error.PNG
end

-- 
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/ac2f697a-ee8d-483f-b9df-c08f8142a182n%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/CALh2VP%2B4HhMTofFOuJ%3DuMQdSqzBi1RmJnOK1pgv%2B3wqHgUeGfw%40mail.gmail.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/9f3e4a8f-61c1-b7fd-5900-9593636b0f2f%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] multiple vm playbook

2022-02-02 Thread Stefan Hornburg (Racke)

On 02/02/2022 19:50, Rene Paquin wrote:


I am attempting to create a playbook to deploy multiple linux  VMs from a 
template and assigning a static ip and I am running into issues.  My playbook:

---

- hosts: localhost

  gather_facts: no

  vars_files:

    - group_vars/vars

    - group_vars/vars_sec

  tasks:

  - name: Clone the template

    vmware_guest:

  hostname: "{{ vcenter_server }}"

  username: "{{ vcenter_user }}"

  password: "{{ vcenter_pass }}"

  validate_certs: False

  name: "{{ item.name }}"

  template: "{{ template }}"

  datacenter: "{{ datacenter_name }}"

  folder: "{{ folder }}"

  cluster:  "{{ cluster_name }}"

  datastore: "{{ datastore }}"

  networks:

    name: "{{ lan }}"

    ip:  '{{ item.ip }}'

    netmask: 255.255.254.0

    gateway: "{{ gw }}"

    connected: yes

    start_connected: yes

  state: poweredon

  wait_for_ip_address: yes

    delegate_to: localhost

    with_items:

    - { name: qanstest01, ip: 10.10.73.43 }

    - { name: qanstest02, ip: 10.10.73.44 }

    - { name: qanstest03, ip: 10.10.73.45 }

When I run the playbook I get the following error output

  "msg": "argument 'networks' is of type  and we were unable to convert to 
list:  cannot be converted to a list"

Any suggestions on how to get around this?


Use a list for the network parameters as shown in the examples for this module:

networks:

    - name: "{{ lan }}"

  ip:  '{{ item.ip }}'

  netmask: 255.255.254.0

  gateway: "{{ gw }}"

      connected: yes

      start_connected: yes


Regards

    Racke


Thanks,


Rene Paquin - Systems Administrator
Wilfrid Laurier University
Waterloo, Ontario
(519)884-0710 x3795
rpaq...@wlu.ca 

--
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/YT2PR01MB6256445CD02F696E3D8F076CD8279%40YT2PR01MB6256.CANPRD01.PROD.OUTLOOK.COM
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/fd814503-424c-9be2-16ae-96c14fb30199%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Getting jsondiff is not installed error even though jsondiff is installed

2022-02-02 Thread Stefan Hornburg (Racke)

On 02/02/2022 18:09, Nick Plichta wrote:

Getting fatal: [192.168.0.51]: FAILED! => {"changed": false, "msg": "jsondiff is not 
installed, try 'pip install jsondiff'"} error on fresh ansible install on ubuntu 20.04 via apt. 
Additionally I installed python3-jsondiff and community.docker from ansible-galaxy. All I’m trying to do is 
destroy a docker stack using ansible-playbook. My yml looks like this



Did you install jsondiff on the target host?
Did you tell Ansible to use Python 3 on the target host 
(ansible_python_interpreter: /usr/bin/python3) ?

Regards
 Racke


---

- hosts: 192.168.0.51

    tasks:

      - name: Remove healthchecks stack

         docker_stack:

           name: healthchecks

           state: absent


What am I missing?

--
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/de19e1eb-c049-4195-9154-7d3adfdf5f27n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/3a1d1443-b3d1-082b-34ec-bfb02f5b%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Creating a string, containg a ':'

2022-01-26 Thread Stefan Hornburg (Racke)

On 26/01/2022 19:47, Axel Rau wrote:

Hi all,

seems to be an FAQ item but I can’t find the solution.
(Try to create sorce args for rsync):


set_fact:
   the_arg: ':{{ some_var }}'



So what's the problem with that?

Regards
Racke


Any help welcome,
Axel
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius




--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/d66ec0d5-49c0-f0c5-7509-681f19e63727%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] roles - apply variable values from /defaults/main.yml

2022-01-20 Thread Stefan Hornburg (Racke)

On 20/01/2022 19:47, dulhaver via Ansible Project wrote:

so, that is a clear yes (and great little exercise) then.
I'll have to figure out, why it does't work atm

thx for sharing


Well to get help you need to elaborate on "why it does't work atm".

The variables in defaults/main.yml do have very low priority BTW.

Regards

  Racke






On 01/20/2022 5:39 PM Vladimir Botka  wrote:

  
On Thu, 20 Jan 2022 17:15:42 +0100 (CET)

dulhaver via Ansible Project  wrote:


As far my understanding goes the /tasks/main.yml should read the variables from 
/defaults/main.yml no matter what (without any vars_files: declaration. Is that 
understanding correct?

Yes. This is correct. For example

shell> tree roles
roles
└── role01
 ├── defaults
 │   └── main.yml
 └── tasks
 └── main.yml

3 directories, 2 files

shell> cat roles/role01/defaults/main.yml
test_var: Hello

shell> cat roles/role01/tasks/main.yml
- debug:
 var: test_var

shell> cat playbook.yml
- hosts: localhost
   roles:
 - role01

shell> ansible-playbook playbook.yml

gives (abridged)

TASK [role01 : debug]
**
ok: [localhost] =>
   test_var: Hello


If this is not working for you provide "Minimal nonworking example"
https://en.wikipedia.org/wiki/Minimal_working_example

--
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/20220120173923.6b4ce819%40gmail.com.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/d469fdfb-dafb-e632-03a0-05bafb0b1340%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] is ~/.bashrc of a become_user read upon TASK execution?

2022-01-19 Thread Stefan Hornburg (Racke)

On 19/01/2022 11:34, dulhaver via Ansible Project wrote:


can anybody tell me whether the ~/.bashrc of a become_user is being read on 
TASK execution, so you could rely on aliases, environment variables or PATH to 
be effective?



As far as know it is not being read. And I doubt that is a good idea if the 
goal is idempotence.

Regards
Racke


--
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/1756296122.520131.1642588450250%40office.mailbox.org
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/34f499ca-45b9-2efc-3b91-f34d73c586a7%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Help with acme_certificate / letsencrypt and empty challenge_data

2022-01-18 Thread Stefan Hornburg (Racke)

On 18/01/2022 18:52, Parth Patel wrote:

How inventory_hostname would contain domain ?



If you put foo.example.com into the inventory, the inventory_hostname would 
include the domain example.com.

Regards
Racke


Its just a special variable pre defined in ansible which contains name of the 
host for which task or play runs

On Tue, 18 Jan 2022 at 10:56 PM, Jason Wood mailto:ja...@definedatabase.com>> wrote:

inventory_hostname is not the domain, it is a variable which contains the 
domain. That's the part where I'm not sure how to reference it.

I will try upgrading to see if that changes anything. Thanks!

On Tuesday, January 18, 2022 at 12:03:31 p.m. UTC-5 Felix Fontein wrote:

Hi,

 > I'm fairly new to this. I'm using ansible 2.9.6 on Ubuntu 20.04.

that version is really old and outdated. You should upgrade at least to
the latest 2.9.x release (2.9.27), or even to the latest Ansible
release (5.2.0).

This is the correct syntax (assuming your domain name is
inventory_hostname):

 > when: acme_challenge_mydomain is changed and inventory_hostname in
 > acme_challenge_mydomain['challenge_data']

Without knowing your playbook...

 > but in both cases the task executes even though I can see with a
 > debug task that challenge_data is empty:
 > ..."challenge_data": {},...

...it's hard to say why this happens.

Same for this:

 > My second question is... I have remaining_days set to 91, and there
 > are 89 days left, so shouldn't I have data in challenge_data?

There should be. (You can also set `force: true` to force regeneration.)

Are you sure that you are really running the playbook that you
modified, and not something else?

Cheers,
Felix


-- 
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/d0750be4-1afe-4635-885e-8e377ff98d70n%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/CAEMGyL%2B2_ND0gOOHMv%3DyNi8LuXM4%2BU7mX0wRF3UFP5YzU43coA%40mail.gmail.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/aba94d67-426e-7de6-d231-5353eb67be60%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Trick to remove a backslash liternal in Ansible?

2022-01-14 Thread Stefan Hornburg (Racke)

On 14/01/2022 16:17, Jibun no Kage wrote:

New to Ansible, having trouble doing the following:  shell command returns a "This 
is a test\u" string.  I can't seem to find a way to trim the '\u'.  Since it 
seem to be tricking to remove a backslash literal in Ansible?

The following would work in a shell command...
  cat /proc/device-tree/model | cut -d '\' -f1

But Ansible chokes on the '\'?  And even '\\'  does not work since cut command 
can't handle more than one char.  So the cut parsing trips or Ansible parsing 
trips.  A bit of a catch-22.

Figure there has to be an Ansible elegant way to do this?

Any help appreciated.


 - debug:
 msg: "{{ input | regex_replace('u', '') }}"
   vars:
 input: 'This is a test\u'

You might need *four* backslashes to get rid of the original backslash.

But you can get away with *two" by swapping the quotes:

 - debug:
 msg: '{{ input | regex_replace("\\u", "") }}'
   vars:
 input: 'This is a test\u'

Regards
Racke



--
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/a71e1eb3-4ddb-4461-bffd-1a3ea5004e2bn%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/87f1ea8a-8d4b-3c3c-de2c-a611fa0cbe05%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Odd results from query of /proc/meminfo?

2022-01-14 Thread Stefan Hornburg (Racke)

On 14/01/2022 18:23, Jibun no Kage . wrote:

Odd results from query of /proc/meminfo?

When I do the following from shell...
# cat /proc/meminfo | grep MemTotal
MemTotal:    8087276 kB

But when I do the same via Ansible...
ok: [192.168.1.212] => {
     "msg": "Pi Memory Total: MemTotal: 957160 kB"
}



Why messing with the shell when the information is already present in the facts?

 - name: Show memory
  debug:
msg: "{{ ansible_memory_mb }}"

TASK [Show memory] *
ok: [bullseye-test-box] =>
  msg:
nocache:
  free: 828
  used: 1154
real:
  free: 82
  total: 1982
  used: 1900
swap:
  cached: 0
  free: 0
  total: 0
  used: 0

Regards
   Racke


Ansible Source...
     - name: Memory Total
   #shell: "cat /proc/meminfo | grep MemTotal | cut -d ':' -f2 | cut -d 'k' -f1 
| tr -d ' '"
   shell: "cat /proc/meminfo | grep MemTotal"
   register: m
   changed_when: False

     - name: Memory Total
   debug:
     msg: "Memory Total: {{ m.stdout }}"

Returned value is greater than physical memory size!




--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/39e4a9c2-480d-d2c6-c1c7-4e77a7415b52%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] include_roles, with tags from a dictionary loop?

2022-01-11 Thread Stefan Hornburg (Racke)

On 11/01/2022 15:53, dkol...@olearycomputers.com wrote:

Hey;

I'm having difficulty coming up with the right syntax to add/include roles, 
with tags, from a loop such that I can limit execution to specific tags.


Hello,

in my opinion tags should be use to control the playbook flow and not to 
determine which role is getting to applied to a server.

This belongs to the inventory:

- import_role:
name: mysql
  when: "'mysql_servers' in group_names"

- import_role:
name: nginx
   when: "'nginx_servers' in group_names"

This is more flexible than tags and a better place for the assignment of the 
roles.

Regards
   Racke


In the tasks section, this syntax works:


# This syntax works but isn't very flexible.  It does, however,
# allow us to select specific tasks to run.
   - name: include root role
     include_role:
       name: root
     tags:
       - rootpwd
       - rootbin
       - rootkeys
       - drex

   - name: include commone role
     include_role:
       name: common

and I can limit execution by running  'ansible-playbook ./pb.yml -l grp -l 
rootpwd' for instance.  That's not very flexible; however, as I'd like to avoid 
having to edit the playbook every time a role gets a new tag.

I have a structure in my group_vars/all file thusly:

commonroles:
   - { n: common,  t: [ 'nil' ] }
   - { n: root,    t: [ 'rootpwd', 'rootbin', 'rootkeys', 'drex' ] }

Debug tasks show I have the syntax the way I expect; however, I can't seem to 
get the include_role module to use the structure

For example, this syntax, in the tasks section, results in no tags::

   - name: include common roles
     include_role:
       name: "{{rolename.n}}"
       apply:
         tags: "{{rolename.t}}"
     loop: "{{commonroles}}"
     loop_control:
       loop_var: rolename

$ ansible-playbook ./configmgmt.yml -l amwtest --list-tags

playbook: ./configmgmt.yml

   play #1 (all): Main configuration management playbook TAGS: []
       TASK TAGS: []

Without the --ilst-tags, this results in an error:

FAILED! => {"msg": "the field 'tags' should be a list of ((,), ), but the item '['nil']' is a 

So, it seems my issue is how I'm trying to present the tags...

Any ideas on how I can create a data structure of roles and tags that's usable 
by include_role  via a loop?

Thanks for any hints/tips/suggestions.

Doug O'Leary

--
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/1ca6c514-2fb0-42d4-a9d1-a8225fbd389fn%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/da0f6a07-d76e-e9dc-0704-d3bc0730bb20%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] how can i get around this error?

2021-12-30 Thread Stefan Hornburg (Racke)

On 30/12/2021 09:16, Kerem Kalayci wrote:

Hi everyone, i'm newbie at ansible yml.
I am trying to run a command like below. But I am getting an error as below. 
where am i doing wrong?

- gather_facts: False
   name: LINGO'da komut
   hosts: xxx
   remote_user: xxx

   tasks:
     - name: Run basic PowerShell script
       win_powershell:
       script: |
           C:\Users\emperior\Desktop\run_command.ps1



Looks like wrong indentation, please try this:

  tasks:
- name: Run basic PowerShell script
  win_powershell:
script: |
  C:\Users\emperior\Desktop\run_command.ps1

Regards
Racke



ERROR! conflicting action statements: win_powershell, script
The error appears to be in '/tmp/awx_13485_rbw826y0/project/5-create-iso.yml': 
line 10, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
   tasks:
     - name: Run basic PowerShell script
       ^ 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/365641a3-53a5-4012-b9c2-254ebf2c433an%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/cc05afff-dd46-60f5-4099-31f29f1cf685%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [⚠️] Re: [ansible-project] Print stout of failed task in recap

2021-12-24 Thread Stefan Hornburg (Racke)

On 25/12/2021 08:28, 'Jitender J' via Ansible Project wrote:

Hello,

Done some changes in callback module



OK, you can get the stdout value by saving it with register task parameter.

Regards
 Racke



On Sat, 25 Dec, 2021, 12:27 PM Stefan Hornburg (Racke), mailto:ra...@linuxia.de>> wrote:

On 24/12/2021 15:13, 'Jitender J' via Ansible Project wrote:
 > Hi Team,
 >
 > Hope everyone is doing good,
 >
 > I am wondering if there is a way to print stdout of a failed task in 
playbook recap
 >
 >
 > PLAY RECAP 

 >
 > Playbook Executed: zdx_test.yml 
***
 >
 > LIST OF FAILED NODES AND TASKS WHICH FAILED ON THEM 
***
 >
 > TASK=Check total CPU cores:
 > FAILED NODES=zdx-was1-vui-1b-smui1
 > what was the stdout value, don't want to scroll up
 > SERVICE FAILED ON TOTAL INSTANCES : 1
 >
 > TASK=Checking Connetion on Port 443 On ZIA SMUI From Provided UI:
 > FAILED NODES=zdx-was1-vui-1b-smui1
 > what was the stdout value, don't want to scroll up
 > SERVICE FAILED ON TOTAL INSTANCES : 1
 >
 > TASK=Check total memory:
 > FAILED NODES=zdx-was1-vui-1b-smui1
 > what was the stdout value, don't want to scroll up
 > SERVICE FAILED ON TOTAL INSTANCES : 1
 >
 > ALL NODES ARE REACHABLE 
***
 >

Hello,

how do you generate the "LIST OF FAILED NODES AND TASKS WHICH FAILED ON 
THEM" ?

Regards
         Racke

 > --
 > 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> 
<mailto: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/1eef7008-c30c-4ab4-af26-8b04fa8d9a7fn%40googlegroups.com 
<https://groups.google.com/d/msgid/ansible-project/1eef7008-c30c-4ab4-af26-8b04fa8d9a7fn%40googlegroups.com>
 
<https://groups.google.com/d/msgid/ansible-project/1eef7008-c30c-4ab4-af26-8b04fa8d9a7fn%40googlegroups.com?utm_medium=email_source=footer
 
<https://groups.google.com/d/msgid/ansible-project/1eef7008-c30c-4ab4-af26-8b04fa8d9a7fn%40googlegroups.com?utm_medium=email_source=footer>>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.

Debian and Sympa administration.


-- 
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/971d2390-ea47-f6f9-473a-d34f837a2b4b%40linuxia.de
 
<https://groups.google.com/d/msgid/ansible-project/971d2390-ea47-f6f9-473a-d34f837a2b4b%40linuxia.de>.

--
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/CAMO4JZv0wvnHVQ5nVYknYjQzU%3DLru4MCFQDapyi-9kBPE%3D-Npw%40mail.gmail.com
 
<https://groups.google.com/d/msgid/ansible-project/CAMO4JZv0wvnHVQ5nVYknYjQzU%3DLru4MCFQDapyi-9kBPE%3D-Npw%40mail.gmail.com?utm_medium=email_source=footer>.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/8423f504-ab66-a895-4e0e-78ff0d9a7cc6%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Print stout of failed task in recap

2021-12-24 Thread Stefan Hornburg (Racke)

On 24/12/2021 15:13, 'Jitender J' via Ansible Project wrote:

Hi Team,

Hope everyone is doing good,

I am wondering if there is a way to print stdout of a failed task in playbook 
recap


PLAY RECAP 


Playbook Executed: zdx_test.yml 
***

LIST OF FAILED NODES AND TASKS WHICH FAILED ON THEM 
***

TASK=Check total CPU cores:
FAILED NODES=zdx-was1-vui-1b-smui1
what was the stdout value, don't want to scroll up
SERVICE FAILED ON TOTAL INSTANCES : 1

TASK=Checking Connetion on Port 443 On ZIA SMUI From Provided UI:
FAILED NODES=zdx-was1-vui-1b-smui1
what was the stdout value, don't want to scroll up
SERVICE FAILED ON TOTAL INSTANCES : 1

TASK=Check total memory:
FAILED NODES=zdx-was1-vui-1b-smui1
what was the stdout value, don't want to scroll up
SERVICE FAILED ON TOTAL INSTANCES : 1

ALL NODES ARE REACHABLE 
***



Hello,

how do you generate the "LIST OF FAILED NODES AND TASKS WHICH FAILED ON THEM" ?

Regards
   Racke


--
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/1eef7008-c30c-4ab4-af26-8b04fa8d9a7fn%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/971d2390-ea47-f6f9-473a-d34f837a2b4b%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Switch Interface UP then playbook should end with error msg

2021-12-23 Thread Stefan Hornburg (Racke)

On 23/12/2021 11:54, Akshay Jadhav wrote:


    - name: show message if interface is not down
      fail:
       msg: "Interface is not down"
      when: {{ interface }}.operstatus == "up"

will this work?


Definitely not, that is pulled from thin air if you ask me.

Try that:

when: vars.get('ansible_' + interface).active

Note:

Gather facts saves the network interface information in separate variables 
(e.g. ansible_eth0) instead of a dict/list,
so accessing the info for a specific item is a bit awkward.

Regards
 Racke


On Thursday, 23 December 2021 at 12:22:41 UTC+5:30 dick@geant.org wrote:

What does your playbook look like?

On Thu, 23 Dec 2021 at 07:49, Akshay Jadhav  wrote:

Hi all,
I need a help from you guys for writing a play if Switch Interface UP 
then playbook should end with error msg using when condition. I am kind of new 
to ansible. So please help me out for writing this task.
Thank you 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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b481d0ff-1160-4307-9e2d-3e1433079a02n%40googlegroups.com
 
.

-- 
Sent from a mobile device - please excuse the brevity, spelling and punctuation.


--
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/1edeb012-822f-49a9-a58a-b6084ba583f1n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/edd5eeb0-d89e-b70c-5fbb-963cb2748636%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [⚠️] Re: [ansible-project] Shell Module Code Not Executing

2021-12-23 Thread Stefan Hornburg (Racke)

On 23/12/2021 09:44, 'Jitender J' via Ansible Project wrote:

Hi

Below is the piece of code I am trying to execute, it is running fine over 500 
nodes but there are some hosts in different environments where ansible not 
executing the code inside the shell module


Problems with arbitrary shell scripts is not related to Ansible IMHO.

Regards
  Racke


just passing the code without any error/output
#
  hosts: smca
  # tags: Node_check
   gather_facts: no
   user: ops
   tasks:

     - name: Executing Cluster Node Count Check On CA
       shell: |
         node_pipe_sepertated=`echo "{{ Nodes }}"|tr ',' '|'`
         c_id1=`for i in "$node_pipe_sepertated" ;do /sc/bin/smconfd smsm 
|egrep $i|awk '{print $(NF-5 )}';done`
         c_id=`echo "$c_id1"|tr -s ' ' '\n'|sort -u|tr -s '\n' ' '`
         echo "c id is $c_id"
          for i in ${c_id[@]};
          do
            echo "$i"
            Count=`/sc/bin/smconfd smsm |awk -v a=$i '$10 == a {print $NF}'|awk 
-F'.logs' '{print $1}'|wc -l`
            instances=`/sc/bin/smconfd smsm |awk -v a=$i '$10 == a {print 
$NF}'|awk -F'.logs' '{print $1}'`
            echo -e "\e[34m# Nodes In Cluster #\e[0m"

            if [ "$Count" -lt 2 ];then
               echo -e "\e[1;31mCRITICAL: Number Of Nodes in Cluster $Count 
\e[0m"
               echo "$instances"
               exit 2
            else
              echo -e "\e[1;32mOk: Number Of Nodes in Cluster $Count \e[0m"
              echo "$instances"

            fi
            echo " "
          done
       args:
        executable: /bin/bash
       ignore_errors: true
       when: smca_role==  true
###


On Thu, Dec 23, 2021 at 2:00 PM Dick Visser mailto:dick.vis...@geant.org>> wrote:

That's almost zero information.
Provide a full playbook and any other relevant information.


On Thu, 23 Dec 2021 at 09:27, 'Jitender J' via Ansible Project 
mailto:ansible-project@googlegroups.com>> 
wrote:

Hi Team,

Need you help on below issue

I am facing issue where code inside shell module is not getting 
executed over some remote server, ansible just passing the got without 
executing without any 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/40b39be1-57a3-4842-86c4-cdc638a87845n%40googlegroups.com
 
.

-- 
Sent from a mobile device - please excuse the brevity, spelling and punctuation.


-- 
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/CAL8fbwOGo1jjaWeMJ4%3DCeB0p7U3cY0%3DF4OsDgudTeTt7VMoTYA%40mail.gmail.com
 
.



--
*Regards,
*
*Jitender*

--
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/CAMO4JZvLGMqY29JtWBSgkGi9_8ZVijv6HwXWjevm%2BQCWOfoTYw%40mail.gmail.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/3a8becfa-b4d9-1681-7a50-cf03a694c3d7%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Deploy a Firewall in Ansible

2021-12-22 Thread Stefan Hornburg (Racke)

On 21/12/2021 22:21, Liliana Achig wrote:

Excuse me, I'm new to ansible. I don't know if you can help me, how can I check 
that the port of the firewall that I implemented was blocked or the change was 
made in the host node, the playbook has already run but I need to know how to 
do the rest


It would be helpful to reveal your playbook.

Try nmap to check whether ports are open or not.

Regards
Racke



El martes, 21 de diciembre de 2021 a las 5:39:34 UTC-5, dick@geant.org 
escribió:

Sounds like ansible is totally irrelevant to you.

First pick a firewall that suits your requirements and only then look how 
to automate it.


On Sun, 19 Dec 2021 at 22:43, Liliana Achig  wrote:

Please have a playbook template to deploy a Firewall in Ansible, there 
are not many on the internet, I have tried with them but they don't work for 
me, not Ansible firewallD, I was trying with UFW but I have not had any results 
either. Please someone who can help me with this issue, I thank in advance 
whoever does it for 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-proje...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2451813b-40a8-495a-805d-d6e7efbbe9dcn%40googlegroups.com
 
.

-- 
Sent from a mobile device - please excuse the brevity, spelling and punctuation.


--
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/f1d08586-4e14-47cb-9a90-d7a3850ce77en%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/d4e5c834-9be8-6962-971e-ddc15c681ad3%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Error while copying the file

2021-12-21 Thread Stefan Hornburg (Racke)

On 21/12/2021 11:15, Kumar Rahul wrote:

Hello all ,
I am new to this please help and reply
1. when i was trying to copy one file to other location i am getting

ERROR! this task 'copy' has extra params, which is only allowed in the 
following modules: add_host, win_command, shell, raw, include_role, command, 
win_shell, set_fact, include_vars, meta, include_tasks, import_role, 
import_tasks, script, group_by, include




Sounds like bad indentation.

Regards
 Racke


--
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/f582bb8e-31b1-4b99-8e39-dc65994495dan%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/4cd66b40-c6b3-259b-0acd-d3f5e034e99c%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Execute an .sql script on mysql with secure installation

2021-12-20 Thread Stefan Hornburg (Racke)

On 20/12/2021 18:42, Tiago Oliveira wrote:

oops, wrong code.

- name: Create a new .sql file for the table '{{table_name}}'
   template:
     src: templates/new_table_template
     dest: /home/secnet/{{table_name}}.sql

- name: Create the new database with name '{{table_name}}'
   expect:
     command: mysql -u root -p < {{table_name}}.sql
     responses:
       'Enter password:': ''
   register: wp
   failed_when: wp.rc not in [ 0, 1 ]

This one is the right one


From expect module documentation:

-- snip --
If you want to run a command through the shell (say you are using <, >, |, and so on), 
you must specify a shell in the command such as /bin/bash -c "/path/to/something | grep 
else".
-- snap --

Don't understand why you try to feed an empty password to MySQL. Do you use 
become: yes in your playbook? This would execute the task as root user.

Regards
  Racke



A segunda-feira, 20 de dezembro de 2021 à(s) 17:28:50 UTC, Tiago Oliveira 
escreveu:

Yeah, sorry.

- name: Create a new .sql file for the table '{{table_name}}'
   template:
     src: templates/new_table_template
     dest: /home/secnet/{{table_name}}.sql
   expect:
     command: mysql -u root -p < {{table_name}}.sql
     responses:
       'Enter password:': ''
   register: wp
   failed_when: wp.rc not in [ 0, 1 ]

The mysql_db module cant enter in mysql, returns the error     "msg": 
"unable to connect to database, check login_user and login_password are correct or 
/root/.my.cnf has
the credentials. Exception message: (1698, \"Access denied for user 
'root'@'localhost'\")"
}

since i need to enter with root user.

  Regards,

Tiago
A segunda-feira, 20 de dezembro de 2021 à(s) 17:14:36 UTC, ra...@linuxia.de 
escreveu:

On 20/12/2021 18:08, Tiago Oliveira wrote:
 > Hi,
 > I am trying to use an sql script to create a database in mariadb on 
a openbsd server with ansible.
 > My playbook first create the script with the name of the database to create and then uses 
expect to give the command "mysql -u root -p < script.sql" and then responses the password 
with "" because theres no password.
 > I try to use the script created by ansible and it works.
 > I try to use the same command that ansible is using and it works.
 > I took the "< script.sql" part to see if the problem was the 
password, and ansible enter in mysql without returning any error.
 >
 > When i use the playbook with "< script.sql" in command, ansible 
returns the error of non-zero return code returning rc=1.
 >
 > Anyone know how to solve it??

Maybe you start with sharing your playbook and the contents of the 
script!?

The modules mysql_user and mysql_db should be able to create your 
database with the associated users.

Regards
Racke

 >
 > I've tried also the community.mysql module, but it didnt worked also 
to create the first database.
 >
 > Best Regards,
 >
 > Tiago Oliveira
 >
 > --
 > 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/44af35a2-29db-4847-a9fe-a1f27a0dc1ebn%40googlegroups.com 

 
>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.

Debian and Sympa administration.


--
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/8e92a586-abe3-493d-8506-563a82801b1cn%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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] Execute an .sql script on mysql with secure installation

2021-12-20 Thread Stefan Hornburg (Racke)

On 20/12/2021 18:08, Tiago Oliveira wrote:

Hi,
I am trying to use an sql script to create a database in mariadb on a openbsd 
server with ansible.
My playbook first create the script with the name of the database to create and then uses expect to 
give the command "mysql -u root -p < script.sql" and then responses the password with 
"" because theres no password.
I try to use the script created by ansible and it works.
I try to use the same command that ansible is using and it works.
I took the "< script.sql" part to see if the problem was the password, and 
ansible enter in mysql without returning any error.

When i use the playbook with "< script.sql" in command, ansible returns the 
error of non-zero return code returning rc=1.

Anyone know how to solve it??


Maybe you start with sharing your playbook and the contents of the script!?

The modules mysql_user and mysql_db should be able to create your database with 
the associated users.

Regards
Racke



I've tried also the community.mysql module, but it didnt worked also to create 
the first database.

Best Regards,

Tiago Oliveira

--
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/44af35a2-29db-4847-a9fe-a1f27a0dc1ebn%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/365a5e70-e323-2f9c-263d-58a0c5c616e3%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [⚠️] Re: [ansible-project] Facing Issue Ansible Summary

2021-12-20 Thread Stefan Hornburg (Racke)

On 20/12/2021 15:44, 'Jitender J' via Ansible Project wrote:

Hi Antony,

Thanks for the mail, below is the playbook code snippet

##
- hosts: "{{ UI }}"
   gather_facts: no
   user: ops
   tasks:
    - name: Check total CPU cores
      shell: |
        cpu=`sysctl hw.model hw.machine hw.ncpu|grep  hw.ncpu:`
        echo "$cpu"|awk -F':' '{
        if ($2 >= 5)
         print "\033[32mOK:\033[0m" $0;
        else
         print $0,  echo -e "\033[31m CRITICAL\033[0m" }'
      register: err_cpu
      failed_when: '"CRITICAL" in err_cpu.stdout'
      args:
       executable: /bin/bash
      ignore_errors: true

    - name: Check total memory
      shell: |
        mem=`echo "$(sysctl -n hw.physmem)/1024/1024/1024"|bc`
        echo "$mem"|awk '{
        if ($NF >= 48)
         print "\033[32mOK:\033[0m" $0
        else
          print  $0,  echo -e "\033[31m CRITICAL\033[0m" }'
      register: err_mem
      failed_when: '"CRITICAL" in err_mem.stdout'
      args:
       executable: /bin/bash
      ignore_errors: true
#


Why don't use ansible_facts instead of these horrible shell hacks?

Regards
Racke



On Mon, Dec 20, 2021 at 8:06 PM Antony Stone mailto:antony.st...@ansible.open.source.it>> wrote:

On Monday 20 December 2021 at 15:34:02, 'Jitender J' via Ansible Project
wrote:

 > Hi Team,
 >
 > Facing a very strange issue, my failed task output getting swapped with
 > another task, in summary, we have done some modification in the callback
 > module but never saw like this before, any suggestion

My suggestion is to show us your playbook which can do this.

Antony.

-- 
What do you call a dinosaur with only one eye?  A Doyouthinkesaurus.


                                                    Please reply to the 
list;
                                                          please *don't* CC 
me.



--
*Regards,
*
*Jitender*

--
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/CAMO4JZs_XPhYKoHNqmjTYzLVWzCo%3Dr2v4o9VWYAomquz5nNXsA%40mail.gmail.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/eab28ae1-9394-e273-1e36-b8079523ef1e%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Need to Input Host information while run time in Ansible-playbook

2021-12-16 Thread Stefan Hornburg (Racke)

On 16/12/2021 11:31, Joel Justin wrote:

Hi Team,
Is there any ways to provide mulitple hosts value input while ansible-playbook 
runitme? I dont wish to provide the host value in static inventory , instead 
the hosts information should be fetched while runtime.is there any ways to 
do that.

Thanks in advance.


Hello,

what about dynamic inventories? 
https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html.

Regards
Racke



--
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/6e3d8e13-d378-441c-b355-5bfa1ab0923bn%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/7231f721-94aa-3439-79db-23ea1ef99b63%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] How do I correctly pass NULL in set_fact ?

2021-12-15 Thread Stefan Hornburg (Racke)

On 15/12/2021 13:40, Anthony Palermo wrote:

I am not able to pass a NULL to community.mysql.mysql_query but I think the 
issue is independent from the module

https://gist.github.com/aworldofcode/35de280946fabcc66e2eea15c8a13dd8


# mariadb sql table includes the following column
`date_of_removal` datetime DEFAULT NULL,


# The Key Dict is either
'main_dict.removal_info is defined': '2021-12-19 21:50:43' # a datetime 
properly formated
'main_dict.removal_info is defined': 'N/A' # A string

# The goal is to properly provide a Null when 'N/A' is present

# Meanwhile in Ansible set_fact

- name: Set the etl_dictionary Key Value Dictionary from main_dict request
set_fact:
etl_dictionary: >-
{

{% if main_dict.removal_info is defined -%}
{% if 'N/A' in main_dict.removal_info -%}
"date_of_removal": 'Null' ,
{% else %}
"date_of_removal": "{{main_dict.removal_info}}",
{% endif %}
{% endif %}

}

# SQL Statement
# Cannot execute SQL 'INSERT INTO  'N/A', 'No', 'null', 'N/A' The expected 
behaviour to achieve is ... 'N/A', 'No', Null, 'N/A'


how would I pass correctly null in a set_fact ?


I think that the Python keyword None (without quotes around) is the equivalent 
of a null value and should translate to NULL in the SQL world.
Not tested though.

Regards
   Racke



--
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/55e0f1ca-b655-432c-917a-7e8d40912cb2n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/5b7d2483-1a93-4931-c7ab-c7cb2c85b121%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Copy folder from one host to another

2021-12-09 Thread Stefan Hornburg (Racke)

On 10/12/2021 06:12, Lucas Possamai wrote:

Hi all,

I need to copy the content of a folder from one remote host to another remote host. The 
copy command needs to be executed as user "postgres".

Folder to be copied from source: /data/postgresql/pg_xlog/
Destination: /data/wal_archive/

I tried looking online but couldn't find anything useful. Can someone please 
point me in the right direction?

Cheers,
Lucas



Hello Lucas,

take a look at the synchronize module.

Regards
Racke


--
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/CAE_gQfXUa%2BDRoqiZ1Oairs7LauTsSpoQu%2B4eZPa6WkR%2BbcXdmg%40mail.gmail.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/166e43b4-a220-5024-46fb-9ff7449b48d1%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Iterate host definitions into single file

2021-12-09 Thread Stefan Hornburg (Racke)

On 09/12/2021 11:36, Chris Jefferies wrote:

Racke,
One glitch that I did not understand...

I must add:

host: all

instead of just

hosts: icinga.example.com

... and run with all hosts defined in the playbook.  I was only using 
icinga.example.com (the false name of my server).  Now I must add:

when: "{{inventory_hostname == 'icinga.example.com'}}"

to the other tasks.  Small price to pay.

Thank you.


Chris, you can still use "hosts: icinga.example.com" and iterate over the all 
group:

{% for host in groups['all'] %}
...
{% endfor %}

BTW: the when condition is automatically evaluated by Jinja, so drop the curly 
braces.

Regards
 Racke



On Thursday, December 9, 2021 at 1:12:39 AM UTC-8 ra...@linuxia.de wrote:

On 09/12/2021 10:07, Chris Jefferies wrote:
 > Racke,
 > *ansible_play_hosts* - I did not know about this *magic* variable, as 
they call it.  I'll test but I assume that the attributes come with it.
 >
 > Then you describe defining a task with:
 >
 > run_once: yes
 > delegate_to: localhost
 >
 > I see run_once in the documentation and they said it was like running 
only on the first host; which is fine because now I want to run using 
*ansible_play_hosts* which gets me all the hosts.
 >
 > Then instead of using:
 > delegate_to: localhost
 >
 > I think I can delegate to the server I am actually running against:
 > delegate_to: icinga.example.com 

Chris,

yes you can use icinga.example.com  if that host 
is part of your inventory.

Racke


 >
 > Or are you suggesting I delegate to localhost, then copy the resulting 
file?
 >
 > dick,
 > I hope the above result explains what and how I would like to do.  But to explain 
a bit... I want to end up with a file that has something like this content, below.  I was 
trying to figure out a way to subvert the normal processing of an inventory host file and do 
it all into one file.  Racke has show a way of doing this by using a "magic 
variable" that holds all of the host info I need and how to run it only once so I don't 
get a bunch of repetitive files being generated.  It's beautiful...  if it works.  ;)   I'm 
sure it will.
 >
 > object Host "myhost1.mine.me " {
 >   import "generic-host"
 >   address = "192.68.0.1"
 >   vars.os = "Linux"
 > }
 > object Host "myhost2.mine.me " {
 >   import "generic-host"
 >   address = "192.68.0.2"
 >   vars.os = "Linux"
 > }
 >
 > Thank you.
 >
 >
 > On Thursday, December 9, 2021 at 12:02:00 AM UTC-8 ra...@linuxia.de 
wrote:
 >
 > On 09/12/2021 08:19, Chris Jefferies wrote:
 > > I use ansible a lot for work and for my home lab.  I love it.
 > >
 > > I keep needing an approach that so far has stumped me, so asking here 
for advice.
 > >
 > > I want to create a single file (an icinga2_hosts.conf) which has a 
separate collection of attributes from each host in my hosts inventory file.  I would 
like to use jinja2 to template one instance and iterate through the hosts building 
the file in one go; not host by host in the usual ansible approach...  although if a 
single file can be built by that method, I'm all ears.
 > >
 >
 > You can iterate through your hosts with
 >
 > {% for host in ansible_play_hosts %}
 > ...
 > {% endfor %}
 >
 > and use hostvars[host]['myattribute'] to access an attribute from you 
inventory.
 >
 > To create the file, use template or copy with content parameter and add
 >
 > run_once: yes
 > delegate_to: localhost
 >
 > Regards
 > Racke
 >
 > > I think I could duplicate the hosts section in the vars section and 
then iterate the yaml data for the single file with a loop.
 > >
 > > I could actually create a file for each host and that would actually 
work in icinga2.  But I want it in a single file for future readability and to avoid 
having to look in each host file for some anomaly.
 > >
 > > I could give up on ansible for this and use python and jinja2 to pass 
the hosts inventory file to a jinja2 render function.
 > >
 > > Is there a way to actually read the hosts inventory in traditional 
ansible style and iterate it into a single file using jinja2 as the template 
mechanism?
 > >
 > > I've wanted to do this in other scenarios but abandoned those attempts.
 > >
 > > Any tips and tricks appreciated.
 > > Chris.
 > >
 > > --
 > > 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 

Re: [ansible-project] Iterate host definitions into single file

2021-12-09 Thread Stefan Hornburg (Racke)

On 09/12/2021 10:07, Chris Jefferies wrote:

Racke,
*ansible_play_hosts* - I did not know about this *magic* variable, as they call 
it.  I'll test but I assume that the attributes come with it.

Then you describe defining a task with:

run_once: yes
delegate_to: localhost

I see run_once in the documentation and they said it was like running only on 
the first host; which is fine because now I want to run using 
*ansible_play_hosts* which gets me all the hosts.

Then instead of using:
delegate_to: localhost

I think I can delegate to the server I am actually running against:
delegate_to: icinga.example.com


Chris,

yes you can use icinga.example.com if that host is part of your inventory.

Racke




Or are you suggesting I delegate to localhost, then copy the resulting file?

dick,
I hope the above result explains what and how I would like to do.  But to explain a 
bit... I want to end up with a file that has something like this content, below.  I was 
trying to figure out a way to subvert the normal processing of an inventory host file and 
do it all into one file.  Racke has show a way of doing this by using a "magic 
variable" that holds all of the host info I need and how to run it only once so I 
don't get a bunch of repetitive files being generated.  It's beautiful...  if it works.  
;)   I'm sure it will.

object Host "myhost1.mine.me" {
  import "generic-host"
  address = "192.68.0.1"
  vars.os = "Linux"
}
object Host "myhost2.mine.me" {
  import "generic-host"
  address = "192.68.0.2"
  vars.os = "Linux"
}

Thank you.


On Thursday, December 9, 2021 at 12:02:00 AM UTC-8 ra...@linuxia.de wrote:

On 09/12/2021 08:19, Chris Jefferies wrote:
> I use ansible a lot for work and for my home lab.  I love it.
>
> I keep needing an approach that so far has stumped me, so asking here for 
advice.
>
> I want to create a single file (an icinga2_hosts.conf) which has a 
separate collection of attributes from each host in my hosts inventory file.  I 
would like to use jinja2 to template one instance and iterate through the hosts 
building the file in one go; not host by host in the usual ansible approach...  
although if a single file can be built by that method, I'm all ears.
>

You can iterate through your hosts with

{% for host in ansible_play_hosts %}
...
{% endfor %}

and use hostvars[host]['myattribute'] to access an attribute from you 
inventory.

To create the file, use template or copy with content parameter and add

run_once: yes
delegate_to: localhost

Regards
Racke

> I think I could duplicate the hosts section in the vars section and then 
iterate the yaml data for the single file with a loop.
>
> I could actually create a file for each host and that would actually work 
in icinga2.  But I want it in a single file for future readability and to avoid 
having to look in each host file for some anomaly.
>
> I could give up on ansible for this and use python and jinja2 to pass the 
hosts inventory file to a jinja2 render function.
>
> Is there a way to actually read the hosts inventory in traditional 
ansible style and iterate it into a single file using jinja2 as the template 
mechanism?
>
> I've wanted to do this in other scenarios but abandoned those attempts.
>
> Any tips and tricks appreciated.
> Chris.
>
> --
> 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/5b0de281-4c29-49f7-bbcf-0fe2ef957b70n%40googlegroups.com 

 
>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.

Debian and Sympa administration.


--
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/c0dbc61d-15d1-4ec5-8635-99f42b85fd3en%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application 

Re: [ansible-project] Iterate host definitions into single file

2021-12-09 Thread Stefan Hornburg (Racke)

On 09/12/2021 08:19, Chris Jefferies wrote:

I use ansible a lot for work and for my home lab.  I love it.

I keep needing an approach that so far has stumped me, so asking here for 
advice.

I want to create a single file (an icinga2_hosts.conf) which has a separate 
collection of attributes from each host in my hosts inventory file.  I would 
like to use jinja2 to template one instance and iterate through the hosts 
building the file in one go; not host by host in the usual ansible approach...  
although if a single file can be built by that method, I'm all ears.



You can iterate through your hosts with

{% for host in ansible_play_hosts %}
...
{% endfor %}

and use hostvars[host]['myattribute'] to access an attribute from you inventory.

To create the file, use template or copy with content parameter and add

  run_once: yes
  delegate_to: localhost

Regards
   Racke


I think I could duplicate the hosts section in the vars section and then 
iterate the yaml data for the single file with a loop.

I could actually create a file for each host and that would actually work in 
icinga2.  But I want it in a single file for future readability and to avoid 
having to look in each host file for some anomaly.

I could give up on ansible for this and use python and jinja2 to pass the hosts 
inventory file to a jinja2 render function.

Is there a way to actually read the hosts inventory in traditional ansible 
style and iterate it into a single file using jinja2 as the template mechanism?

I've wanted to do this in other scenarios but abandoned those attempts.

Any tips and tricks appreciated.
Chris.

--
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/5b0de281-4c29-49f7-bbcf-0fe2ef957b70n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/60992f0e-5e83-0cdc-7594-8a56c7c114f8%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Parted plugin fails after first run

2021-12-06 Thread Stefan Hornburg (Racke)

On 06/12/2021 10:50, Lucas Possamai wrote:

On Mon, 6 Dec 2021 at 22:21, dulhaver via Ansible Project 
mailto:ansible-project@googlegroups.com>> 
wrote:

__
I have seen something similar with re-running LVM operations and remember they mentioned to add a *force: yes* option (I don't recall the exact wording though) in oder the not fail on re-execution. Wondering whether something alike would help here too. 



Hmm that didn't help.

This is working for me, but I think that's ugly.. there must be another way to 
achieve this:

- name: Check if {{ data_volume }}is already mounted
shell: df | grep {{ data_volume }}| wc -l
with_items: "{{ data_volume }}"
register: ebs_checked



Hello Lucas,

it is more efficient and less fragile to check "ansible_mounts" fact, e.g.

 when: ansible_mounts | selectattr('fstype', 'equalto', 'ext4') | 
selectattr('mount', 'equalto', data_volume) | list | count > 1

(not tested).

Regards
  Racke



- name: Create a new ext4 primary partition for /data
run_once: true
community.general.parted:
name: pg_data
device: "{{ data_volume }}"
number: 2
state: present
fs_type: ext4
when: "{{item.stdout}} == 0"
with_items: "{{ ebs_checked.results }}"

- name: Create a ext4 filesystem on "{{ data_volume }}" (/data)
run_once: true
community.general.filesystem:
fstype: ext4
dev: "{{ data_volume }}"
when: "{{item.stdout}} == 0"
with_items: "{{ ebs_checked.results }}"

- name: Mount /data
ansible.posix.mount:
path: /data
src: "{{ data_volume }}"
fstype: ext4
state: mounted
opts: defaults

--
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/CAE_gQfUMJgDFKv0-x5Nyn109X7ZtS6qbwaO64VdadJBVx-2Q%2BQ%40mail.gmail.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/b9968f48-fee7-6f3c-53cd-ef2259dc1a6c%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] remote copy issue

2021-12-02 Thread Stefan Hornburg (Racke)

On 01/12/2021 18:08, Rene Paquin wrote:


I am attemping o copy a file from one remote linux server to two remote linux 
servers.  My playbook is:

- name: copy file

  hosts: “remote source server”

  gather_facts: false

  tasks:

    - name: "copy "

  copy:

    src: /opt/odrive/alc/library/libraryusername.csv

    remote_src: yes

    dest: /var/alc

  delegate_to: destination server 1

  check_mode: yes

    - name: "copy "

  copy:

    src: /opt/odrive/alc/library/libraryusername.csv

    remote_src: yes

    dest: /var/alc

  delegate_to: destination server 2

  check_mode: yes

I get the following error despite the file being there.

"msg": "Source /opt/odrive/alc/library/libraryusername.csv not found"

What am I missing?


The copy module only supports the controller or target itself (remote_src) for 
the source file.

Take a look at the synchronize module if you want copy from one target to 
another.

Regards

    Racke



Rene Paquin - Systems Administrator
Wilfrid Laurier University
Waterloo, Ontario
(519)884-0710 x3795
rpaq...@wlu.ca 

--
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/YQBPR0101MB62463290E15B126F8E6BF23AD8689%40YQBPR0101MB6246.CANPRD01.PROD.OUTLOOK.COM
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/7addf104-5064-0bce-0a39-09aed56c3d6a%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Encrypt files on remote host

2021-11-29 Thread Stefan Hornburg (Racke)

On 26/11/2021 11:39, 'Roman Steinhart' via Ansible Project wrote:

Hi Stefan,

probably with openssl or gpg.
See
https://gist.github.com/dreikanter/c7e85598664901afae03fedff308736b 
<https://gist.github.com/dreikanter/c7e85598664901afae03fedff308736b>
https://www.gnupg.org/gph/en/manual/x110.html 
<https://www.gnupg.org/gph/en/manual/x110.html>

I mean, I could do this with a basic shell module, but I'm wondering that 
there's no module fur such actions.



Hello Roman,

yeah, I guess you need to use the command module (not the shell module) or a 
dedicated backup software that does the encryption.

Regards
Racke


Thanks,
Roman

On Thu, 25 Nov 2021 at 18:50, Stefan Hornburg (Racke) mailto:ra...@linuxia.de>> wrote:

On 25/11/2021 18:22, 'Roman Steinhart' via Ansible Project wrote:
 > Hi all,
 >
 > I want to encrypt a file on a remote host. I was looking through the 
existing modules and couldn't find any that is able to do that?
 >
 > My use case is that I want to create a backup (tar file) on a remote 
host, encrypt the backup archive and upload it to some storage.
 >
 > I'm aware of Ansible vault, but it's intended purpose is for encrypting 
secrets etc. to use it in the playbook and not encrypting a remote file.
 > Maybe someone has a suggestion.
 > Thanks!
 > ~ Roman

Hello Roman,

how would you do the encryption without Ansible?

Regards
           Racke

 >
 > --
 > 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> 
<mailto: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/d334642c-5982-480c-a4a1-76f6036131c6n%40googlegroups.com 
<https://groups.google.com/d/msgid/ansible-project/d334642c-5982-480c-a4a1-76f6036131c6n%40googlegroups.com>
 
<https://groups.google.com/d/msgid/ansible-project/d334642c-5982-480c-a4a1-76f6036131c6n%40googlegroups.com?utm_medium=email_source=footer
 
<https://groups.google.com/d/msgid/ansible-project/d334642c-5982-480c-a4a1-76f6036131c6n%40googlegroups.com?utm_medium=email_source=footer>>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.

Debian and Sympa administration.


-- 
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/rRD_f5yiVBA/unsubscribe 
<https://groups.google.com/d/topic/ansible-project/rRD_f5yiVBA/unsubscribe>.
To unsubscribe from this group and all its topics, 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/17fdd7e3-f072-96a1-9459-8a47343f%40linuxia.de
 
<https://groups.google.com/d/msgid/ansible-project/17fdd7e3-f072-96a1-9459-8a47343f%40linuxia.de>.

--
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/CAKrGhHLC0QnxrmTBhZ8nb6G_Go4aQUia9uB9jOB55HO316EChQ%40mail.gmail.com
 
<https://groups.google.com/d/msgid/ansible-project/CAKrGhHLC0QnxrmTBhZ8nb6G_Go4aQUia9uB9jOB55HO316EChQ%40mail.gmail.com?utm_medium=email_source=footer>.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/ab483b4b-e853-36e0-438e-d0da61870185%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Encrypt files on remote host

2021-11-25 Thread Stefan Hornburg (Racke)

On 25/11/2021 18:22, 'Roman Steinhart' via Ansible Project wrote:

Hi all,

I want to encrypt a file on a remote host. I was looking through the existing 
modules and couldn't find any that is able to do that?

My use case is that I want to create a backup (tar file) on a remote host, 
encrypt the backup archive and upload it to some storage.

I'm aware of Ansible vault, but it's intended purpose is for encrypting secrets 
etc. to use it in the playbook and not encrypting a remote file.
Maybe someone has a suggestion.
Thanks!
~ Roman


Hello Roman,

how would you do the encryption without Ansible?

Regards
 Racke



--
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/d334642c-5982-480c-a4a1-76f6036131c6n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/17fdd7e3-f072-96a1-9459-8a47343f%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Calculate partition space used in jinja

2021-11-22 Thread Stefan Hornburg (Racke)

On 22/11/2021 14:19, lift...@gmail.com wrote:

My apologies.  I obviously forgot to add the error.  I did find that I was missing a ')' 
character at the end of the "Total Space" line. But now I get the following:

FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no 
attribute 'size'"}

The j2 file is above, but here's the playbook I'm using:

---
- hosts: localhost
   become: true
   become_method: sudo
   gather_facts: yes

   tasks:

   - name: Print out server mounts
     template:
       src: /root/server_mounts.html.j2
       dest: /var/tmp/server_mounts.html
     delegate_to: localhost
     run_once: true

I can't find why its complaining about a "size" attribute.


Hello Harry,

I don't see that problem either, are you really sure that the you posted the 
content of /root/server_mounts.html.j2?

BTW: That's a really weird location for any part of your Ansible project if you 
ask me.

Regards
 Racke



Thanks,
Harry
On Saturday, November 20, 2021 at 1:10:51 AM UTC-5 dick@geant.org wrote:

What is the error you get ?

On Fri, 19 Nov 2021 at 21:44, lift...@gmail.com  wrote:

I have a playbook that uses gather facts, then I use the ansible_mounts 
fact in a jinja2 template.  In this template, I can print out each partition, 
the total size and total available.  What I'd like to do is to also calculate 
the percentage of space available.  I'm trying below, but keep getting a 
templating error when the playbook runs.  Any ideas?

server_mounts.html.j2


Partition/Mount Space Report

{{ now(false, '%m/%d/%Y %I:%M:%S') }}

---

{% for i in play_hosts | sort %}
Host: {{ i }}

{% for m in hostvars[i]['ansible_mounts'] %}
Partition: {{ m.mount }}
Total Space: {{ m.size_total|human_readable(unit="G") }}
Available Space: {{ m.size_available|human_readable(unit="G" }}
{% if m.size_total|int != 0 %}
Space used: {{ 100 * ((m.size_total - 
m.size.available/m.size_available)) |round(1, 'common') }}
{% endif %}
{% endfor %}
---
{% endfor %}



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/f2ce821e-98c6-4ae8-97bc-032580358ad6n%40googlegroups.com
 
.

-- 
Sent from a mobile device - please excuse the brevity, spelling and punctuation.


--
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/4223039a-c344-4808-b72f-36adfda7f586n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/d4308792-9a71-2baf-a47f-3cf2d0469b92%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Re: Non Config Data in Ansible NRM Module

2021-11-22 Thread Stefan Hornburg (Racke)

On 22/11/2021 09:46, Anees fathima Saifudeen wrote:

Hi,
Could anyone please respond.


I have no clue what NRM is about.

Regards
   Racke



Thanks in advance,
Anees Fathima
On Thursday, November 18, 2021 at 8:28:15 PM UTC+5:30 Anees fathima Saifudeen 
wrote:

Hi,

Could you please confirm the below query,

  * Can we define non-configurable attributes in the NRM model ?
  o if Yes, how do we achieve the same.
  o If No, is NRM scope is restricted only to configurable attributes ?


Thanks in advance,
Anees Fathima

--
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/72db7eb4-0412-4f2c-b129-964be35f9c8fn%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/9fe57bb6-97e7-7189-79f3-0338d254b52b%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] How to set hostname with running number

2021-11-22 Thread Stefan Hornburg (Racke)

On 22/11/2021 09:00, dudu.c...@gmail.com wrote:

Hi,
In my inventory file i have 3 server, I need to set the hostname including 
prefix1-3

web1
web2
web3

*Inventory fie:*

[web]
192.168.0.47
192.168.0.48
192.168.0.49



Add the hostname to the inventory file:

web1 ansible_host=192.168.0.47


*Playbook*

- hosts:
     - web
   become: true
   any_errors_fatal: true
   tasks:


     - name: update hostname
       hostname:
         name : "web "



Now you can use the inventory_hostname variable in your task:

   - name: update hostname
 hostname:
   name: "{{ inventory_hostname }}"

Please note that might not survive reboots, e.g on Ubuntu I'm doing:

- name: Enable preserving hostname in Cloud configuration
  lineinfile:
path: /etc/cloud/cloud.cfg
line: 'preserve_hostname: true'
regexp: '^preserve_hostname:'
  tags: hostname

Regards
  Racke


--
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/2dd18239-c65d-4717-9d90-af4c2aba1a68n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/6c6ac5f1-51a6-c067-472b-e22316a489d2%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] how to stop ansible from ignoring syntax errors

2021-11-18 Thread Stefan Hornburg (Racke)

On 18/11/2021 10:29, Axel Rau wrote:

Hi all,

is there a central knob to stop ansible from continuing after a syntax error?
Also, it seems that ansible continues after failed tasks in included roles or 
included tasks.

How can I let ansible stop on all those errors?


Hello Axel,

can you give an example, please?

Regards
Racke



Thanks, Axel
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius




--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/9089abb2-9d0e-7ec4-59d8-20f3560799ba%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Can't find error in jinja2 expression

2021-11-16 Thread Stefan Hornburg (Racke)

On 16/11/2021 19:50, Axel Rau wrote:

Hi all,

in a template, I have:

data_directory = '{{ {{ i.data }}/{{ postgresql_version }}/data }}‘

but I’m getting:
  "AnsibleError: template error while templating string: expected token ':', 
got ‚}'

In the calling ansible block, I have:
   loop:
 - '{{ i.data }}/{{ postgresql_version }}/data/pg_hba.conf‘

What am I doing wrong?


Hello Axel,

you certainly can't nest the curly braces.

Regards
   Racke



Any help appreciated

Axel
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius




--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/e6635e8c-2ce9-5e76-76bd-0b5d2daaa2d1%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Determining distribution specific facts/paths/etc

2021-11-15 Thread Stefan Hornburg (Racke)

On 15/11/2021 17:43, or...@nwra.com wrote:

I've found myself writing a lot of tasks like:

- name:"RedHat: Set facts"
set_fact:path_lib_security="/usr/lib64/security"
when:ansible_os_family == 'RedHat'or ansible_os_family == 'SHMZ'

- name:"Debian: Set facts"
set_fact:path_lib_security="/lib/x86_64-linux-gnu/security"
when:ansible_os_family == 'Debian'

- name:"EL8+: Set facts"
set_fact:pam_kwallet="pam_kwallet5.so"
when:ansible_distribution_major_version|int >= 8

- name:"Not EL8+: Set facts"
set_fact:pam_kwallet="pam_kwallet.so"
when:ansible_distribution_major_version|int < 8
tags:always

- name:"Check if pam_kwallet is installed"
stat:
path:"{{ path_lib_security }}/{{ pam_kwallet }}"
register:kwallet

Lately, I've started to think that this would be better served by a lookup 
plugin, e.g. (this is very crude and a different set of facts):


I don't think the lookup plugin makes it any easier or user friendly. The 
common approach is to put the OS dependent variables in separate files and use

include_vars, for example:

- name: Include variables depending on OS details
  include_vars: "{{ item }}"
  with_first_found:
    - files:
    - "{{ ansible_distribution }}-{{ ansible_distribution_major_version 
}}.yml"
    - "{{ ansible_distribution }}.yml"
    - "{{ ansible_os_family }}.yml"
    - "defaults.yml"

The disadvantage of this approach that you need to repeat the values from 
Debian.yml in Debian-11.yml.

Regards

 Racke




# python 3 headers, required if submitting to Ansible
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

DOCUMENTATION = """
 lookup: distro_facts
 author: Orion Poplawski mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/13f6b77c-ced7-413e-9eb9-45bc49e66815n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/9ae04b1e-e9cc-7811-bcb8-64fe39da5685%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] I want to execute nohup command on remote host using ansible but it didn't work

2021-11-15 Thread Stefan Hornburg (Racke)

On 15/11/2021 10:32, dulhaver via Ansible Project wrote:


I guess the error message you got would be helpful in order to troubleshoot 
your problem


At any rate, nohup is IMHO not the correct way to start an application as a 
server / daemon. Even if some tutorials on the web say so. There is no control 
of the running application, so please use some kind of supervisor (e.g.systemd).

On top of that using the shell module is fragile and not recommended unless the 
command module really doesn't to the trick for you.

Regards

 Racke





On 11/15/2021 9:34 AM Dip Giri  wrote:


---

- name: Application setup
  hosts: aws
  gather_facts: no
  tasks:

    - name: Start application
      shell: nohup mvn spring-boot:run -Drun.jvmArguments="-Xmx1024m" &
      args:
        chdir: /home/dipak

*I want to execute nohup command on remote host using ansible but it didn't 
work *


--
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/77f328ac-d41b-44b5-a7ff-3f85f89fbe54n%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/2021256539.3416.1636968749678%40office.mailbox.org
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/cd6fbdfc-18b4-94fd-3f53-471f8714589b%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Unarchive and FreeBSD

2021-11-10 Thread Stefan Hornburg (Racke)

On 10/11/2021 18:32, Norman Gray wrote:


Greetings.

I recently raised issue , 
connected to the behaviour of the `unarchive` module on FreeBSD.  It was closed as a 
duplicate and, in effect, not-a-bug, with the indication that any further commentary 
or discussion would be more welcome here than on the bugparade.

So...

One workaround suggested is to install gtar on the target machine, but apart 
from that requiring a further package/task, it's arguably poor FreeBSD style to 
require tools that aren't part of the install (requiring Python in order to use 
Ansible is of course a necessary breach of that).  FreeBSD (and I think the 
other BSDs as well) places something of a premium on using the tool-suite 
available in the stock install, where possible.  Because of its dependence on 
an optional package (gtar), I would therefore class the `unarchive` module as 
‘broken on stock FreeBSD’.

The alternative workaround of avoiding `unarchive`, and using the `command` 
module to untar archives, is more attractive, to the extent that it fits my 
perception of good style in this context.

I'd be interested in any thoughts.

Best wishes,

Norman



Hello Norman,

I'm more pragmatic:

- name: Install GNU tar on Alpine Linux
  package:
name: tar
  when: ansible_os_family == 'Alpine'

- name: Install GNU tar on FreeBSD
  package:
name: gtar
  when: ansible_os_family == 'FreeBSD'

Yes it requires an extra task, but still better IMHO than inventing workarounds 
for unarchive.

Regards
 Racke

--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/5da06ccc-607f-2249-8cea-63ad984b5d8e%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] installing postgres - error with initdb -D /path/to/pg_data

2021-10-27 Thread Stefan Hornburg (Racke)

On 27/10/2021 17:11, dulhaver via Ansible Project wrote:

I figured out that apparently using ansible_become_user: root in the 
defaults.yml is meesing things up

Changing
ansible_become_user: root
to
ansible_root_user: root

in the defaults file and the playbok makes this issue going away. Apparently 
the term ansible_become_user is more then just a string and overwrites all 
other become_user occurences.


I think there is actually no need to set these variables at all as "root" is 
the default.

Regards
Racke



If I remember correctly it may be even workable to skip the become_user: xyz 
(and just say become: yes) in the playbook if I do not want to become anyone 
else then root and likewise share me this sort of trouble





On 10/27/2021 4:45 PM Jorge Rúa  wrote:


Hey!

We can't access the playbook here - https://pastebin.com/edit/9Uvjdupe 
 at least I can't. pastebin redirects me to 
the login page. I can however access default_postgres.yml file

I'm going to assume you are using sudo as become_method. I am also going to 
assume selinux is not part of the issue here, nor standard unix permissions or 
posix acls.

When you run the task manually:  /opt/db/postgres/postgresql/bin/initdb -D 
/opt/db/data/postgres/data/ on the target as user postgres ... say you login as 
root to the machine then you run su - postgres, right? At this point you are 
running commands as postgres.

 I'm wondering if you can mimic that very same behaviour adding become_flags to 
the equation:

- name: configure postgres - create database
  command: "{{ postgres_home }}/bin/initdb -D {{ postgres_data }}"
  args:
    creates: "{{ postgres_data }}/PG_VERSION"
  become: yes
  become_flags: "su - {{ ansible_postgres_user }} -c"
  become_user: "{{ ansible_postgres_user }}"

Please let me know if that works,

Regards,










El mié, 27 oct 2021 a las 14:32, dulhaver via Ansible Project 
(mailto:ansible-project@googlegroups.com>>) 
escribió:

__

  * here is the entire playbook 
  * here is the defaults_postgres.yml  I 
refer to in it

I am wondering whether the use of a ...

  * ansible_become_user: root
  * ansbile_postgres_user: postgres

... in the same context may be related to my problem



On 10/27/2021 1:55 PM dulhaver via Ansible Project mailto:ansible-project@googlegroups.com>> wrote:


I have a playbook to install postgresql on a rhel8 target


one TASK should start the initdb process ...

\\\
- name: configure postgres - create database
  command: "{{ postgres_home }}/bin/initdb -D {{ postgres_data }}"
  args:
    creates: "{{ postgres_data }}/PG_VERSION"
  become: yes
  become_user: postgres

\\\


but fails with an "initdb: error: cannot be run as root" error  *details 
below


\\\
TASK [configure postgres - create database] 
**
fatal: [vm-51150-0180.step.zrz.dvz.cn-mv.de 
]: FAILED! => changed=true
cmd:
- /opt/db/postgres/postgresql/bin/initdb
- -D
- /opt/db/data/postgres/data
delta: '0:00:00.009346'
end: '2021-10-27 11:54:25.210944'
msg: non-zero return code
rc: 1
start: '2021-10-27 11:54:25.201598'
stderr: |-
initdb: error: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
stderr_lines: 
stdout: ''
stdout_lines: 

\\\

the TASK however has a particular become_user: postgresspecified. 
Furthermore Selinux is set to @permissive in an erlier TASK.

Manually running /opt/db/postgres/postgresql/bin/initdb -D 
/opt/db/data/postgres/data/on the target as user postgres works, so I can not 
make much sense of this. It's kind of obvious the become process does not work, 
but I can't figure out why. Plaid a bit with indentation, but did not find any 
solution that works


-- 
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] Splunk cluster configuration using ansible playbook

2021-10-27 Thread Stefan Hornburg (Racke)

On 27/10/2021 04:46, Vinod P wrote:

Hello All,

Have any one tried deploying  Splunk Cluster using ansible playbook.

Please share some details.

regards
Vinod


Hello Vinod,

it looks like Splunk provides playbooks for Ansible: 
https://github.com/splunk/splunk-ansible. That might help you.

Regards
Racke



--
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/d3af12f6-962f-4b89-9b14-0ec38ec9329fn%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/6955e863-e70b-3e92-cf20-e4544d397ae7%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] one email for multiple hosts

2021-10-22 Thread Stefan Hornburg (Racke)

On 22/10/2021 16:09, Raj wrote:

Hi, VGM

my playbook call roles  ssl scan  ( final part is email to send once)  but it 
is sending 100 emails


Did you ever check the indentation on your task sending email as advised?

delegate_to should really work.

Regards

    Racke



---
- hosts: "{{ web }}"
  gather_facts: yes
  roles:
- SSL_scan

On Thursday, October 14, 2021 at 11:09:29 AM UTC-4 dick@geant.org wrote:

So, post that playbook

On Thu, 14 Oct 2021 at 17:03, Raja Natte  wrote:

Hi..


Yes it is running in same playbook.

On Thu, Oct 14, 2021, 10:21 AM Dick Visser  wrote:

This is just the one mail task.
It must be part of a playbook, where other things happen as well, 
and which will reveal the cause.

Also, you say "I am trying to send one email to team after job is 
successfully completed".
I guess this "job" is the running of the playbook?




On Thu, 14 Oct 2021 at 15:12, Raj  wrote:


Hi Racke,

This is my code

- name: Sending email to about SSL scan
  mail:
    host: x
    port: 25
    subject: 
    body:  
    from: xxx
    to:
   # - 
    - 
  delegate_to: localhost
  run_once: true
On Thursday, October 14, 2021 at 1:28:05 AM UTC-4 
ra...@linuxia.de wrote:

On 13/10/2021 22:13, Raj wrote:
> Hi All,
>
> I am trying to send one email to team after job is 
successfully completed.  Issue is playbook sending (if inventory have 100 servers 
). It is sending 100 emails.
>
> I tried in my code:  delegate_to: localhost and run_once: 
true it doesn't help please provide your inputs it really helpful .

That should work. Please provide your code.

Regards

   Racke

>
> TIA
> Raja
> --
> 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/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com 

 
>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.

Debian and Sympa administration.

-- 
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/f662886f-2a63-4988-a2b7-e15a4dfbfd16n%40googlegroups.com
 
.



-- 
Dick Visser

Trust & Identity Service Operations Manager
GÉANT
-- 
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/CAL8fbwNz4ToNKCBngPbHOtB4%3D%3DHbFvx%3DTCJ6%3D4CL-kSrgvrDUA%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-proje...@googlegroups.com.

To view this discussion on the web visit 

Re: [ansible-project] package TASK ... 'should be run under the root user'

2021-10-20 Thread Stefan Hornburg (Racke)

On 20/10/2021 16:45, dulhaver via Ansible Project wrote:



On 10/20/2021 4:07 PM Stefan Hornburg (Racke) mailto:ra...@linuxia.de>> wrote:


On 20/10/2021 15:49, dulhaver via Ansible Project wrote:



On 10/20/2021 3:32 PM Stefan Hornburg (Racke) mailto:ra...@linuxia.de> 
<mailto:ra...@linuxia.de <mailto:ra...@linuxia.de>>> wrote:


On 20/10/2021 15:26, dulhaver via Ansible Project wrote:
>

* I have this TASK in a playbook <https://pastebin.com/h83HqMn0 
<https://pastebin.com/h83HqMn0> <https://pastebin.com/h83HqMn0 
<https://pastebin.com/h83HqMn0>>> which should install a bunch of packages on my (rhel8) 
target rrequired for postgresql
*
I am shooting my playbok as a user with root priviledges via sudo


Please show the code that you are using for that user in your playbook.


it is the paste https://pastebin.com/h83HqMn0 <https://pastebin.com/h83HqMn0> 
<https://pastebin.com/h83HqMn0 <https://pastebin.com/h83HqMn0>>. However ... here you 
go


Sorry, I wanted to see the head of the playbook respective the place in 
inventory where you set up the
become: variables.

actually I figured out in the meantime that aparently my trouble lies exactly 
there:
I have a defaults.yaml that injects a bunch of variables into the playbook.
In that defaults.yml there is a variable referencing to user 'postgres' as 
ansible_become_user

ansible_become_user: postgres

So I assume I'll have to figure out how to utilize different become users in a 
single playbook. I tried or overrule the defaults entry temporarily with ...

  become: yes
become_user: [root_user]

... inside the TASK, but that apparently was not interpreted in the way I wanted


The default for the become_user should be root and you can override it in your 
tasks.

It can be tricky, so here an example how I do it:

- name: Ensure PostgreSQL database is initialized (RedHat, Suse)
  command: "{{ postgresql_initdb_path }} -D {{ postgresql_data_dir }}"
  become: true
  become_user: "{{ postgresql_user }}"
  vars:
    ansible_ssh_pipelining: true
  when:
    - postgresql_data_version_dir.stat.exists == false
    - ansible_os_family in ['Alpine', 'RedHat', 'Suse']

Regards

 Racke


--
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/1635706396.1095.1634741116055%40office.mailbox.org
 
<https://groups.google.com/d/msgid/ansible-project/1635706396.1095.1634741116055%40office.mailbox.org?utm_medium=email_source=footer>.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/3b435cb3-fe96-da86-e55f-16e6ce4d4823%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] package TASK ... 'should be run under the root user'

2021-10-20 Thread Stefan Hornburg (Racke)

On 20/10/2021 15:49, dulhaver via Ansible Project wrote:



On 10/20/2021 3:32 PM Stefan Hornburg (Racke) mailto:ra...@linuxia.de>> wrote:


On 20/10/2021 15:26, dulhaver via Ansible Project wrote:
>

* I have this TASK in a playbook <https://pastebin.com/h83HqMn0 
<https://pastebin.com/h83HqMn0>> which should install a bunch of packages on my 
(rhel8) target rrequired for postgresql
*
I am shooting my playbok as a user with root priviledges via sudo


Please show the code that you are using for that user in your playbook.


it is the paste https://pastebin.com/h83HqMn0 <https://pastebin.com/h83HqMn0>. 
However ... here you go


Sorry, I wanted to see the head of the playbook respective the place in 
inventory where you set up the
become: variables.



##
- name: check installed system packages for postgres
   package:
     name:
     - psmisc
     - strace
     - gdb
     - nagios-plugins-mysql
     - nagios-plugins-pgsql
     - nagios-plugins-http
     - openssl
     - pam
     - readline
     - libselinux
     - systemd-libs
     - zlib
     state: present
   ignore_errors: yes
   become: yes
   # become_user: [root_user]
##



(zealous_mode: yes)

Why do you use ignore_errors: yes here?

Regards
 Racke


*
In earlier TASKS of the playbook I become a 'postgres' user, but would expect 
this to be ephemeral (so I become the intital user as soon a TASK is finished)


If that is part of the task, it should be fine.

Regards

    Racke



*

still I am getting an (inexplicable to me) error <https://pastebin.com/6fQ8xNuK 
<https://pastebin.com/6fQ8xNuK>> upon running this playbook, which seems to 
indicate I am not a root-capable user when trying to install those packages.

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



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/7783ffd0-bbee-a3e4-02c8-70b514ccee8d%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] package TASK ... 'should be run under the root user'

2021-10-20 Thread Stefan Hornburg (Racke)

On 20/10/2021 15:26, dulhaver via Ansible Project wrote:


  * I have this TASK in a playbook  which should 
install a bunch of packages on my (rhel8) target rrequired for postgresql
 *
I am shooting my playbok as a user with root priviledges via sudo


Please show the code that you are using for that user in your playbook.


 *
In earlier TASKS of the playbook I become a 'postgres' user, but would 
expect this to be ephemeral (so I become the intital user as soon a TASK is 
finished)


If that is part of the task, it should be fine.

Regards

    Racke



 *

still I am getting an (inexplicable to me) error 
 upon running this playbook, which seems to 
indicate I am not a root-capable user when trying to install those packages.

can anybody help me out 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/965503419.166525.1634736398069%40office.mailbox.org
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


--
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/763c1508-f2dc-e83e-dc00-0bbea688d50a%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] tell 'service' module to continue with playbook, if service isn't found

2021-10-15 Thread Stefan Hornburg (Racke)

On 15/10/2021 16:16, dulhaver via Ansible Project wrote:



On 10/15/2021 1:37 PM dulhaver via Ansible Project 
 wrote:

  

On 10/15/2021 1:01 PM Stefan Hornburg (Racke)  wrote:

  
On 15/10/2021 12:40, dulhaver via Ansible Project wrote:

On 10/15/2021 12:07 PM Stefan Hornburg (Racke)  wrote:

   
On 15/10/2021 12:04, dulhaver via Ansible Project wrote:

On 10/15/2021 11:41 AM Stefan Hornburg (Racke)  wrote:


On 15/10/2021 11:20, dulhaver via Ansible Project wrote:


I am trying to install postgresql via a playbook and want to make sure the service 
is not running prior installation on the target (rhel7/8 & debian10) machines.

However my task below

    - name: stop postgresql.service from systemd if running
  service:
    name: postgresql.service
    state: stopped
        # enabled: false
  become: yes

is failing ('Could not find the requested service postgresql.service: host')

so, I guess I have to build something that directs the target to ignore that 
and continues with the playbook. I just can't see anything


You can check the status of the postgresql service as follows:

 - service_facts:

 - debug:
 msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"

TASK [service_facts] 
***
ok: [papas]

TASK [debug] 
***
ok: [papas] => {
"msg": {
"name": "postgresql",
"source": "sysv",
"state": "running"
}
}


are those arguments to the the "service" module? how exaclty would I weave 
those into my task? I tried

 - name: stop postgresql.service from systemd if running
   service:
 name: postgresql
   service_facts:
   debug:
 msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 
'absent'}) }}"
 state: stopped
 # enabled: false
   become: yes

but that did not work



No, use my tasks verbatim.


hm ... pasting this verbatim to my plabook does not survice a --symtax-check


What is the diagnosis of the syntax check?


##
play -v --limit [host] postgres_install.yml --syntax-check
Using /path/to/ansible.cfg as config file
ERROR! We were unable to read either as JSON nor YAML, these are the errors we 
got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
   did not find expected key

The error appears to be in 
'/home/gwagner/repos/ansible/step/step_server_env/postgres_install_test_external.yml':
 line 130, column 4, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:
- service_facts:
^ here
##



I figured out soome sort of sense-making output with adding 2 tasks based on 
what you posted.


- name: gather service facts
  service_facts:

- name: return postgres running or not
  debug:
msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"


however ... what do I do whith that output ('state: absent' in my test 
scenario)?

Maybe I need to put this to work as some sort of condition deciding whether to 
run a 'service' task disabling the postgresql.service or not?



Correct. For example:

when: ansible_facts.services.postgresql.state == 'running'


ok, thx. I'll play with that


I am still stuck with this:

theses 3 TASKS should take care of checking the status of postgresql.server and 
(if running) stop it

   - name: gather service facts
 service_facts:

   - name: return postgres running or not
 debug:
   msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"

   - name: stop postgresql.service from systemd if running
 service:
   name: postgresql
   state: stopped
   when: ansible_facts.services.postgresql.state == 'running'
 become: yes



"when" is a task level parameter and not a module parameter, so please shift it to the 
left on the same level as "become".

Regards
 Racke



however I am getting an  'Unsupported parameters for (systemd) module: when 
Supported parameters include: daemon_reexec, daemon

Re: [ansible-project] tell 'service' module to continue with playbook, if service isn't found

2021-10-15 Thread Stefan Hornburg (Racke)

On 15/10/2021 13:37, dulhaver via Ansible Project wrote:



On 10/15/2021 1:01 PM Stefan Hornburg (Racke)  wrote:

  
On 15/10/2021 12:40, dulhaver via Ansible Project wrote:

On 10/15/2021 12:07 PM Stefan Hornburg (Racke)  wrote:

   
On 15/10/2021 12:04, dulhaver via Ansible Project wrote:

On 10/15/2021 11:41 AM Stefan Hornburg (Racke)  wrote:


On 15/10/2021 11:20, dulhaver via Ansible Project wrote:


I am trying to install postgresql via a playbook and want to make sure the service 
is not running prior installation on the target (rhel7/8 & debian10) machines.

However my task below

    - name: stop postgresql.service from systemd if running
  service:
    name: postgresql.service
    state: stopped
        # enabled: false
  become: yes

is failing ('Could not find the requested service postgresql.service: host')

so, I guess I have to build something that directs the target to ignore that 
and continues with the playbook. I just can't see anything


You can check the status of the postgresql service as follows:

 - service_facts:

 - debug:
 msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"

TASK [service_facts] 
***
ok: [papas]

TASK [debug] 
***
ok: [papas] => {
"msg": {
"name": "postgresql",
"source": "sysv",
"state": "running"
}
}


are those arguments to the the "service" module? how exaclty would I weave 
those into my task? I tried

 - name: stop postgresql.service from systemd if running
   service:
 name: postgresql
   service_facts:
   debug:
 msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 
'absent'}) }}"
 state: stopped
 # enabled: false
   become: yes

but that did not work



No, use my tasks verbatim.


hm ... pasting this verbatim to my plabook does not survice a --symtax-check


What is the diagnosis of the syntax check?


##
play -v --limit [host] postgres_install.yml --syntax-check
Using /path/to/ansible.cfg as config file
ERROR! We were unable to read either as JSON nor YAML, these are the errors we 
got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
   did not find expected key

The error appears to be in 
'/home/gwagner/repos/ansible/step/step_server_env/postgres_install_test_external.yml':
 line 130, column 4, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:
- service_facts:
^ here
##


Could be an indentation problem.

Regards
   Racke





I figured out soome sort of sense-making output with adding 2 tasks based on 
what you posted.


- name: gather service facts
  service_facts:

- name: return postgres running or not
  debug:
msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"


however ... what do I do whith that output ('state: absent' in my test 
scenario)?

Maybe I need to put this to work as some sort of condition deciding whether to 
run a 'service' task disabling the postgresql.service or not?



Correct. For example:

when: ansible_facts.services.postgresql.state == 'running'


ok, thx. I'll play with that




--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/6947c99f-172d-bf50-7213-c6d7ae6ddb45%40linuxia.de.


OpenPGP_0x5B93015BFA2720F8.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] tell 'service' module to continue with playbook, if service isn't found

2021-10-15 Thread Stefan Hornburg (Racke)

On 15/10/2021 12:40, dulhaver via Ansible Project wrote:

On 10/15/2021 12:07 PM Stefan Hornburg (Racke)  wrote:

  
On 15/10/2021 12:04, dulhaver via Ansible Project wrote:

On 10/15/2021 11:41 AM Stefan Hornburg (Racke)  wrote:

   
On 15/10/2021 11:20, dulhaver via Ansible Project wrote:


I am trying to install postgresql via a playbook and want to make sure the service 
is not running prior installation on the target (rhel7/8 & debian10) machines.

However my task below

       - name: stop postgresql.service from systemd if running
     service:
       name: postgresql.service
       state: stopped
           # enabled: false
     become: yes

is failing ('Could not find the requested service postgresql.service: host')

so, I guess I have to build something that directs the target to ignore that 
and continues with the playbook. I just can't see anything


You can check the status of the postgresql service as follows:

- service_facts:

- debug:
msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"

TASK [service_facts] 
***
ok: [papas]

TASK [debug] 
***
ok: [papas] => {
   "msg": {
   "name": "postgresql",
   "source": "sysv",
   "state": "running"
   }
}


are those arguments to the the "service" module? how exaclty would I weave 
those into my task? I tried

- name: stop postgresql.service from systemd if running
  service:
name: postgresql
  service_facts:
  debug:
msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 
'absent'}) }}"
state: stopped
# enabled: false
  become: yes

but that did not work



No, use my tasks verbatim.


hm ... pasting this verbatim to my plabook does not survice a --symtax-check


What is the diagnosis of the syntax check?



I figured out soome sort of sense-making output with adding 2 tasks based on 
what you posted.


   - name: gather service facts
 service_facts:

   - name: return postgres running or not
 debug:
   msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"


however ... what do I do whith that output ('state: absent' in my test 
scenario)?

Maybe I need to put this to work as some sort of condition deciding whether to 
run a 'service' task disabling the postgresql.service or not?



Correct. For example:

when: ansible_facts.services.postgresql.state == 'running'

Regards
Racke



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/5ff305cb-bdbf-c335-4bd9-e77fbbfde318%40linuxia.de.


OpenPGP_0x5B93015BFA2720F8.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] tell 'service' module to continue with playbook, if service isn't found

2021-10-15 Thread Stefan Hornburg (Racke)

On 15/10/2021 12:04, dulhaver via Ansible Project wrote:

On 10/15/2021 11:41 AM Stefan Hornburg (Racke)  wrote:

  
On 15/10/2021 11:20, dulhaver via Ansible Project wrote:


I am trying to install postgresql via a playbook and want to make sure the service 
is not running prior installation on the target (rhel7/8 & debian10) machines.

However my task below

      - name: stop postgresql.service from systemd if running
    service:
      name: postgresql.service
      state: stopped
          # enabled: false
    become: yes

is failing ('Could not find the requested service postgresql.service: host')

so, I guess I have to build something that directs the target to ignore that 
and continues with the playbook. I just can't see anything


You can check the status of the postgresql service as follows:

   - service_facts:

   - debug:
   msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"

TASK [service_facts] 
***
ok: [papas]

TASK [debug] 
***
ok: [papas] => {
  "msg": {
  "name": "postgresql",
  "source": "sysv",
  "state": "running"
  }
}


are those arguments to the the "service" module? how exaclty would I weave 
those into my task? I tried

   - name: stop postgresql.service from systemd if running
 service:
   name: postgresql
 service_facts:
 debug:
   msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 
'absent'}) }}"
   state: stopped
   # enabled: false
 become: yes

but that did not work



No, use my tasks verbatim.

Regards
  Racke

--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/842bcdc0-9c09-458a-45d5-e873967940b4%40linuxia.de.


OpenPGP_0x5B93015BFA2720F8.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] tell 'service' module to continue with playbook, if service isn't found

2021-10-15 Thread Stefan Hornburg (Racke)

On 15/10/2021 11:20, dulhaver via Ansible Project wrote:


I am trying to install postgresql via a playbook and want to make sure the service 
is not running prior installation on the target (rhel7/8 & debian10) machines.

However my task below

     - name: stop postgresql.service from systemd if running
   service:
     name: postgresql.service
     state: stopped
         # enabled: false
   become: yes

is failing ('Could not find the requested service postgresql.service: host')

so, I guess I have to build something that directs the target to ignore that 
and continues with the playbook. I just can't see anything


You can check the status of the postgresql service as follows:

 - service_facts:

 - debug:
 msg: "{{ ansible_facts.services.postgresql | default({ 'state' : 'absent'}) 
}}"

TASK [service_facts] 
***
ok: [papas]

TASK [debug] 
***
ok: [papas] => {
"msg": {
"name": "postgresql",
"source": "sysv",
"state": "running"
}
}

Regards
Racke



--
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/2143903425.108349.1634289634148%40office.mailbox.org
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/fc307e08-e3c6-f46d-c5e9-148f8b140f3d%40linuxia.de.


OpenPGP_0x5B93015BFA2720F8.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] one email for multiple hosts

2021-10-14 Thread Stefan Hornburg (Racke)

On 14/10/2021 15:12, Raj wrote:


Hi Racke,

This is my code

- name: Sending email to about SSL scan
  mail:
    host: x
    port: 25
    subject: 
    body:  
    from: xxx
    to:
   # - 
    - 
  delegate_to: localhost
  run_once: true


The mail module apparently doesn't check its parameters. For example "from" is going to be ignored, 
as the correct parameter is "sender". Please double check your indentation. "run_once" 
should be working.

Regards

     Racke




On Thursday, October 14, 2021 at 1:28:05 AM UTC-4 ra...@linuxia.de wrote:

On 13/10/2021 22:13, Raj wrote:
> Hi All,
>
> I am trying to send one email to team after job is successfully 
completed.  Issue is playbook sending (if inventory have 100 servers ). It is 
sending 100 emails.
>
> I tried in my code:  delegate_to: localhost and run_once: true it doesn't 
help please provide your inputs it really helpful .

That should work. Please provide your code.

Regards

   Racke

>
> TIA
> Raja
> --
> 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/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com 

 
>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.

Debian and Sympa administration.

--
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/f662886f-2a63-4988-a2b7-e15a4dfbfd16n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/859efc4a-8a62-dfa5-67d8-1c4c49191be5%40linuxia.de.


OpenPGP_0x5B93015BFA2720F8.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] centos7 target - sudden python interpreter trouble

2021-10-14 Thread Stefan Hornburg (Racke)

On 14/10/2021 14:23, dulhaver via Ansible Project wrote:

the '# centos7' comment on 2 targets is legal I believe.
To rule this out I have removed it for a test run. Still the error was present


Somewhere the value /usr/bin/python3 must come from ... try to grep for this 
string through all relevant directories.

Regards

   Racke


On 10/14/2021 2:14 PM dulha...@mailbox.org wrote:

  

On 10/14/2021 1:44 PM Sandip Bhattacharya  wrote:

  
On 14.10.21 11:49, dulhaver via Ansible Project wrote:

I am running a playbook to install postgresql  
against a centos7 (python 2.75) target and am getting this error about a bad python 
interpreter .

I try to solve this via the inventory.yml

all:
    hosts:
      [hostname]: # centos7

Is this literally what is in your inventory.yaml file? Is that even valid yaml?
Shouldn't it be:

all:
hosts:
  hostname: # centos7


this is my literal inventory file: https://paste.debian.net/1215386/
it works for other playbooks, it works for ad-hoc commands (where I addresse a 
particular host from that group)



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/198061a5-4f5f-e241-45ef-293283b6ac1a%40linuxia.de.


OpenPGP_0x5B93015BFA2720F8.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Help me to achive this task

2021-10-14 Thread Stefan Hornburg (Racke)

On 14/10/2021 09:22, Dineshbabu Shankar wrote:

Can any one help me on this


Please define "not working".

Regards

 Racke




On Tue, 12 Oct, 2021, 8:58 pm Dineshbabu Shankar, mailto:shankardineshb...@gmail.com>> wrote:

My requiremnt ,

i need to add the disk to vms in vcenter   by passing
vm name, datastorename , and  disk_size   via csv file ,
with the following condition.
1. datastore which i am providing the csv should be in facts collected from 
vms
2.datastore  free volume is greater than what we requested (disk_size)
3.after taking the required disk_size the datastore should be  greater than 
equal to 20% of the total size of the datastore .

i can achieve this for the single server  but for more than one server i am 
struggling , can any one help me ,

Working one (for one server )
 cat test/diskadditionpre.yaml
---
  - hosts: localhost
    vars_prompt:
      - name: vcentername
        prompt: "Enter the vcenter name"
        private: no
      - name: vcenter_user
        prompt: "Enter the username"
        private: no
      - name: vcenter_password
        prompt: "Enter your password"
      - name: datastore_name
        prompt: "Enter the datastore name "
        private: no
      - name: disk_size
        prompt: "Enter the disksize in GB"


    tasks:
    - name: collecting the vminformation
      vmware_guest_facts:
        validate_certs: no
        hostname: "{{ vcentername }}"
        username: "{{ vcenter_user }}"
        password: "{{ vcenter_password }}"
        datacenter: DFW
        folder: /DFW/vm/Servers/Linux
        name: vmtest1
      delegate_to: localhost
      register: vm_info

    - name: Get the datastores associated with the VM
      set_fact:
         datastorelist: "{{vm_info.instance.hw_files | join (' ')}}"  # 
#converting list into the srting for easy  when condition use#

    - name: checking wheather enter correct datastore
      assert:
       that:
         - "datastore_name in datastorelist"
       success_msg: 'VM has correct Datastore.'
       fail_msg: 'Pls Enter the correct Datastore name '

    - name: Collecting the datastore information
      vmware_datastore_info:
        validate_certs: no
        hostname: '{{ vcentername }}'
        username: '{{ vcenter_user }}'
        password: '{{ vcenter_password }}'
        datacenter_name: DFW
        name: '{{datastore_name}}'
      delegate_to: localhost
      register: datastore_info
      when: " datastore_name in datastorelist " # if the datastorelist 
contains the name datastore_name procees furthur#

    - set_fact: datastore_cap="{{datastore_info.datastores[0].capacity |float / 
1073741824|float }}" # byte to GB converstion
    - set_fact: datastore_free="{{datastore_info.datastores[0].freeSpace |float 
/ 1073741824|float}}"
    - set_fact: 
datastore_used="{{datastore_info.datastores[0].provisioned|filesizeformat(true)}}"
    - set_fact: datastore_buffer="{{datastore_free|float - 
disk_size|float}}"
    - set_fact: datastore_buffer_s="{{(datastore_buffer)|float / ( 
datastore_cap)|float }}"
    - set_fact: datastore_buffer_percentage="{{100*(datastore_buffer_s) 
|float}}"
      when: " datastore_name in datastorelist "

    - name: Checking wheather datastore having enough disk
      assert:
        that:
          - "(datastore_free|float ) > (disk_size|float)"
          - "(datastore_buffer_percentage |float) > (20.0|float)"
        fail_msg: 'Free Disk is lesser than the required disksize'
        success_msg: 'Free Disk is greater than require disksize'

    - name: disk addition should be with either scsi controller with type  
no or controllernumber with type
      vmware_guest_disk:
       validate_certs: no
       hostname: "{{ vcentername }}"
       username: "{{ vcenter_user }}"
       password: "{{ vcenter_password }}"
       datacenter: DFW
       folder: /DFW/vm/Servers/Linux
       name: vmtest1
       disk:
       - size_gb: "{{disk_size}}"
         type: thick
         state: present
         scsi_controller: 2   #required paramater
         scsi_type: 'paravirtual' #required paramater
         datastore: "{{datastore_name}}"
         unit_number: 3 #required paramater
         destroy: no
      when:
        - "(datastore_free|float ) > (disk_size|float)"
        - "( datastore_name) in (datastorelist) "
        - "(datastore_buffer_percentage |float) > (20.0|float)"



NOT working (multiple servers)

---
  - hosts: localhost
    vars_prompt:
      - name: vcentername
        prompt: "Enter the vcenter name"
        private: no
      - name: vcenter_user
        

Re: [ansible-project] one email for multiple hosts

2021-10-13 Thread Stefan Hornburg (Racke)

On 13/10/2021 22:13, Raj wrote:

Hi All,

I am trying to send one email to team after job is successfully completed.  
Issue is playbook sending (if inventory have 100 servers ). It is sending 100 
emails.

I tried in my code:  delegate_to: localhost and run_once: true it doesn't help 
please provide your inputs it really helpful .


That should work. Please provide your code.

Regards

   Racke



TIA
Raja
--
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/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com
 
.



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
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/fd212cae-ad10-b9c3-f550-1534ff505e0f%40linuxia.de.


OpenPGP_0x5B93015BFA2720F8.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [ansible-project] Launch node server in background

2021-10-12 Thread Stefan Hornburg (Racke)

On 12/10/2021 20:32, 'Neil Young' via Ansible Project wrote:

OK, then back to the problem:

With and without nohup the same result: The app seems to start, but is killed 
then. Didn't try debug yet, but the console output looks good:

TASK [Start server (run as non-privileged user)] 
**
changed: [ubuntuVM] => {"changed": true, "cmd": "nohup node wss.js &\n", "delta": "0:00:01.190398", "end": "2021-10-12 18:30:38.791334", "msg": "", "rc": 0, 
"start": "2021-10-12 18:30:37.600936", "stderr": "", "stderr_lines": [], "stdout": "WSS mock running on port 8080", "stdout_lines": ["WSS mock running on port 8080"]}


TASK [Start server (run as non-privileged user)] 
**
changed: [ubuntuVM] => {"changed": true, "cmd": "node wss.js &\n", "delta": "0:00:01.182786", "end": "2021-10-12 18:31:23.449623", "msg": "", "rc": 0, "start": 
"2021-10-12 18:31:22.266837", "stderr": "", "stderr_lines": [], "stdout": "WSS mock running on port 8080", "stdout_lines": ["WSS mock running on port 8080"]}




My advice would be to write a script that does the nohup with all the 
redirections instead using it verbatim. See 
https://stackoverflow.com/questions/41676607/ansible-terminates-my-app-with-nohup
 for more information. If you do that, switch to command module.

Regards
   Racke





ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 20:24:53 UTC+2:

On 12/10/2021 20:20, 'Neil Young' via Ansible Project wrote:
 > Yes, now everyone understands that you've got it.
 >
 > Anyone else with an answer to the actual question? Why is that not 
possible?

Did you try to remove the redirection from your shell command and look at 
stdout/stderr (with register + debug task)?

Regards
Racke

 >
 > I don't mean: Why can't you do that?
 >
 > ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 20:09:54 UTC+2:
 >
 > On 12/10/2021 20:00, 'Neil Young' via Ansible Project wrote:
 > > Look, that sucks meanwhile. The question was: "why is this not 
working"? Not: Who here is able to teach me best practice?
 > >
 > > Because - this is something I can get around the corner.
 > >
 > > I give you the last word. Will not respond.
 > >
 > > Thanks
 > >
 >
 > Fair enough, but the trouble is other users might reuse your 
questionable examples.
 >
 >
 > Racke
 >
 > >
 > > ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 19:08:47 
UTC+2:
 > >
 > > On 12/10/2021 19:04, 'Neil Young' via Ansible Project wrote:
 > > > Posts disappear here...
 > > >
 > > > However, disregard. IMHO there is nothing wrong with "node server.js 
&" and I was just trying to figure out why this doesn't work with Ansible. I wasn't looking 
for a religious discussion.
 > > >
 > >
 > > Neither me .. just pointing out common sense using Ansible and Unix 
services.
 > >
 > > Regards
 > > Racke
 > >
 > > > ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 18:54:35 
UTC+2:
 > > >
 > > > On 12/10/2021 18:45, 'Neil Young' via Ansible Project wrote:
 > > > > ...even though it might not be the high level of "best practice" 
(in fact you can read a lot of this Racke comments, especially with Ansible) - and I'm surely aware 
of that - it is a legit shell command.
 > > > >
 > > >
 > > > Yes, but running a server through nohup is certainly bad practice. 
Nohup is rather provided to prevent long running processes to be disrupted.
 > > >
 > > > There is no really good way to control the server when it is 
running. How do you stop it for example? Restart it when it is crashed? Etc.
 > > >
 > > > And the shell called from Ansible doesn't have the same environment 
as when you login as regular user.
 > > >
 > > > Regards
 > > > Racke
 > > >
 > > >
 > > > >
 > > > > Neil Young schrieb am Dienstag, 12. Oktober 2021 um 18:43:12 UTC+2:
 > > > >
 > > > > Thanks for the helpful comment.
 > > > >
 > > > > ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 18:42:33 
UTC+2:
 > > > >
 > > > > On 12/10/2021 17:28, 'Neil Young' via Ansible Project wrote:
 > > > > > Hmm. I must be making again something fundamentally wrong :)
 > > > > >
 > > > >
 > > > > Yes, you are trying to use Ansible as glorified shell *and* ignore 
all the options to run a service properly (e.g. with systemd).
 > > > >
 > > > > Regards
 > > > > Racke
 > > > >
 > > > > > Trying to start a simple node server app into background
 > > > > >
 > > > > >
 > > > > >     - name: Start server (run as 

Re: [ansible-project] Launch node server in background

2021-10-12 Thread Stefan Hornburg (Racke)

On 12/10/2021 20:20, 'Neil Young' via Ansible Project wrote:

Yes, now everyone understands that you've got it.

Anyone else with an answer to the actual question? Why is that not possible?


Did you try to remove the redirection from your shell command and look at 
stdout/stderr (with register + debug task)?

Regards
Racke



I don't mean: Why can't you do that?

ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 20:09:54 UTC+2:

On 12/10/2021 20:00, 'Neil Young' via Ansible Project wrote:
 > Look, that sucks meanwhile. The question was: "why is this not working"? 
Not: Who here is able to teach me best practice?
 >
 > Because - this is something I can get around the corner.
 >
 > I give you the last word. Will not respond.
 >
 > Thanks
 >

Fair enough, but the trouble is other users might reuse your questionable 
examples.


Racke

 >
 > ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 19:08:47 UTC+2:
 >
 > On 12/10/2021 19:04, 'Neil Young' via Ansible Project wrote:
 > > Posts disappear here...
 > >
 > > However, disregard. IMHO there is nothing wrong with "node server.js 
&" and I was just trying to figure out why this doesn't work with Ansible. I wasn't 
looking for a religious discussion.
 > >
 >
 > Neither me .. just pointing out common sense using Ansible and Unix 
services.
 >
 > Regards
 > Racke
 >
 > > ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 18:54:35 
UTC+2:
 > >
 > > On 12/10/2021 18:45, 'Neil Young' via Ansible Project wrote:
 > > > ...even though it might not be the high level of "best practice" (in 
fact you can read a lot of this Racke comments, especially with Ansible) - and I'm surely aware of 
that - it is a legit shell command.
 > > >
 > >
 > > Yes, but running a server through nohup is certainly bad practice. 
Nohup is rather provided to prevent long running processes to be disrupted.
 > >
 > > There is no really good way to control the server when it is running. 
How do you stop it for example? Restart it when it is crashed? Etc.
 > >
 > > And the shell called from Ansible doesn't have the same environment as 
when you login as regular user.
 > >
 > > Regards
 > > Racke
 > >
 > >
 > > >
 > > > Neil Young schrieb am Dienstag, 12. Oktober 2021 um 18:43:12 UTC+2:
 > > >
 > > > Thanks for the helpful comment.
 > > >
 > > > ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 18:42:33 
UTC+2:
 > > >
 > > > On 12/10/2021 17:28, 'Neil Young' via Ansible Project wrote:
 > > > > Hmm. I must be making again something fundamentally wrong :)
 > > > >
 > > >
 > > > Yes, you are trying to use Ansible as glorified shell *and* ignore 
all the options to run a service properly (e.g. with systemd).
 > > >
 > > > Regards
 > > > Racke
 > > >
 > > > > Trying to start a simple node server app into background
 > > > >
 > > > >
 > > > >     - name: Start server (run as non-privileged user)
 > > > >       tags: server
 > > > >       shell: |
 > > > >         nohup node server.js 2>&1 &
 > > > >       args:
 > > > >         chdir: my-server-dir
 > > > >       become: yes
 > > > >       become_user: "{{ non_root_user }}"
 > > > >
 > > > > This runs w/o problems. However, the service is not started...
 > > > >
 > > > > Running the same command from console works...
 > > > >
 > > > > It doesn't even run as "sudo" (if f I remove the "become" lines at 
the end, my entire script runs as sudo)
 > > > >
 > > > >
 > > > >
 > > > > --
 > > > > 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/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com 
 
> 
 
>>

Re: [ansible-project] Launch node server in background

2021-10-12 Thread Stefan Hornburg (Racke)

On 12/10/2021 20:00, 'Neil Young' via Ansible Project wrote:

Look, that sucks meanwhile. The question was: "why is this not working"? Not: 
Who here is able to teach me best practice?

Because - this is something I can get around the corner.

I give you the last word. Will not respond.

Thanks



Fair enough, but the trouble is other users might reuse your questionable 
examples.


  Racke



ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 19:08:47 UTC+2:

On 12/10/2021 19:04, 'Neil Young' via Ansible Project wrote:
 > Posts disappear here...
 >
 > However, disregard. IMHO there is nothing wrong with "node server.js &" 
and I was just trying to figure out why this doesn't work with Ansible. I wasn't looking for a 
religious discussion.
 >

Neither me .. just pointing out common sense using Ansible and Unix 
services.

Regards
Racke

 > ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 18:54:35 UTC+2:
 >
 > On 12/10/2021 18:45, 'Neil Young' via Ansible Project wrote:
 > > ...even though it might not be the high level of "best practice" (in 
fact you can read a lot of this Racke comments, especially with Ansible) - and I'm surely aware 
of that - it is a legit shell command.
 > >
 >
 > Yes, but running a server through nohup is certainly bad practice. Nohup 
is rather provided to prevent long running processes to be disrupted.
 >
 > There is no really good way to control the server when it is running. 
How do you stop it for example? Restart it when it is crashed? Etc.
 >
 > And the shell called from Ansible doesn't have the same environment as 
when you login as regular user.
 >
 > Regards
 > Racke
 >
 >
 > >
 > > Neil Young schrieb am Dienstag, 12. Oktober 2021 um 18:43:12 UTC+2:
 > >
 > > Thanks for the helpful comment.
 > >
 > > ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 18:42:33 
UTC+2:
 > >
 > > On 12/10/2021 17:28, 'Neil Young' via Ansible Project wrote:
 > > > Hmm. I must be making again something fundamentally wrong :)
 > > >
 > >
 > > Yes, you are trying to use Ansible as glorified shell *and* ignore all 
the options to run a service properly (e.g. with systemd).
 > >
 > > Regards
 > > Racke
 > >
 > > > Trying to start a simple node server app into background
 > > >
 > > >
 > > >     - name: Start server (run as non-privileged user)
 > > >       tags: server
 > > >       shell: |
 > > >         nohup node server.js 2>&1 &
 > > >       args:
 > > >         chdir: my-server-dir
 > > >       become: yes
 > > >       become_user: "{{ non_root_user }}"
 > > >
 > > > This runs w/o problems. However, the service is not started...
 > > >
 > > > Running the same command from console works...
 > > >
 > > > It doesn't even run as "sudo" (if f I remove the "become" lines at 
the end, my entire script runs as sudo)
 > > >
 > > >
 > > >
 > > > --
 > > > 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/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com 
 
> 
 
>>


 
>
 


  1   2   3   4   5   6   7   8   >