Re: [ansible-project] KEY: VALUE iterations

2020-02-12 Thread Vladimir Botka
On Wed, 12 Feb 2020 19:52:31 -0800 (PST)
Anand Solomon  wrote:

> How will get the value of item.key and item.value to variable
> 
> sqlqry = "{{ item.key }}"
> sqlid = "{{ item.value }}"

Declare the vars in the scope of the task. For example

   - debug:
msg: "{{ sqlqry }}: {{ sqlid }}"
  vars:
sqlqry: "{{ item.key }}"
sqlid: "{{ item.value }}"
  loop: "{{ scripts|dict2items }}"

HTH,

-vlado

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200213052231.5ed71ce2%40gmail.com.


pgpnnzNlkBhSO.pgp
Description: OpenPGP digital signature


Re: [ansible-project] KEY: VALUE iterations

2020-02-12 Thread Anand Solomon
Basically I want to read sqlvar.yml, pass the "select username from 
dba_users;" to SQLID and "Script1" to SQLQRY  one by one.

On Wednesday, February 12, 2020 at 10:52:32 PM UTC-5, Anand Solomon wrote:
>
> You helped me Vlado. Thanks again. This works very well. 
>
> How will get the value of item.key and item.value to variable
>
> sqlqry = "{{ item.key }}"
> sqlid = "{{ item.value }}"
>
>
> On Wednesday, February 12, 2020 at 10:38:22 PM UTC-5, Vladimir Botka wrote:
>>
>> On Wed, 12 Feb 2020 18:02:20 -0800 (PST) 
>> Anand Solomon  wrote: 
>>
>> > What is the best way to loop the below KEY : VALUE ? 
>> > [...] 
>> >  sqlvar.yml 
>> >  Key: Value 
>> >  Script1: select username from dba_users; 
>> >  Script2: select file_name from dba_data_files; 
>> >  Script3: select name from v$profile; 
>> >  Script4: select username from dba_profile; 
>>
>> Try this 
>>
>> - include_vars: 
>> file: /home/ansible/sqlvar.yml 
>> name: scripts 
>> - debug: 
>> msg: "{{ item.key }}: {{ item.value }}" 
>>   loop: "{{ scripts|dict2items }}" 
>>
>> HTH, 
>>
>> -vlado 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fdf234ef-3362-4af9-9f8d-e65d2558bc19%40googlegroups.com.


Re: [ansible-project] KEY: VALUE iterations

2020-02-12 Thread Vladimir Botka
On Wed, 12 Feb 2020 18:02:20 -0800 (PST)
Anand Solomon  wrote:

> What is the best way to loop the below KEY : VALUE ?
> [...]
>  sqlvar.yml
>  Key: Value
>  Script1: select username from dba_users;
>  Script2: select file_name from dba_data_files;
>  Script3: select name from v$profile;
>  Script4: select username from dba_profile;

Try this

- include_vars:
file: /home/ansible/sqlvar.yml
name: scripts
- debug:
msg: "{{ item.key }}: {{ item.value }}"
  loop: "{{ scripts|dict2items }}"

HTH,

-vlado

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200213043800.23268a5d%40gmail.com.


pgpNbLMbpnhZq.pgp
Description: OpenPGP digital signature


[ansible-project] KEY: VALUE iterations

2020-02-12 Thread Anand Solomon
Hi,
What is the best way to loop the below KEY : VALUE ?


*main.yml*
 
 var_files:
 - /home/ansible/sqlvar.yml
 
 - name: Script 
 oracle_sql:
 sql: {{Value}}
 environment: "{{oracle_env}}"
 register: query_result
 connection: local
 
 - name: Runs statements 
 command: $ORACLE_HOME/sqlplus -s {{user}}/{{password}}@{{sname}} 
@/home/ansible/Playbooks/{{sname}}/sql/{{Key}}_revoke.sql
 environment: "{{oracle_env}}"
 register: sqloutput
 connection: local
 
 --
 sqlvar.yml
 
 Key: Value
 Script1: select username from dba_users;
 Script2: select file_name from dba_data_files;
 Script3: select name from v$profile;
 Script4: select username from dba_profile;

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/61eb0fae-6370-42ec-bfb4-841dfb244a6d%40googlegroups.com.


Re: [ansible-project] How can I search for an specific IP-Address on all of my Ansible-connected hosts

2020-02-12 Thread Vladimir Botka
On Wed, 12 Feb 2020 13:00:55 -0800 (PST)
Matthias Steffens  wrote:

> I'm looking for an method by which I can have a look on all of my 
> 'Ansible-Clients' for an specific IP-Address.

Try this

- hosts: all
  gather_facts: true
  tasks:
- debug:
var: ansible_all_ipv4_addresses

HTH,

-vlado

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200212234604.31b9703e%40gmail.com.


pgpsXzQxg2dxZ.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Playbook doesn't run completely stuck after "check if reboot required"

2020-02-12 Thread Jean-Yves LENHOF
Why not using the "reboot" module which is done for that instead of 
using shell module with some tricks ?


Regards,


JYL


Le 12/02/2020 à 19:30, Work-Hard a écrit :
*Playbook doesn't run completely stuck after "check if reboot 
required". Please assist!*

*
*
*
Play-Book*
---
- hosts: ubuntu
  become: true
  any_errors_fatal: true
  serial: 1
  max_fail_percentage: 0
  vars:
    ansible_user: ubuntu
  tasks:
    # do an "apt-get update", to ensure latest package lists
    - name: apt-get update
      apt:
        update-cache: yes
      changed_when: 0

    # get a list of packages that have updates
    - name: get list of pending upgrades
      command: apt-get --simulate dist-upgrade
      args:
        warn: false # don't warn us about apt having its own plugin
      register: apt_simulate
      changed_when: 0

    - name: Update cache
      apt:
        update-cache: yes
      changed_when: false

    - name: Fetch package list of updates
      command: apt list --upgradable
      register: aptlist
    - set_fact:
        updates: "{{ aptlist.stdout_lines | difference(['Listing...'])
| map('regex_replace', '^(.*?)/(.*)', '\\1') | list }}"

    - debug: var=updates

    # tell user about packages being updated
    - name: show pending updates
      debug:
        var: updates
      when: updates.0 is defined

    # running package ack each server update with a prompt
    - pause:
      when: updates.0 is defined

    # if a new kernel is incoming, remove old ones to avoid full /boot
    - name: apt-get autoremove
      command: apt-get -y autoremove
      args:
        warn: false
      when: '"Inst linux-image-" in apt_simulate.stdout'
      changed_when: 0

    # do the actual apt-get dist-upgrade
    - name: apt-get dist-upgrade
      apt:
        upgrade: dist # upgrade all packages to latest version
      register: upgrade_output

    # check if we need a reboot
    - name: check if reboot needed
      stat: path=/var/run/reboot-required
      register: file_reboot_required

    # "meta: end_play" aborts the rest of the tasks in the current 
«tasks:»

    # section, for the current desired server
    - meta: end_play
      when: not file_reboot_required.stat.exists

    # because of the above meta/when we at this point know that the 
current

    # host needs a reboot

    # prompt for manual input before doing the actual reboot
    - name: Confirm reboot of ubuntu
      pause:

    - name: reboot node
      shell: sleep 2 && shutdown -r now "Reboot triggered by ansible"
      async: 1
      poll: 0
      ignore_errors: true

    # poll ssh port until we get a tcp connect
    - name: wait for node to finish booting
      become: false
      local_action: wait_for host=ubuntu
          port=22
          state=started
          delay=5
          timeout=600

    # give sshd time to start fully
    - name: wait for ssh to start fully
      pause:
        seconds: 15

    # wait a few minutes between hosts, unless we're on the last
    - name: waiting between hosts
      pause:
        minutes: 10
      when: inventory_hostname != ansible_play_hosts[-1]

*Output*
PLAY [ubuntu] 



TASK [Gathering Facts] 
***

ok: [10.0.2.236]

TASK [apt-get update] 


ok: [10.0.2.236]

TASK [get list of pending upgrades] 
**

ok: [10.0.2.236]

TASK [Update cache] 
**

ok: [10.0.2.236]

TASK [Fetch package list of updates] 
*

changed: [10.0.2.236]

TASK [set_fact] 
**

ok: [10.0.2.236]

TASK [debug] 
*

ok: [10.0.2.236] => {
    "updates": []
}

TASK [show pending updates] 
**

skipping: [10.0.2.236]

TASK [pause] 
*

skipping: [10.0.2.236]

TASK [apt-get autoremove] 

[ansible-project] Re: Module nxos_user not recognizing fails saying role is invalid

2020-02-12 Thread 'Alex King' via Ansible Project
I had the same problem.  It seem like it is a shortcoming of the nxos_user 
module.  It seems like roles are checked against a hard-coded list of 
standard roles, and the module can't work with user defined roles at all.

Thanks,
Alex

On Saturday, February 9, 2019 at 6:39:56 AM UTC+13, Eliezer Rodriguez wrote:
>
>
> Hi everybody,
>
> I wrote this playbook to create a new role in Nexus OS and then create a 
> new user to use that role.
> The role gets created but when it's time for the second task to create the 
> role it fails with a non-existent role error.
>
> ---
> - name: Playing with Nexus OS module
>   hosts: all
>   gather_facts: false
>   vars:
> ansible_connection: network_cli
> ansible_network_os: nxos
> tasks:
>- name: create a new role
>  nxos_config:
> backup: yes
> lines:
>  - rule 10 permit command show policy-map interface input
>  - rule 20 permit command show vrf *
>  - rule 30 permit command show run vrf *
> parents: role name aegisro
>
>- name: create a new user
>  nxos_user:
> name: aegis_new
> configured_password: 
> state: present
> role: aegisro
>   - name: save config
>  nxos_config:
>   save: yes
> ...
>
>
> I get this when running the playbook:
>
> $ ansible-playbook -i ../hosts.ivan --limit bs1.lab aegis-user.yml
>
> PLAY [Playing with Nexus OS module] 
> *
>
> TASK [create a new role] 
> 
> ok: [bs1.lab]
>
> TASK [create a new user] 
> 
> fatal: [bs1.lab]: FAILED! => {"changed": false, "msg": "invalid role 
> specified"}
> to retry, use: --limit 
> @/home/elie/ansible-secbu/etc/ansible/playbooks/aegis-user.retry
>
> PLAY RECAP 
> **
> bs1.lab: ok=1changed=0unreachable=0failed=1
>
> Any ideas on how to make the second task aware of the role that just got 
> created ?
>
> Eliezer R.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/435920ed-0ee8-4529-93a2-d86ab73fb58a%40googlegroups.com.


[ansible-project] How can I search for an specific IP-Address on all of my Ansible-connected hosts

2020-02-12 Thread Matthias Steffens
Hi everyone! 

I'm looking for an method by which I can have a look on all of my 
'Ansible-Clients' for an specific IP-Address.

I thought about grepping for this in my root-directory (/) but is this 
possible or are there any other better methods?

Hope you can help me to find a good solution.

Best regards,

Matthias

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/79b1281b-4c82-4cc2-93ea-1695f952df07%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-12 Thread Anand Solomon
Thank you so much Vlado.

It works fine. 

On Wednesday, February 12, 2020 at 1:49:13 PM UTC-5, Vladimir Botka wrote:
>
> On Wed, 12 Feb 2020 08:51:12 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > - name: Generate Revoke Statement 
> >   local_action: 
> > copy dest= /home/ansible/query.sql 
> > content= {% for line in query_result.msg|flatten %} {{ line }} 
> {% 
> > endfor %} 
> >   connection: local 
> > 
> > I get -->  localhost]: FAILED! => {"changed": false, "msg": "dest is 
> > required"} 
>
> Very probably the problem is the formatting and indentation of the 
> "shorthand 
> syntax". Try this 
>
> - name: Generate Revoke Statement 
>   copy: 
> dest: /home/ansible/query.sql 
> content: | 
>   {% for line in query_result.msg|flatten %} {{ line }} {% endfor 
> %} 
>   delegate_to: localhost 
>   connection: local 
>
> HTH, 
>
> -vlado 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/13321f95-962b-42d3-bb87-eeecb88d3af8%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-12 Thread Vladimir Botka
On Wed, 12 Feb 2020 08:51:12 -0800 (PST)
Anand Solomon  wrote:

> - name: Generate Revoke Statement
>   local_action:
> copy dest= /home/ansible/query.sql
> content= {% for line in query_result.msg|flatten %} {{ line }} {% 
> endfor %}
>   connection: local
> 
> I get -->  localhost]: FAILED! => {"changed": false, "msg": "dest is 
> required"}

Very probably the problem is the formatting and indentation of the "shorthand
syntax". Try this

- name: Generate Revoke Statement
  copy:
dest: /home/ansible/query.sql
content: |
  {% for line in query_result.msg|flatten %} {{ line }} {% endfor %}
  delegate_to: localhost
  connection: local

HTH,

-vlado

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200212194850.420f63c1%40gmail.com.


pgpctpM_sOwto.pgp
Description: OpenPGP digital signature


[ansible-project] Playbook doesn't run completely stuck after "check if reboot required"

2020-02-12 Thread Work-Hard
*Playbook doesn't run completely stuck after "check if reboot required". 
Please assist!*

*Play-Book*
---
- hosts: ubuntu
  become: true
  any_errors_fatal: true
  serial: 1
  max_fail_percentage: 0
  vars:
ansible_user: ubuntu
  tasks:
# do an "apt-get update", to ensure latest package lists
- name: apt-get update
  apt:
update-cache: yes
  changed_when: 0

# get a list of packages that have updates
- name: get list of pending upgrades
  command: apt-get --simulate dist-upgrade
  args:
warn: false # don't warn us about apt having its own plugin
  register: apt_simulate
  changed_when: 0

- name: Update cache
  apt:
update-cache: yes
  changed_when: false

- name: Fetch package list of updates
  command: apt list --upgradable
  register: aptlist
- set_fact:
updates: "{{ aptlist.stdout_lines | difference(['Listing...'])
| map('regex_replace', '^(.*?)/(.*)', '\\1') | list }}"

- debug: var=updates

# tell user about packages being updated
- name: show pending updates
  debug:
var: updates
  when: updates.0 is defined

# running package ack each server update with a prompt
- pause:
  when: updates.0 is defined

# if a new kernel is incoming, remove old ones to avoid full /boot
- name: apt-get autoremove
  command: apt-get -y autoremove
  args:
warn: false
  when: '"Inst linux-image-" in apt_simulate.stdout'
  changed_when: 0

# do the actual apt-get dist-upgrade
- name: apt-get dist-upgrade
  apt:
upgrade: dist # upgrade all packages to latest version
  register: upgrade_output

# check if we need a reboot
- name: check if reboot needed
  stat: path=/var/run/reboot-required
  register: file_reboot_required

# "meta: end_play" aborts the rest of the tasks in the current «tasks:»
# section, for the current desired server
- meta: end_play
  when: not file_reboot_required.stat.exists

# because of the above meta/when we at this point know that the current
# host needs a reboot

# prompt for manual input before doing the actual reboot
- name: Confirm reboot of ubuntu
  pause:

- name: reboot node
  shell: sleep 2 && shutdown -r now "Reboot triggered by ansible"
  async: 1
  poll: 0
  ignore_errors: true

# poll ssh port until we get a tcp connect
- name: wait for node to finish booting
  become: false
  local_action: wait_for host=ubuntu
  port=22
  state=started
  delay=5
  timeout=600

# give sshd time to start fully
- name: wait for ssh to start fully
  pause:
seconds: 15

# wait a few minutes between hosts, unless we're on the last
- name: waiting between hosts
  pause:
minutes: 10
  when: inventory_hostname != ansible_play_hosts[-1]

*Output*
PLAY [ubuntu] 


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

TASK [apt-get update] 

ok: [10.0.2.236]

TASK [get list of pending upgrades] 
**
ok: [10.0.2.236]

TASK [Update cache] 
**
ok: [10.0.2.236]

TASK [Fetch package list of updates] 
*
changed: [10.0.2.236]

TASK [set_fact] 
**
ok: [10.0.2.236]

TASK [debug] 
*
ok: [10.0.2.236] => {
"updates": []
}

TASK [show pending updates] 
**
skipping: [10.0.2.236]

TASK [pause] 
*
skipping: [10.0.2.236]

TASK [apt-get autoremove] 

skipping: [10.0.2.236]

TASK [apt-get dist-upgrade] 

Re: [ansible-project] Ansible Vault online tool for encrypt/decrypt

2020-02-12 Thread Amarnatha Reddy
Nice one, thanks for sharing and improving

On Wed, 12 Feb 2020, 2:47 pm Stefan Hornburg (Racke), 
wrote:

> On 2/12/20 5:59 AM, Mamed Shahmaliyev wrote:
> > Dear Ansible users,
> >
> > recently i have been looking for some online service for on-hand ansible
> vault encrypt decrypt service and could not
> > find anything. So i decided to write my own web interface:
> https://ansible-vault-tool.com/
> >
> > Here you can decrypt or encrypt anything and no data is stored or
> logged. I hope it will be useful for ansible daily users.
>
> This is only useful to me in case you publish it under an Open Source
> license :-)
>
> 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  ansible-project+unsubscr...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/503a1a12-34ab-4834-bb97-6a122d959fb1%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/503a1a12-34ab-4834-bb97-6a122d959fb1%40googlegroups.com?utm_medium=email_source=footer
> >.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0f5fcff1-cf45-b194-58c9-9f7b7deb039a%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/CA%2BdKxYxcaVw3ZZ5_JbT9u8pnLu_WQxpdK04%2BvxwjB%3DynQxms%3DA%40mail.gmail.com.


Re: [ansible-project] parted - azure managed disks - unrecognized disk label

2020-02-12 Thread Hugo Gonzalez



On 2/11/20 6:23 AM, 'deewon' via Ansible Project wrote:

I got to the bottom of this eventually :)

The task was running on the controller which didn't have a /dev/sdc 
device :)



Whoa! careful there! :)

Hugo G.

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ab9769be-4b62-cc0b-992d-f9826980a082%40redhat.com.


Re: [ansible-project] How to get clean output ?

2020-02-12 Thread Anand Solomon
Thanks Vlado,
We don't want to maintain separate files.

Here is my 
- name: Generate Revoke Statement
  local_action:
copy dest= /home/ansible/query.sql
content= {% for line in query_result.msg|flatten %} {{ line }} {% 
endfor %}
  connection: local

I get -->  localhost]: FAILED! => {"changed": false, "msg": "dest is 
required"}

Is that something I am missing ?

On Tuesday, February 11, 2020 at 6:06:42 PM UTC-5, Vladimir Botka wrote:
>
> On Tue, 11 Feb 2020 14:59:04 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > Instead of maintaining another template file. Can I embed the content in 
> > the playbook itself ? 
>
> Sure you can. Put it into the "content". For example 
>
> - local_action: 
> copy dest=/scratch/tmp/revoke.sql 
> content="{% for line in query_result.msg|flatten %}{{ line }}{% 
> endfor %}" 
>
> But, why to get rid of the flexibility and modularity? 
>
> HTH, 
>
> -vlado 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2cf96e8b-80a5-43a7-8bcd-7c157854474e%40googlegroups.com.


Re: [ansible-project] Ansible expect module with Oracle SBC

2020-02-12 Thread Kai Stian Olstad
On Wed, Feb 12, 2020 at 02:39:08AM -0800, Gerhard Van Der Wath wrote:
> Hi Kai.
> 
> Thank you for taking the time to get back to me.
> 
> It is highly appreciated, and apologies for the formatting of my request, I 
> will correct this in future.
> 
> I am in uncharted waters here as I am new to Ansible, and coding in 
> general, but I have made some changes to the code:
> 
> - name: Check CPU
>   hosts: 10.18.170.200
>   connection: local
>   gather_facts: yes
> 
> 
>   tasks:
> 
>   - name: Get CPU load
> expect:
>   command: ssh admin@10.18.170.200
>   responses:
>(?i)password: "###"
> 
>   - name: basic command
> expect:
>   command: show platform cpu-load summary
>   responses:
>(?i)#: 

You can't split it like that.
Two tasks in Ansible have nothing do to with each other.

The expect command will always be the ssh and in the response section it will
contain the command for the interface.

So it will be something like this.

  - name: Get CPU load
expect:
  command: ssh admin@10.18.170.200
  responses:
(?i)password: "###"
#:
  - show platform cpu-load summary
  - exit

When expect sees "password" it will type "###" and hit enter.
When it sees "#" it will write the first element in the list(show...) of the
second time expect sees "#" it will write "exit" and hit enter.
(I presume exit terminate the connection, if not change it to the correct 
command)

-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200212161532.gfkaw6ozvfjtkeb7%40olstad.com.


Re: [ansible-project] Automating LDAP integration of artifactory using ansible

2020-02-12 Thread Dick Visser
Hi

“Automation of ldap integration” can mean a thousand things.


Could you please tell clearly:


- What you are trying to achieve.

- How you are doing this.

- What problems you encounter.

- Which command did you run, and what output did you get from that (copied
as text, not as images/attachments/screenshots)

- What the relevant tasks/playbooks/code/variables look like




On Tue, 11 Feb 2020 at 11:13, Vishal Bobade 
wrote:

> Hi,
>
> could some one help me in understanding if the below yaml code can be used
> in ansible-playbook to achieve the automation of LDAP integration.
>
> security:   #Security configuration (LDAP, SAML, Password Policy, ...)
>   ldapSettings:   #LDAP server(s) settings
> ldap1:   #The unique ID of the LDAP setting
>   emailAttribute: email1   #An attribute that can be used to map a
> user's email to a user created automatically by Artifactory
>   ldapPoisoningProtection: true   #When set to true (recommended),
> Artifactory will protect against LDAP poisoning by filtering out users
> exposed to vulnerability
>   ldapUrl: ldap://myserver:myport/dc=sampledomain,dc=com   #Location
> of the LDAP server in the following format:
> ldap://myserver:myport/dc=sampledomain,dc=com. The URL should include the
> base DN used to search for and/or authenticate users
>   search:
> managerDn: manager1   #The full DN of a user with permissions
> that allow querying the LDAP server. When working with LDAP Groups, the
> user should have permissions for any extra group attributes such as memberOf
> managerPassword: managerpass1   #The password of the user binding
> to the LDAP server when using "search" authentication
> searchBase: searchbase1   #The Context name in which to search
> relative to the base DN in the LDAP URL. Multiple search bases may be
> specified separated by a pipe ( | ). This is parameter is optional
> searchFilter: searchfilter1   #A filter expression used to search
> for the user DN that is used in LDAP authentication. Possible examples are:
> uid={0}) - this would search for a username match on the uid attribute.
> Authentication using LDAP is performed from the DN found if successful
> searchSubTree: true   #When set, enables deep search through the
> sub-tree of the LDAP URL + Search Base
>   userDnPattern: userppatt1  #A DN pattern used to log users directly
> in to the LDAP database. This pattern is used to create a DN string for
> "direct" user authentication, and is relative to the base DN in the LDAP
> URL. For example: uid={0},ou=People
>   allowUserToAccessProfile: false   #When set, users created after
> logging in using LDAP will be able to access their profile page in
> Artifactory
>   autoCreateUser: true   #When set, Artifactory will automatically
> create new users for those who have logged in using LDAP, and assign them
> to the default groups
>   enabled: true   #When set, these settings are enabled
> Samp
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f9d8e4a5-cb48-4351-9154-ad9329ab7dd0%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/CAL8fbwN4H0CN%2B4DofT5CLFLjnAJTh07Wy0gzVZqFsmOYswsz2g%40mail.gmail.com.


Re: [ansible-project] Illegal info request from server"

2020-02-12 Thread Dick Visser
You forgot to post your playbook

On Mon, 10 Feb 2020 at 14:04, Mr. sHamEem/ IT Club Hub 
wrote:

> Hi there ,
>
> i am getting following issue to connect with my Cisco CISCO2951/K9
> (revision 1.1)  router any one please help me !
>
> ===
>
>
>
> *fatal: [router1]: FAILED! => {"changed": false, "msg": "Illegal
> info request from server"}*
> ==
>
> root@firstansible:/etc/ansible#
> ## db-[99:101]-node.example.com
> [IOS]
> router1 ansible_ssh_user=bdcom ansible_host=210.4.64.100
> ansible_network_os=ios ansible_connection=network_cli
> router2 ansible_host=10.10.1.254
>
> root@firstansible:/etc/ansible# ansible-playbook aminul1.yml -vvv
> ansible-playbook 2.9.4
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = [u'/root/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/dist-packages/ansible
>   executable location = /usr/bin/ansible-playbook
>   python version = 2.7.12 (default, Oct  8 2019, 14:14:10) [GCC 5.4.0
> 20160609]
> Using /etc/ansible/ansible.cfg as config file
> host_list declined parsing /etc/ansible/hosts as it did not pass its
> verify_file() method
> script declined parsing /etc/ansible/hosts as it did not pass its
> verify_file() method
> auto declined parsing /etc/ansible/hosts as it did not pass its
> verify_file() method
> Parsed /etc/ansible/hosts inventory source with ini plugin
>
> PLAYBOOK: aminul1.yml
> **
> 1 plays in aminul1.yml
>
> PLAY [router1]
> *
> META: ran handlers
>
> TASK [change hostname BDCOM-TEST]
> **
> task path: /etc/ansible/aminul1.yml:8
>
>
>
> *fatal: [router1]: FAILED! => {"changed": false, "msg": "Illegal
> info request from server"}*
>
> PLAY RECAP
> *
> router1: ok=0changed=0unreachable=0
>  failed=1skipped=0rescued=0ignored=0
>
> root@firstansible:/etc/ansible# cat /etc/issue
> Ubuntu 16.04.6 LTS \n \l
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAEV3LdpKBgJCgyXEUBx-M8gFJGVAT2x6xP9EcNehS3GZbaw7VA%40mail.gmail.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/CAL8fbwMc%2BneAYPOR5EXjz_qaJ57KJYM3Oy_nT2V-t5XaCsWLmQ%40mail.gmail.com.


Re: [ansible-project] use rules from different git repos/locations

2020-02-12 Thread sanctc
Hi,
I used the below option after copying the rules from git and it worked for 
me.

*- hosts: all
  roles:
- server
- /path/to/my/roles/common
- /path/to/my/client_roles/client*

*My intention was to use roles from different locations in a playbook*

On Wednesday, February 12, 2020 at 5:49:08 PM UTC+5:30, Dick Visser wrote:

Hi
>
> What do you mean by “a single ansible”?
>
> In any case where a role came from (git, in your case) is not relevant, 
> just make sure they are available locally. 
> The roles docs are reasonably clear:
>
>
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html
>
>
>
> On Wed, 12 Feb 2020 at 06:57, sanctc > 
> wrote:
>
>> Hi Folks,
>> Can I use roles from several different git repos/locations to single 
>> ansible?
>> e.g. 
>> ---
>> - hosts: myhost
>>   roles:
>> - role1: '/path/to/my/roles/common'
>> - role2: '/usr1/to/my/roles/client'
>> - role3: '/usrpath/to/my/roles/server'
>>
>> What would be the best way to use roles from different locations?
>>
>> Thanks,
>> Santosh
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/3031f4c9-ea37-4032-b971-4668b5e55e7c%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/e6bd0c21-0b0c-434b-af4f-0709e76fdbb5%40googlegroups.com.


Re: [ansible-project] use rules from different git repos/locations

2020-02-12 Thread Dick Visser
Hi

What do you mean by “a single ansible”?

In any case where a role came from (git, in your case) is not relevant,
just make sure they are available locally.
The roles docs are reasonably clear:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html



On Wed, 12 Feb 2020 at 06:57, sanctc  wrote:

> Hi Folks,
> Can I use roles from several different git repos/locations to single
> ansible?
> e.g.
> ---
> - hosts: myhost
>   roles:
> - role1: '/path/to/my/roles/common'
> - role2: '/usr1/to/my/roles/client'
> - role3: '/usrpath/to/my/roles/server'
>
> What would be the best way to use roles from different locations?
>
> Thanks,
> Santosh
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3031f4c9-ea37-4032-b971-4668b5e55e7c%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/CAL8fbwM-DwXLc9KcAr%3DPawCB%2BE6fgpzkQ0zgBDYfpHt5E_eSnQ%40mail.gmail.com.


Re: [ansible-project] Ansible expect module with Oracle SBC

2020-02-12 Thread Gerhard Van Der Wath
Hi Kai.

Thank you for taking the time to get back to me.

It is highly appreciated, and apologies for the formatting of my request, I 
will correct this in future.

I am in uncharted waters here as I am new to Ansible, and coding in 
general, but I have made some changes to the code:

- name: Check CPU
  hosts: 10.18.170.200
  connection: local
  gather_facts: yes


  tasks:

  - name: Get CPU load
expect:
  command: ssh admin@10.18.170.200
  responses:
   (?i)password: "###"

  - name: basic command
expect:
  command: show platform cpu-load summary
  responses:
   (?i)#: 

I am getting the below


fatal: [10.18.170.200]: FAILED! => {
"changed": false, 
"invocation": {
"module_args": {
"chdir": null, 
"command": "show platform cpu-load", 
"creates": null, 
"echo": false, 
"removes": null, 
"responses": {
"(?i)#": null
}, 
"timeout": 30
}
}, 
"msg": "The command was not found or was not executable: show."
}



On Tuesday, 11 February 2020 13:33:54 UTC+2, Kai Stian Olstad wrote:
>
> On Wed, Feb 05, 2020 at 01:05:57AM -0800, Gerhard Van Der Wath wrote: 
> > Hi. 
>
> Hi, if you had posted a plain text mail instead of HTML you would have 
> gotten a 
> replay a lot sooner. 
> As you can see bellow you formatting is hard to read. 
>
>
> > tasks: 
> > 
> > - name: Get CPU load 
> > expect: 
> > command: ssh admin@# 
> > responses: 
> > 'password: ': 
> > - ### 
> > '#': 
> > - sh platform cpu-load 
> > 
> > 
> > 
> > Error: 
> > 
> > fatal: [##]: FAILED! => { "changed": false, "invocation": { 
> > "module_args": { "chdir": null, "command": "ssh admin@##", 
> "creates": 
> > null, "echo": false, "removes": null, "responses": { "#": [ "sh platform 
> > cpu-load" ], "password: ": [ "##" ] }, "timeout": 30 } }, "msg": "No 
> > remaining responses for '#', output was ' sh platform 
> > cpu-load\r\nTimestamp: 10:49:41 Wed 2020-02-05\r\nTotal load : 4%\r\nCPU 
> 00 
> > load : 5%\r\nCPU 01 load : 3%\r\nCPU 02 load : 5%\r\nCPU 03 load : 
> > 5%\r\nVOXBDLHA1#'" } 
>
> As the msg says expect has gotten a prompt # put have no more command to 
> give. 
> Remember that expect is you substitute for a human typing inn commands, so 
> you 
> need to provide all command from start, ssh in you case, to the exit of 
> the ssh command. 
>
> So you need to add an element to the item "#" in your responses to exit 
> the command. 
>
> -- 
> Kai Stian Olstad 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/13bb319c-590e-4fd3-8232-f57104bc6e1e%40googlegroups.com.


Re: [ansible-project] How to use group_vars in ansible templates

2020-02-12 Thread Bala Mutyam
Yes. I managed get the config as below.

{% for host in groups['rabbitmq'] %}
cluster_formation.classic_config.nodes.{{ loop.index }} = rabbit@{{ 
hostvars[host]['ansible_hostname'] }}
{% endfor %}


On Monday, February 10, 2020 at 1:01:58 PM UTC, Stefan Hornburg (Racke) 
wrote:
>
> On 2/10/20 12:21 PM, Bala Mutyam wrote: 
> > Hi there, 
> > 
> > Could someone help me with how to template this config like below 
> please? 
> > 
> > cluster_formation.classic_config.nodes.1 = rabbit@rabbitmq-1 
> > cluster_formation.classic_config.nodes.2 = rabbit@rabbitmq-2 
> > cluster_formation.classic_config.nodes.3 = rabbit@rabbitmq-3 
> > 
> > 
> > I would like to change nodes.1,2,3 & rabbit@anisble_hostname 
>
> So you want to loop over a host group to get this configuration above? 
>
> 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...@googlegroups.com   ansible-project+unsubscr...@googlegroups.com >. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/f4b3c9f2-a4b3-4052-86a1-06e6dde25054%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/f4b3c9f2-a4b3-4052-86a1-06e6dde25054%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming. 
> Debian and Sympa administration. Provisioning with Ansible. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e00d8295-9781-4576-9cc2-0f0ea36ed1d6%40googlegroups.com.


Re: [ansible-project] Ansible Vault online tool for encrypt/decrypt

2020-02-12 Thread Stefan Hornburg (Racke)
On 2/12/20 5:59 AM, Mamed Shahmaliyev wrote:
> Dear Ansible users,
> 
> recently i have been looking for some online service for on-hand ansible 
> vault encrypt decrypt service and could not
> find anything. So i decided to write my own web interface: 
> https://ansible-vault-tool.com/
> 
> Here you can decrypt or encrypt anything and no data is stored or logged. I 
> hope it will be useful for ansible daily users.

This is only useful to me in case you publish it under an Open Source license 
:-)

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/503a1a12-34ab-4834-bb97-6a122d959fb1%40googlegroups.com
> .


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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0f5fcff1-cf45-b194-58c9-9f7b7deb039a%40linuxia.de.


signature.asc
Description: OpenPGP digital signature