[ansible-project] Re: ansible with elastic search with Jinja2 Template

2018-04-13 Thread Bishwajit Samanta
Thanks Larry for such great help.. i hope this solves my problem. !! :) 

On Saturday, April 14, 2018 at 10:25:50 AM UTC+5:30, Larry Smith wrote:
>
> You can use:
> node.name: {{ansible_hostname}}
>
> Which will use the hostname defined on the remote host.
>
> Or you can use:
> node.name:{{inventory_hostname}}
>
> Which will use the inventory hostname defined in your Ansible inventory.
>
> For reference:
>
> https://github.com/mrlesmithjr/ansible-elasticsearch/blob/master/defaults/main.yml#L74
>
> Hope this helps.
>
> On Friday, April 13, 2018 at 1:56:57 PM UTC-4, Bishwajit Samanta wrote:
>>
>> Can anyone help me in my problem please ? 
>>
>>
>> On Friday, April 13, 2018 at 8:21:31 PM UTC+5:30, Bishwajit Samanta wrote:
>>>
>>>
>>>
>>> Hi, my question is :: 
>>> 
>>>
>>> My ansible script will be running for multiple systems. But in 
>>> elasticsearch.jinja2 how can i change the value of node.name for 
>>> different systems.
>>>
>>> Jinja 2 Code::-
>>> ---
>>>
>>> # -- Cluster 
>>> ---
>>> #
>>> # Use a descriptive name for your cluster:
>>> #
>>>  cluster.name: {{ my_defined_cluster_name }}
>>> #
>>> #  Node 
>>> 
>>> #
>>> # Use a descriptive name for the node:
>>> #
>>>  node.name: {{ my_defined_node_name }}
>>> #
>>> # Add custom attributes to the node:
>>> #
>>> # node.rack: r1
>>>
>>> If i am running this jinja2 file, across all the systems the value of 
>>> node.name will be same. But i dont want this, i want to put some other 
>>> values when it runs to other systems. 
>>>
>>> what modification i can do in Jinja2 file , can anyone help me ??
>>>
>>> My ansible playbook looks like this::
>>>
>>>
>>> ---
>>>
>>> ## Task Related to Configuration of Elastic Search :: 
>>>
>>> - name: Copy Configuration file for Elastic Search 
>>>   template:
>>> src: elasticsearch.jinja2
>>> dest: /etc/elasticsearch/elasticsearch.yml
>>> mode: 0750
>>> owner: root
>>> group: elasticsearch
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f9ea6dd9-fe2a-4cb3-a6a0-c188bed218c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Variables with quotes

2018-04-13 Thread Larry Smith
Try to use the Ansible rabbitmq_user module as this will be much easier to 
accomplish your needs.

http://docs.ansible.com/ansible/latest/modules/rabbitmq_user_module.html

On Friday, April 13, 2018 at 9:48:15 AM UTC-4, Shaun Lim wrote:
>
> Hi all,
>
> I'm new to Ansible and am trying to use some variables with quotes. The 
> command I'm trying to run is as follows:
> rabbitmqctl set_permissions -p /vhost username ".*" ".*" ".*"
>
>
>
> To do this, I'm trying to use the command module. If I include the command 
> exactly as above, the command runs successfully but I'm trying to make this 
> reusable so I've changed a few of those into variables instead. My task 
> currently looks like this:
> - name: Set user permissions on RabbitMQ
>   become: yes
>   command: rabbitmqctl set_permissions -p /"{{ rabbitVhost }}" "{{ 
> rabbitUser }}" "{{ rabbitAcl }}"
>
>
> I can't seem to get this to work. I've tried sending the parameters like 
> this:
> ansible-playbook rabbit.yml 
> --extra-vars='{"rabbitUser":"shaun","rabbitSecret":"P@ssw0rd","rabbitVhost":"sensu","rabbitAcl":"\\\".*\\\"
>  
> \\\".*\\\" \\\".*\\\""}'
>
>
> The error I get is as below and it looks like the parameters are being set 
> correctly:
> fatal: [localhost]: FAILED! => {
> "changed": true,
> "cmd": [
> "rabbitmqctl",
> "set_permissions",
> "-p",
> "/sensu",
> "shaun",
> "\".*\" \".*\" \".*\""
> ],
> "delta": "0:00:00.691783",
> "end": "2018-04-13 23:37:49.505521",
> "invocation": {
> "module_args": {
> "_raw_params": "rabbitmqctl set_permissions -p /\"sensu\" 
> \"shaun\" \"\\\".*\\\" \\\".*\\\" \\\".*\\\"\"",
> "_uses_shell": false,
> "chdir": null,
> "creates": null,
> "executable": null,
> "removes": null,
> "stdin": null,
> "warn": true
> }
> },
> "msg": "non-zero return code",
> "rc": 64,
> "start": "2018-04-13 23:37:48.813738",
> "stderr": "Error: operation set_permissions used with invalid 
> parameter: [\"shaun\",\n   
> \"\\\".*\\\" \\\".*\\\" \\\".*\\\"\"]",
> "stderr_lines": [
> "Error: operation set_permissions used with invalid parameter: 
> [\"shaun\",",
> "   
> \"\\\".*\\\" \\\".*\\\" \\\".*\\\"\"]"
> ],
>
> Any help would be appreciated.
>
> Thanks.
>
> Regards,
> Shaun
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c35951ef-6d2c-4026-874a-393d29e45811%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: ansible with elastic search with Jinja2 Template

2018-04-13 Thread Larry Smith
You can use:
node.name: {{ansible_hostname}}

Which will use the hostname defined on the remote host.

Or you can use:
node.name:{{inventory_hostname}}

Which will use the inventory hostname defined in your Ansible inventory.

For reference:
https://github.com/mrlesmithjr/ansible-elasticsearch/blob/master/defaults/main.yml#L74

Hope this helps.

On Friday, April 13, 2018 at 1:56:57 PM UTC-4, Bishwajit Samanta wrote:
>
> Can anyone help me in my problem please ? 
>
>
> On Friday, April 13, 2018 at 8:21:31 PM UTC+5:30, Bishwajit Samanta wrote:
>>
>>
>>
>> Hi, my question is :: 
>> 
>>
>> My ansible script will be running for multiple systems. But in 
>> elasticsearch.jinja2 how can i change the value of node.name for 
>> different systems.
>>
>> Jinja 2 Code::-
>> ---
>>
>> # -- Cluster 
>> ---
>> #
>> # Use a descriptive name for your cluster:
>> #
>>  cluster.name: {{ my_defined_cluster_name }}
>> #
>> #  Node 
>> 
>> #
>> # Use a descriptive name for the node:
>> #
>>  node.name: {{ my_defined_node_name }}
>> #
>> # Add custom attributes to the node:
>> #
>> # node.rack: r1
>>
>> If i am running this jinja2 file, across all the systems the value of 
>> node.name will be same. But i dont want this, i want to put some other 
>> values when it runs to other systems. 
>>
>> what modification i can do in Jinja2 file , can anyone help me ??
>>
>> My ansible playbook looks like this::
>>
>>
>> ---
>>
>> ## Task Related to Configuration of Elastic Search :: 
>>
>> - name: Copy Configuration file for Elastic Search 
>>   template:
>> src: elasticsearch.jinja2
>> dest: /etc/elasticsearch/elasticsearch.yml
>> mode: 0750
>> owner: root
>> group: elasticsearch
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9ff9f66e-bcad-48f4-a6c0-e705a2a7853b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to sort ansible output

2018-04-13 Thread Brian Coca
ansible -m script -a 'free.sh' |sort?

you can also use --tree to save a file with the output of each server

or you can just write your own callback to handle the output.




-- 
--
Brian Coca

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


[ansible-project] include not working

2018-04-13 Thread Tcpip
Hi all

I have the following playbook 
!
---


   
- hosts: lab
  gather_facts: true
  connection: local
  vars:
creds:
  host: "{{ ansible_host }}"
  username: cisco
  password: cisco
 
  tasks:
- name: ios_facts
  ios_facts:
 provider: "{{ creds }}"
  register: iosfacts
 
- name: interface description
  ios_config:
provider: "{{ creds }}"
lines:
  - description test interface
parents: "interface {{ item.key }}"
  with_dict: "{{ iosfacts.ansible_facts.ansible_net_interfaces }}"
  when: item.value.bandwidth >= 100
 
- name: new task
  include: 2.yml
  with_dict: "{{ iosfacts.ansible_facts.ansible_net_interfaces }}"
  when: item.value.bandwidth <= 100

!!
And I get this error

"reason": "no action detected in task. This often indicates a 
misspelled module name, or incorrect module path.\n\nThe error appears to 
have been in '/home/playbooks/varios/2.yml': line 2, column 3, but may\nbe 
elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n---\n- hosts: lab\n  ^ here\n\n\nThe error 
appears to have been in '/home/playbooks/varios/2.yml': line 2, column 3, 
but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n---\n- hosts: lab\n  ^ 
here\n"

If I execute the playbook 2.yml in stand alone it works, if I add it to my 
other playbook i get errors.

Any ideas???

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a6e77380-cf49-472d-932a-228b2def9fe6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Getting two results with custom callbacks

2018-04-13 Thread tommcf64
Here is my my playbook.  I am also running ansible version 2.4.2.0
---
- hosts: all
  tasks:
- name: Run setup
  setup:
#  register: variables




On Friday, April 13, 2018 at 11:39:58 AM UTC-4, tommcf64 wrote:
>
> Hi,
>   I am attempting to use the Ansible API to run and playbook and insert 
> the facts into a mongodb database but I am getting two documents for each 
> machine.  I am a newbie and unfamiliar with the API.  Can anyone shed my 
> insight into why my code creates two outputs, I would greatly appreciate 
> the help.
>
> Here is the code:
> #!/usr/bin/env python
>
> import json
> import shutil
> from collections import namedtuple
> from ansible.parsing.dataloader import DataLoader
> from ansible.vars.manager import VariableManager
> from ansible.inventory.manager import InventoryManager
> from ansible.executor.playbook_executor import PlaybookExecutor
> from ansible.playbook.play import Play
> from ansible.executor.task_queue_manager import TaskQueueManager
> from ansible.plugins.callback import CallbackBase
> import ansible.constants as C
> import pymongo
>
> connection = pymongo.MongoClient("mongodb://:27017")
> db = connection.infrastructure
> servers = db.servers
> one_server = dict()
>
> class ResultCallback(CallbackBase):
> """A sample callback plugin used for performing an action as results 
> come in
>
> If you want to collect all results into a single object for processing 
> at
> the end of the execution, look into utilizing the ``json`` callback 
> plugin
> or writing your own custom callback plugin
> """
> def v2_runner_on_ok(self, result, **kwargs):
> """Print a json representation of the result
>
> This method could store the result in an instance attribute for 
> retrieval later
> """
> host = result._host
> #one_server = ((json.dumps({host.name: result._result})))
> one_server = ({host.name: result._result})
> #print(one_server)
> servers.insert(one_server,check_keys=False)
>
> Options = namedtuple('Options', ['connection', 'module_path', 'forks', 
> 'become', 'become_method', 'become_user', 'check', 'diff'])
> # initialize needed objects
> loader = DataLoader()
> options = Options(connection='local', module_path=['/path/to/mymodules'], 
> forks=100, become=None, become_method=None, become_user=None, check=False,
>   diff=False)
> passwords = dict(vault_pass='secret')
>
> # Instantiate our ResultCallback for handling results as they come in
> results_callback = ResultCallback()
>
> # create inventory and pass to var manager
> # use path to host config file as source or hosts in a comma separated 
> string
> inventory = InventoryManager(loader=loader, 
> sources='/etc/ansible/single/playbooks/hosts')
> variable_manager = VariableManager(loader=loader, inventory=inventory)
>
> Options = namedtuple('Options',
>  ['connection',
>   'remote_user',
>   'ask_sudo_pass',
>   'verbosity',
>   'ack_pass',
>   'module_path',
>   'forks',
>   'become',
>   'become_method',
>   'become_user',
>   'check',
>   'listhosts',
>   'listtasks',
>   'listtags',
>   'syntax',
>   'sudo_user',
>   'sudo',
>   'diff'])
> options = Options(connection='smart',
>remote_user=None,
>ack_pass=None,
>sudo_user=None,
>forks=5,
>sudo=None,
>ask_sudo_pass=False,
>verbosity=5,
>module_path=None,
>become=None,
>become_method=None,
>become_user=None,
>check=False,
>diff=False,
>listhosts=None,
>listtasks=None,
>listtags=None,
>syntax=None)
>
> pbe = 
> PlaybookExecutor(playbooks=['/etc/ansible/single/playbooks/setup.yml'],inventory=inventory,
>   variable_manager=variable_manager,
>   loader=loader,options=options,passwords=passwords)
> results_callback = ResultCallback()
> pbe._tqm._stdout_callback = results_callback
> return_code = pbe.run()
>  
>
> Thank you,
> Tom
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 

[ansible-project] Re: ansible with elastic search with Jinja2 Template

2018-04-13 Thread Bishwajit Samanta
Can anyone help me in my problem please ? 


On Friday, April 13, 2018 at 8:21:31 PM UTC+5:30, Bishwajit Samanta wrote:
>
>
>
> Hi, my question is :: 
> 
>
> My ansible script will be running for multiple systems. But in 
> elasticsearch.jinja2 how can i change the value of node.name for 
> different systems.
>
> Jinja 2 Code::-
> ---
>
> # -- Cluster 
> ---
> #
> # Use a descriptive name for your cluster:
> #
>  cluster.name: {{ my_defined_cluster_name }}
> #
> #  Node 
> 
> #
> # Use a descriptive name for the node:
> #
>  node.name: {{ my_defined_node_name }}
> #
> # Add custom attributes to the node:
> #
> # node.rack: r1
>
> If i am running this jinja2 file, across all the systems the value of 
> node.name will be same. But i dont want this, i want to put some other 
> values when it runs to other systems. 
>
> what modification i can do in Jinja2 file , can anyone help me ??
>
> My ansible playbook looks like this::
>
>
> ---
>
> ## Task Related to Configuration of Elastic Search :: 
>
> - name: Copy Configuration file for Elastic Search 
>   template:
> src: elasticsearch.jinja2
> dest: /etc/elasticsearch/elasticsearch.yml
> mode: 0750
> owner: root
> group: elasticsearch
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cb729411-2196-4619-a9f6-e6301c8288b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Ansible Playbook running for longtime/indefinitely for windows 2012 R2 Ansible Playbook

2018-04-13 Thread Namasivayam C
Hi

We have rebooted the Ansible server issues got fixed

On Thu 12 Apr, 2018, 8:31 PM Ramanjaneyulu S,  wrote:

> I have the same issue while using win_packageto install applications on
> remote windows servers. in the log ansible is giving status code 200 thrice
> and then status code 500 consistently.
>
> let me know, if you got any workaround.
>
> Thank you
>
> On Thursday, 8 March 2018 02:32:51 UTC-5, Namasivayam C wrote:
>>
>>
>> I am new to Ansible and I'm trying to configure windows 2012 R2 from RHEL
>> 7 Ansible Node. I'm able to establish connection between them using Winrm
>> Credssp. Below is /etc/ansible/group_vars/windows.yml file
>>
>>
>> COMPONENT NAME
>> urllib3.connectionpool https://192.168.2.211:5986 "POST /wsman HTTP/1.1"
>> 500 1320
>>
>>
>> ANSIBLE VERSION
>> ansible 2.3.1.0
>>
>> python version = 2.7.5
>>
>>
>> ansible_user: admin
>> ansible_password: XXX
>> ansible_winrm_scheme: https
>> ansible_winrm_transport: credssp
>> ansible_port: 5986
>> ansible_connection: winrm
>> ansible_winrm_server_cert_validation: ignore
>> validate_certs: false
>>
>> When I execute win_ping module for testing connection from Ansible node
>> to Windows 2012 R2 server it was successful.
>>
>> [root@Ansible-Server playbooks]# ansible windows -m win_ping
>> XX.XX.XX.XX | SUCCESS => {
>> "changed": false,
>> "ping": "pong"
>> }
>>
>> But When I have tried executing Windows 2012 R2 playbook file, after
>> submitting ansible-playbook playbook.yml command, it is continuously
>> waiting for indefinite time, as It is not completing.
>>
>> Below is the log that is constantly displaying same. Waiting
>> continuously. /var/log/ansible/log
>>
>> 2018-03-07 19:34:14,255 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:34:34,256 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:34:54,256 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:35:14,258 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:35:34,257 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:35:54,272 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:36:14,272 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:36:34,273 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:36:54,273 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:37:14,273 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:37:34,273 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:37:54,274 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:38:14,274 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:38:34,274 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>> 2018-03-07 19:38:54,274 urllib3.connectionpool https://192.168.2.211:5986 
>> "POST
>> /wsman HTTP/1.1" 500 1320
>>
>> above log continues/updates same for every 20 sec.
>>
>> Could you please any one suggest where it' got stuck and how i can
>> identify and troubleshoot .
>>
>>
>>
>> --
> 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/drzmhWiLvew/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b3088ba8-e074-4592-a919-3d6c9a497ff5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


[ansible-project] Re: Proper handling of host specific credential files

2018-04-13 Thread Jean Helou
in a classical case of rubber duck debbuging, I found a possible answer 
seconds after posting my message 

- name: "Install client openvpn credentials"
  copy:
src: "{{ inventory_dir+'/host_vars/'+inventory_hostname+'/openvpn.'+ 
item }}"
dest: "/etc/openvpn/{{ hostname }}.{{ item }}"
mode: 0755
  with_items:
- crt
- key
  tags:
- foo

I am still interested to know if this is a proper solution and if not what 
is the idiomatic/recommended way to handle this case. 

thanks
jean

On Wednesday, April 11, 2018 at 11:52:08 AM UTC+2, Jean Helou wrote:
>
> Hi, 
>
> I am using ansible 2.5, I have gone through the best practices 
> 
>  
> but I fail to understand how I am supposed to properly handle 
> *host-specific* files. 
>
> My exact use case is handling vpn certificates for computers embedded in 
> cars. the vpn lets the cars talk to our internal servers.
> Each deployed car has it's own vpn certificate and key allowing for 
> individual revocation. The .crt and the .key files really are host 
> specific. 
>
> Here is the tree I thought I could use : 
> .
> ├── inventories
> │   ├── group_vars
> │   │   └── mygroup
> │   └── host_vars
> │   └── demo-box
> │   ├── demo-box.crt
> │   ├── demo-box.key
> │   └── demo-box.yml
> ├── playbook.yml
> ├── playbooks
> │   └── setup.yml
> └── roles
> └── linux
> └── openvpn
> ├── defaults
> │   └── main.yml
> ├── files
> ├── meta
> │   └── main.yml
> └── tasks
> └── main.yml
>
> Unfortunately I can't seem to get the copy plugin to properly resolve the 
> .key and .crt files (the host vars are indeed processed) 
>
> my initial naive attempt for the tasks/main.yml was 
>
> - name: "Install client openvpn credentials"
>   copy:
> src: "openvpn.{{item}}"
> dest: "/etc/openvpn/{{ hostname }}.{{ item }}"
> mode: 0755
>   with_items:
> - crt
> - key
>   tags:
> - foo
>
> When running ansible-playbook -i inventories/test.lst playbook.yml I get 
> the follwing error
>
> AnsibleFileNotFound: Could not find or access 'openvpn.crt'
> Searched in:
> /home/ansible/ansible/roles/linux/openvpn/files/openvpn.crt
> /home/ansible/ansible/roles/linux/openvpn/openvpn.crt
> /home/ansible/ansible/roles/linux/openvpn/tasks/files/openvpn.crt
> /home/ansible/ansible/roles/linux/openvpn/tasks/openvpn.crt
> /home/ansible/ansible/playbooks/files/openvpn.crt
> /home/ansible/ansible/playbooks/openvpn.crt
>
> So it seems that unlike vars, default file lookup doesn't look into 
> inventory_dir at all. and also that using a top level file directory  like 
> in 
> https://stackoverflow.com/questions/32830428/where-should-i-be-organizing-host-specific-files-templates?lq=1
>  
> in not going to work. Adding playbook_vars_root = all to ansible.cfg 
> doesn't help either as it seem to only apply to vars.
>  
> Based on 
> https://www.reddit.com/r/ansible/comments/29mnp3/where_to_store_perhost_config_files/,
>  
> I tried using lookup like so 
>
> - name: "Install client openvpn credentials"
> src: "{{ lookup('file', inventory_dir + '/host_vars/' + 
> inventory_hostname + '/openvpn.'+ item ) }}"
> dest: "/etc/openvpn/{{ hostname }}.{{ item }}"
> mode: 0755
>   with_items:
> - crt
> - key
>
> but that doesn't seem to be valid anymore in 2.5 (I get an error about 
> quotes but can't spot a quoting error) and this syntax is totally absent 
> from 2.5 documentation.
>
> What is the "official" recommendation for this use case ? 
> I guess I could create 2 string vars for the key and crt files and use 
> ansible-vault encrypt-string instead of encrypt to secure the key. This is 
> a relatively painful process (as opposed to simply copying the files over 
> to the proper host folder) and we have tens of systems to retrofit into 
> ansible. I was hoping there would be a better solution for host-specfic 
> credential files. 
>
> thanks
> jean
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2eae2c06-1520-4054-80e8-2bd322949b36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Getting two results with custom callbacks

2018-04-13 Thread tommcf64
Hi,
  I am attempting to use the Ansible API to run and playbook and insert the 
facts into a mongodb database but I am getting two documents for each 
machine.  I am a newbie and unfamiliar with the API.  Can anyone shed my 
insight into why my code creates two outputs, I would greatly appreciate 
the help.

Here is the code:
#!/usr/bin/env python

import json
import shutil
from collections import namedtuple
from ansible.parsing.dataloader import DataLoader
from ansible.vars.manager import VariableManager
from ansible.inventory.manager import InventoryManager
from ansible.executor.playbook_executor import PlaybookExecutor
from ansible.playbook.play import Play
from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.plugins.callback import CallbackBase
import ansible.constants as C
import pymongo

connection = pymongo.MongoClient("mongodb://:27017")
db = connection.infrastructure
servers = db.servers
one_server = dict()

class ResultCallback(CallbackBase):
"""A sample callback plugin used for performing an action as results 
come in

If you want to collect all results into a single object for processing 
at
the end of the execution, look into utilizing the ``json`` callback 
plugin
or writing your own custom callback plugin
"""
def v2_runner_on_ok(self, result, **kwargs):
"""Print a json representation of the result

This method could store the result in an instance attribute for 
retrieval later
"""
host = result._host
#one_server = ((json.dumps({host.name: result._result})))
one_server = ({host.name: result._result})
#print(one_server)
servers.insert(one_server,check_keys=False)

Options = namedtuple('Options', ['connection', 'module_path', 'forks', 
'become', 'become_method', 'become_user', 'check', 'diff'])
# initialize needed objects
loader = DataLoader()
options = Options(connection='local', module_path=['/path/to/mymodules'], 
forks=100, become=None, become_method=None, become_user=None, check=False,
  diff=False)
passwords = dict(vault_pass='secret')

# Instantiate our ResultCallback for handling results as they come in
results_callback = ResultCallback()

# create inventory and pass to var manager
# use path to host config file as source or hosts in a comma separated 
string
inventory = InventoryManager(loader=loader, 
sources='/etc/ansible/single/playbooks/hosts')
variable_manager = VariableManager(loader=loader, inventory=inventory)

Options = namedtuple('Options',
 ['connection',
  'remote_user',
  'ask_sudo_pass',
  'verbosity',
  'ack_pass',
  'module_path',
  'forks',
  'become',
  'become_method',
  'become_user',
  'check',
  'listhosts',
  'listtasks',
  'listtags',
  'syntax',
  'sudo_user',
  'sudo',
  'diff'])
options = Options(connection='smart',
   remote_user=None,
   ack_pass=None,
   sudo_user=None,
   forks=5,
   sudo=None,
   ask_sudo_pass=False,
   verbosity=5,
   module_path=None,
   become=None,
   become_method=None,
   become_user=None,
   check=False,
   diff=False,
   listhosts=None,
   listtasks=None,
   listtags=None,
   syntax=None)

pbe = 
PlaybookExecutor(playbooks=['/etc/ansible/single/playbooks/setup.yml'],inventory=inventory,
  variable_manager=variable_manager,
  loader=loader,options=options,passwords=passwords)
results_callback = ResultCallback()
pbe._tqm._stdout_callback = results_callback
return_code = pbe.run()
 

Thank you,
Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/036c9014-3d3c-4020-b69c-ac9b3bb1395f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Using subversion via http?

2018-04-13 Thread Michael Renner
Moin,

a simple playbook won't work:

  - name: svn checkout
subversion:
  repo: http://svn-01.int.de/operation/foobar
  dest: /tmp/checkout
delegate_to: localhost

but it fail:
TASK [svn checkout] 
*
fatal: [server.local -> localhost]: FAILED! => {"changed": false, "cmd": 
"/usr/local/bin/svn --non-interactive --trust-server-cert --no-auth-cache 
checkout -r HEAD http://svn-01.int.de/operation/foobar /tmp/checkout", 
"msg": "svn: OPTIONS of 'http://svn-01.int.de/operation/foobar': 
authorization failed: Could not authenticate to server: rejected Basic 
challenge (http://svn-01.int.de)", "rc": 1, "stderr": "svn: OPTIONS of 
'http://svn-01.int.de/operation/foobar': authorization failed: Could not 
authenticate to server: rejected Basic challenge (http://svn-01.int.de)\n", 
"stderr_lines": ["svn: OPTIONS of 'http://svn-01.int.de/operation/foobar': 
authorization failed: Could not authenticate to server: rejected Basic 
challenge (http://svn-01.int.de)"], "stdout": "", "stdout_lines": []}

There is no password protection, it's also possible to check out the 
repository by
/usr/local/bin/svn --non-interactive --trust-server-cert --no-auth-cache 
checkout -r HEAD http://svn-01.int.de/operation/foobar /tmp/checkout
in a shell.

What may be wrong?

Thanks for answers!

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ff451692-f865-428b-b39f-191e3faba954%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: List of running processes form multiple linux hosts using with_items

2018-04-13 Thread Kai Stian Olstad
On Friday, 13 April 2018 10.11.21 CEST smitconsultant2...@gmail.com wrote:

> Thanks. It is creating file for each hostname but data is not in readable 
> format. Are you able to do favor little more, how to get the data in each 
> file as orignal form like as processes list show on linux machine?

Replace {{ output }} with {{ output.stdout }}


> I was 
> initially thinking to get output from all hosts in one file and somehow get 
> processes list along with hostname one by one. But this can work as well. 

To do that you need to use jinja template, something like this should work.

  - name: Getting some details of systems
copy:
  content: |
{% for i in ansible_play_hosts %}
Output for host {{ i }}:
{{ hostvars[i].output.stdout }}

{% endfor %}
  dest: /my/file
  delegate: localhost


-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/507899709.q8DnG1Y3qU%40x1.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: vsphere wait for vm powered off

2018-04-13 Thread Kai Stian Olstad
On Friday, 13 April 2018 09.14.36 CEST Zeljko Dokman wrote:
> Do you know is it possible to list all undocumented parameters of a module 
> and its states?

I don't think there are any undocumented parameters so in that regard the 
module documentation is very good.
But the output they generate is lacking on many of them, and the only way to 
find this is to read the code or run it and print out the result as I described 
in previous post.


-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2410362.O0lMVxFnl9%40x1.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Cannot create user [solved]

2018-04-13 Thread Werner Flamme
Werner Flamme [13.04.2018 16:30]:
> Werner Flamme [13.04.2018 16:18]:
>> Hi,
>>
>> can someone please show me what's wrong?
>>
>> - name: create one single user
>>   user:
>> user: "someguy"
>> password: "something secret here"
>> group: "users"
>> state: "present"
>>
>> does not create a user, but invokes usermod instead of useradd. Of
>> course, I get a message telling me that the user does not exist in
>> /etc/passwd. This is very correct.
>>
>> Using no quotation marks around present or leaving them away completely
>> does not help.
>>
>> I'm running ansible 2.5.0 on python version = 2.7.13.
>>
>> Regards,
>> Werner
>>
> 
> First solution: use shorter user name. It works when "someguy" is
> replaced with "exer". Originally, we use an 8 character user name.
> 
> Unfortunately, the usernames are not designed by me... I have to use
> usernames with up to 8 characters.
> 
> Regards,
> Werner
> 

Note to self: Do not try to create a user locally that is available via
LDAP when the system has a LDAP login... *cough*

Thanks for looking.

Werner
-- 


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/dd0b5013-fc45-9268-87c5-c86bef1fa303%40ufz.de.
For more options, visit https://groups.google.com/d/optout.


smime.p7s
Description: S/MIME Cryptographic Signature


Re: [ansible-project] Re: unable to fit the piece of code in ansible

2018-04-13 Thread Bishwajit Samanta
Ansible:: 2.4 is the version i am using.

On Friday, April 13, 2018 at 11:40:02 AM UTC+5:30, Biswadip Dutta wrote:
>
> Can you please let me know which Ansible version you are using and what 
> error you are getting?
>
> Regards,
> Biswadip Dutta
>
> On Thu, Apr 12, 2018 at 7:16 PM, Bishwajit Samanta <
> bishwajits...@gmail.com > wrote:
>
>> Thanks Karl, for your reply. Problem statement ::-
>>
>> My job is to find out the hostname which belongs to hostclass ess, which 
>> in this case the answer is host002.
>>
>> hostinfo:
>>   'host001':
>> ip: 192.168.43.10
>> hostclass: 'puppet'
>>   'host002':
>> ip: 192.168.43.11
>> hostclass: 'ess'
>>   'host003':
>> ip: 192.168.43.21
>> hostclass: 'mdb'
>>
>>
>> i got one solution from some friend in google ansible groups only, but i 
>> am unable to fit it my ansible playbook.
>>
>>
>> - debug:
>> msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto', 
>> 'ess')|first|first }}"
>>
>>
>> The playbook i am writing, which is wrong but i am not able to figure out 
>> how to fit the code in my playbook. Can anyone help me in modifying the 
>> code of mine.
>>
>> ---
>>
>> - hosts: somehost
>>   gather_facts: no
>>   vars_files:
>> file: sometext.yaml
>> name: sometext
>>
>>   - debug:
>> msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto', 
>> 'ess')|first|first }}
>>
>>
>> On Thursday, April 12, 2018 at 5:52:14 PM UTC+5:30, Karl Auer wrote:
>>>
>>> Can I suggest that you describe what you want to achieve. That is, 
>>> describe the end result that you are seeking.
>>>
>>> That is more likely to get a useful response.
>>>
>>> Regards, K.
>>>
>>>
>>> On Thu, Apr 12, 2018 at 9:58 PM, Bishwajit Samanta <
>>> bishwajits...@gmail.com> wrote:
>>>
 Any one can suggest any idea please..

 On Thursday, April 12, 2018 at 8:21:32 AM UTC+5:30, Bishwajit Samanta 
 wrote:
>
> Hi all,
>
> I am a beginner in ansible. If anyone can help me in finding the 
> answer. It would be great. My problem was finding a phrase in ansible 
> which 
> one of the person have helped me. But unfortunately i am not able to fit 
> the piece of code in my playbook.
>
> hostinfo:
>   host001':
> ip: 192.168.43.10
> hostclass: 'puppet'
>   'host002':
> ip: 192.168.43.11
> hostclass: 'ess'
>   'host003':
> ip: 192.168.43.21
> hostclass: 'mdb'
>
> the code was::
>
> - debug: 
>   msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto', 
> 'ess')|first|first }}"
>
> Now i am writing the code as given below. I know in this piece of code 
> i am making mistakes. But since i am a beginner i am not able to 
> understand 
> it. Can anyone help me?
>
> ---
> - hosts: test
>   gather_facts: no 
>
> - debug: 
>   msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto', 
> 'ess')|first|first }}"
>
> -- 
 You received this message because you are 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 post to this group, send email to ansible...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/ansible-project/4431f374-65b9-4884-9acb-f709bdd658f3%40googlegroups.com
  
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>>
>>> -- 
>>> Karl Auer
>>>
>>> Email  : ka...@2pisoftware.com
>>> Website: http://2pisoftware.com
>>>
>>> GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>>> Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA
>>>
>> -- 
>> You received this message because you are 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 post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/bacee1a5-37a0-423a-9dcf-a8625c361493%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 

[ansible-project] ansible with elastic search with Jinja2 Template

2018-04-13 Thread Bishwajit Samanta


Hi, my question is :: 


My ansible script will be running for multiple systems. But in 
elasticsearch.jinja2 how can i change the value of node.name for different 
systems.

Jinja 2 Code::-
---

# -- Cluster 
---
#
# Use a descriptive name for your cluster:
#
 cluster.name: {{ my_defined_cluster_name }}
#
#  Node 

#
# Use a descriptive name for the node:
#
 node.name: {{ my_defined_node_name }}
#
# Add custom attributes to the node:
#
# node.rack: r1

If i am running this jinja2 file, across all the systems the value of 
node.name will be same. But i dont want this, i want to put some other 
values when it runs to other systems. 

what modification i can do in Jinja2 file , can anyone help me ??

My ansible playbook looks like this::


---

## Task Related to Configuration of Elastic Search :: 

- name: Copy Configuration file for Elastic Search 
  template:
src: elasticsearch.jinja2
dest: /etc/elasticsearch/elasticsearch.yml
mode: 0750
owner: root
group: elasticsearch


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c2c74408-6c49-4e3f-bda7-350c65ecb6d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Cannot create user

2018-04-13 Thread Werner Flamme
Werner Flamme [13.04.2018 16:18]:
> Hi,
> 
> can someone please show me what's wrong?
> 
> - name: create one single user
>   user:
> user: "someguy"
> password: "something secret here"
> group: "users"
> state: "present"
> 
> does not create a user, but invokes usermod instead of useradd. Of
> course, I get a message telling me that the user does not exist in
> /etc/passwd. This is very correct.
> 
> Using no quotation marks around present or leaving them away completely
> does not help.
> 
> I'm running ansible 2.5.0 on python version = 2.7.13.
> 
> Regards,
> Werner
> 

First solution: use shorter user name. It works when "someguy" is
replaced with "exer". Originally, we use an 8 character user name.

Unfortunately, the usernames are not designed by me... I have to use
usernames with up to 8 characters.

Regards,
Werner

-- 


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/aa889456-b3da-6f37-e664-653a95dea6a6%40ufz.de.
For more options, visit https://groups.google.com/d/optout.


smime.p7s
Description: S/MIME Cryptographic Signature


[ansible-project] Cannot create user

2018-04-13 Thread Werner Flamme
Hi,

can someone please show me what's wrong?

- name: create one single user
  user:
user: "someguy"
password: "something secret here"
group: "users"
state: "present"

does not create a user, but invokes usermod instead of useradd. Of
course, I get a message telling me that the user does not exist in
/etc/passwd. This is very correct.

Using no quotation marks around present or leaving them away completely
does not help.

I'm running ansible 2.5.0 on python version = 2.7.13.

Regards,
Werner

-- 



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/49963f37-336a-2da6-680d-297e4ac53c95%40ufz.de.
For more options, visit https://groups.google.com/d/optout.


smime.p7s
Description: S/MIME Cryptographic Signature


[ansible-project] Variables with quotes

2018-04-13 Thread Shaun Lim
Hi all,

I'm new to Ansible and am trying to use some variables with quotes. The 
command I'm trying to run is as follows:
rabbitmqctl set_permissions -p /vhost username ".*" ".*" ".*"



To do this, I'm trying to use the command module. If I include the command 
exactly as above, the command runs successfully but I'm trying to make this 
reusable so I've changed a few of those into variables instead. My task 
currently looks like this:
- name: Set user permissions on RabbitMQ
  become: yes
  command: rabbitmqctl set_permissions -p /"{{ rabbitVhost }}" "{{ 
rabbitUser }}" "{{ rabbitAcl }}"


I can't seem to get this to work. I've tried sending the parameters like 
this:
ansible-playbook rabbit.yml 
--extra-vars='{"rabbitUser":"shaun","rabbitSecret":"P@ssw0rd","rabbitVhost":"sensu","rabbitAcl":"\\\".*\\\"
 
\\\".*\\\" \\\".*\\\""}'


The error I get is as below and it looks like the parameters are being set 
correctly:
fatal: [localhost]: FAILED! => {
"changed": true,
"cmd": [
"rabbitmqctl",
"set_permissions",
"-p",
"/sensu",
"shaun",
"\".*\" \".*\" \".*\""
],
"delta": "0:00:00.691783",
"end": "2018-04-13 23:37:49.505521",
"invocation": {
"module_args": {
"_raw_params": "rabbitmqctl set_permissions -p /\"sensu\" 
\"shaun\" \"\\\".*\\\" \\\".*\\\" \\\".*\\\"\"",
"_uses_shell": false,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"warn": true
}
},
"msg": "non-zero return code",
"rc": 64,
"start": "2018-04-13 23:37:48.813738",
"stderr": "Error: operation set_permissions used with invalid 
parameter: [\"shaun\",\n   
\"\\\".*\\\" \\\".*\\\" \\\".*\\\"\"]",
"stderr_lines": [
"Error: operation set_permissions used with invalid parameter: 
[\"shaun\",",
"   
\"\\\".*\\\" \\\".*\\\" \\\".*\\\"\"]"
],

Any help would be appreciated.

Thanks.

Regards,
Shaun

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/586e02e0-61ad-458f-8602-66977c14d411%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible : get running config from aruba switches

2018-04-13 Thread Martial CHAVIGNY
Log in ansible :

2018-04-13 15:26:16,799 p=4956 u=mchavigny |  ansible 2.5.0 (stable-2.5 
955ef020ef) last updated 2018/04/12 16:44:14 (GMT +200)
  config file = /opt/ansible/ansible.cfg
  configured module search path = [u'/opt/ansible/library']
  ansible python module location = /opt/ansible/lib/ansible
  executable location = /opt/ansible/bin/ansible
  python version = 2.7.14 (default, Oct 31 2017, 21:12:13) [GCC 6.4.0]
2018-04-13 15:26:16,799 p=4956 u=mchavigny |  Using 
/opt/ansible/ansible.cfg as config file
2018-04-13 15:26:16,800 p=4956 u=mchavigny |  setting up inventory plugins
2018-04-13 15:26:16,926 p=4956 u=mchavigny |  Parsed swautc02, inventory 
source with host_list plugin
2018-04-13 15:26:19,696 p=4956 u=mchavigny |  Loading callback plugin 
minimal of type stdout, v2.0 from 
/opt/ansible/lib/ansible/plugins/callback/minimal.pyc
2018-04-13 15:26:22,368 p=4956 u=mchavigny |  META: ran handlers
2018-04-13 15:26:35,095 paramiko.transport starting thread (client mode): 
0xfd7283d0L
2018-04-13 15:26:35,096 paramiko.transport Local version/idstring: 
SSH-2.0-paramiko_2.4.1
2018-04-13 15:26:35,097 paramiko.transport Remote version/idstring: 
SSH-2.0-Mocana SSH 6.3
2018-04-13 15:26:35,097 paramiko.transport Connected (version 2.0, client 
Mocana)
2018-04-13 15:26:35,108 paramiko.transport kex 
algos:[u'diffie-hellman-group14-sha1'] server key:[u'ssh-rsa'] client 
encrypt:[u'aes256-ctr', u'aes256-cbc', u'rijndael-...@lysator.liu.se', 
u'aes192-ctr', u'aes192-cbc', u'aes128-ctr', u'aes128-cbc', u'3des-cbc'] 
server encrypt:[u'aes256-ctr', u'aes256-cbc', 
u'rijndael-...@lysator.liu.se', u'aes192-ctr', u'aes192-cbc', 
u'aes128-ctr', u'aes128-cbc', u'3des-cbc'] client mac:[u'hmac-sha1-96', 
u'hmac-md5', u'hmac-sha1', u'hmac-md5-96'] server mac:[u'hmac-sha1-96', 
u'hmac-md5', u'hmac-sha1', u'hmac-md5-96'] client compress:[u'none'] server 
compress:[u'none'] client lang:[u''] server lang:[u''] kex follows?False
2018-04-13 15:26:35,108 paramiko.transport Kex agreed: 
diffie-hellman-group14-sha1
2018-04-13 15:26:35,109 paramiko.transport HostKey agreed: ssh-rsa
2018-04-13 15:26:35,109 paramiko.transport Cipher agreed: aes128-ctr
2018-04-13 15:26:35,109 paramiko.transport MAC agreed: hmac-sha1
2018-04-13 15:26:35,110 paramiko.transport Compression agreed: none
2018-04-13 15:26:35,542 paramiko.transport kex engine KexGroup14 specified 
hash_algo 
2018-04-13 15:26:35,543 paramiko.transport Switch to new keys ...
2018-04-13 15:26:35,582 paramiko.transport Trying discovered key 
931806b200d37ba37c23ed0f745877c3 in /opt/ansible/bkpkey.key
2018-04-13 15:26:35,750 paramiko.transport userauth is OK
2018-04-13 15:26:35,840 paramiko.transport Auth banner: We'd like to keep 
you up to date about:
  * Software feature updates
  * New product announcements
  * Special events
Please register your products now at:  www.hpe.com/networking/register



2018-04-13 15:26:35,892 paramiko.transport Authentication (publickey) 
successful!
2018-04-13 15:26:35,896 paramiko.transport [chan 0] Max packet in: 32768 
bytes
2018-04-13 15:26:35,942 paramiko.transport [chan 0] Max packet out: 32768 
bytes
2018-04-13 15:26:35,942 paramiko.transport Secsh channel 0 opened.
2018-04-13 15:26:36,047 paramiko.transport [chan 0] Sesch channel 0 request 
ok
2018-04-13 15:26:36,153 paramiko.transport [chan 0] Sesch channel 0 request 
ok
2018-04-13 15:26:46,678 p=160 u=mchavigny |  shutdown complete
2018-04-13 15:26:46,693 paramiko.transport EOF in transport thread
2018-04-13 15:26:46,764 p=4956 u=mchavigny |  The full traceback is:
Traceback (most recent call last):
  File "/usr/bin/ansible-connection", line 70, in start
self.connection._connect()
  File "/opt/ansible/lib/ansible/plugins/connection/network_cli.py", line 
316, in _connect
self.receive()
  File "/opt/ansible/lib/ansible/plugins/connection/network_cli.py", line 
391, in receive
data = self._ssh_shell.recv(256)
  File "/usr/lib/python2.7/site-packages/paramiko/channel.py", line 685, in 
recv
raise socket.timeout()
timeout

2018-04-13 15:26:46,772 p=4956 u=mchavigny |  swautc02 | FAILED! => {
"msg": ""
}


Le vendredi 13 avril 2018 13:12:40 UTC+2, Martial CHAVIGNY a écrit :
>
> Hello,
>
> I'm new user of ansible and for the first projet, I would to get current 
> config of aruba (2930F) switches (for backup).
>
> I read these documentations :
>
>
> https://docs.ansible.com/ansible/devel/network/getting_started/first_playbook.html
> https://docs.ansible.com/ansible/2.4/aruba_config_module.html
>
> For the debug, I test with this commande :
>
> ansible all -i swautc02, -c network_cli -u manager -m aruba_config -e 
> ansible_network_os=aruba - --private-key=bkpkey.key
>
> but return :
>
> ansible 2.5.0 (stable-2.5 955ef020ef) last updated 2018/04/12 16:44:14 
>> (GMT +200)
>>   config file = /opt/ansible/ansible.cfg
>>   configured module search path = [u'/opt/ansible/library']
>>   ansible python module location = /opt/ansible/lib/ansible
>>   executable 

[ansible-project] Re: Ansible : get running config from aruba switches

2018-04-13 Thread Martial CHAVIGNY
Log in /var/log/ansible :

2018-04-13 15:22:22,108 p=2296 u=mchavigny |  ansible 2.5.0 (stable-2.5 
> 955ef020ef) last updated 2018/04/12 16:44:14 (GMT +200)
>   config file = /opt/ansible/ansible.cfg
>   configured module search path = [u'/opt/ansible/library']
>   ansible python module location = /opt/ansible/lib/ansible
>   executable location = /opt/ansible/bin/ansible
>   python version = 2.7.14 (default, Oct 31 2017, 21:12:13) [GCC 6.4.0]
> 2018-04-13 15:22:22,108 p=2296 u=mchavigny |  Using 
> /opt/ansible/ansible.cfg as config file
> 2018-04-13 15:22:29,129 p=2296 u=mchavigny |  setting up inventory plugins
> 2018-04-13 15:22:29,474 p=2296 u=mchavigny |  Parsed 172.25.0.56, 
> inventory source with host_list plugin
> 2018-04-13 15:22:33,726 p=2296 u=mchavigny |  Loading callback plugin 
> minimal of type stdout, v2.0 from 
> /opt/ansible/lib/ansible/plugins/callback/minimal.pyc
> 2018-04-13 15:22:36,913 p=2296 u=mchavigny |  META: ran handlers
> 2018-04-13 15:22:52,906 paramiko.transport starting thread (client mode): 
> 0xfd7283d0L
> 2018-04-13 15:22:52,908 paramiko.transport Local version/idstring: 
> SSH-2.0-paramiko_2.4.1
> 2018-04-13 15:22:56,012 paramiko.transport Remote version/idstring: 
> SSH-2.0-OpenSSH_3.7.1p2
> 2018-04-13 15:22:56,012 paramiko.transport Connected (version 2.0, client 
> OpenSSH_3.7.1p2)
> 2018-04-13 15:22:56,025 paramiko.transport kex 
> algos:[u'diffie-hellman-group-exchange-sha1', 
> u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa'] client 
> encrypt:[u'des', u'3des-cbc'] server encrypt:[u'des', u'3des-cbc'] client 
> mac:[u'hmac-md5', u'hmac-sha1', u'hmac-ripemd160', 
> u'hmac-ripemd...@openssh.com', u'hmac-sha1-96', u'hmac-md5-96'] server 
> mac:[u'hmac-md5', u'hmac-sha1', u'hmac-ripemd160', 
> u'hmac-ripemd...@openssh.com', u'hmac-sha1-96', u'hmac-md5-96'] client 
> compress:[u'none'] server compress:[u'none'] client lang:[u''] server 
> lang:[u''] kex follows?False
> 2018-04-13 15:22:56,025 paramiko.transport Kex agreed: 
> diffie-hellman-group-exchange-sha1
> 2018-04-13 15:22:56,025 paramiko.transport HostKey agreed: ssh-rsa
> 2018-04-13 15:22:56,026 paramiko.transport Cipher agreed: 3des-cbc
> 2018-04-13 15:22:56,026 paramiko.transport MAC agreed: hmac-sha1
> 2018-04-13 15:22:56,026 paramiko.transport Compression agreed: none
> 2018-04-13 15:22:56,541 paramiko.transport Got server p (2048 bits)
> 2018-04-13 15:22:57,595 paramiko.transport kex engine KexGex specified 
> hash_algo 
> 2018-04-13 15:22:57,604 paramiko.transport Switch to new keys ...
> 2018-04-13 15:22:57,639 paramiko.transport userauth is OK
> 2018-04-13 15:22:58,035 paramiko.transport Authentication (password) 
> successful!
> 2018-04-13 15:22:58,043 paramiko.transport [chan 0] Max packet in: 32768 
> bytes
> 2018-04-13 15:22:58,063 paramiko.transport [chan 0] Max packet out: 32768 
> bytes
> 2018-04-13 15:22:58,064 paramiko.transport Secsh channel 0 opened.
> 2018-04-13 15:22:58,081 paramiko.transport [chan 0] Sesch channel 0 
> request ok
> 2018-04-13 15:22:58,107 paramiko.transport [chan 0] Sesch channel 0 
> request ok
> 2018-04-13 15:23:08,362 p=10660 u=mchavigny |  shutdown complete
> 2018-04-13 15:23:08,447 paramiko.transport EOF in transport thread
> 2018-04-13 15:23:08,450 p=2296 u=mchavigny |  The full traceback is:
> Traceback (most recent call last):
>   File "/usr/bin/ansible-connection", line 70, in start
> self.connection._connect()
>   File "/opt/ansible/lib/ansible/plugins/connection/network_cli.py", line 
> 316, in _connect
> self.receive()
>   File "/opt/ansible/lib/ansible/plugins/connection/network_cli.py", line 
> 391, in receive
> data = self._ssh_shell.recv(256)
>   File "/usr/lib/python2.7/site-packages/paramiko/channel.py", line 685, 
> in recv
> raise socket.timeout()
> timeout
> 2018-04-13 15:23:08,457 p=2296 u=mchavigny |  172.25.0.56 | FAILED! => {
> "msg": ""
> }



Le vendredi 13 avril 2018 13:12:40 UTC+2, Martial CHAVIGNY a écrit :
>
> Hello,
>
> I'm new user of ansible and for the first projet, I would to get current 
> config of aruba (2930F) switches (for backup).
>
> I read these documentations :
>
>
> https://docs.ansible.com/ansible/devel/network/getting_started/first_playbook.html
> https://docs.ansible.com/ansible/2.4/aruba_config_module.html
>
> For the debug, I test with this commande :
>
> ansible all -i swautc02, -c network_cli -u manager -m aruba_config -e 
> ansible_network_os=aruba - --private-key=bkpkey.key
>
> but return :
>
> ansible 2.5.0 (stable-2.5 955ef020ef) last updated 2018/04/12 16:44:14 
>> (GMT +200)
>>   config file = /opt/ansible/ansible.cfg
>>   configured module search path = [u'/opt/ansible/library']
>>   ansible python module location = /opt/ansible/lib/ansible
>>   executable location = /opt/ansible/bin/ansible
>>   python version = 2.7.14 (default, Oct 31 2017, 21:12:13) [GCC 6.4.0]
>> Using /opt/ansible/ansible.cfg as config file
>> setting up inventory plugins
>> Parsed swautc02, inventory source 

[ansible-project] Jinja Format CSV and HTML From Yaml

2018-04-13 Thread Magnus Torstein
Within a play, one of the tasks is to generate a yaml file (using the 
ansible-inventory command to take a "snapshot" of a subset of the current 
inventory). From that yaml file, I want to do two things - 1) Create a CSV 
file with values both from the yaml file and from other vars generated 
previously during the play, 2) Format an HTML email to display the same 
information in a different manner. 

The CSV file will look as such:

Date (from prev. var), Time (from prev. var), hostname,* owner, 
other_key_value*

Sanitized yaml file:

all:
  children:
day_1:
  hosts:
server_1:
  owner: another group
  key: value
server_2:
  owner: some-team
  key: value

day_2:
  hosts:
server_1:
  owner: some-team
  key: value
server_2:
  owner: another group
  key: value



The jinja template thus far (for the csv):

% for groupname, hosts in curr_inv.all.children.items() %}
{% if 'day_' in groupname %}
{% for hostname, static_vars in hosts.hosts.items() %}
{{ my_dates[groupname].calendar_date }},{{ my_dates[groupname].time }},{{ 
hostname }}
{% endfor %}
{% endif %}
{% endfor %}



This gives me the first three necessary values without issue. Where I am 
having an issue is accessing the inner key=value pairs such as "owner: 
some-team".

For the HTML formatting, I want to use the same data but display it as such:

Date_1 - Time_1

some-team
server_that_belongs_to_this_group_1
server_that_belongs_to_this_group_2
server_that_belongs_to_this_group_3

a different group
server_that_belongs_to_this_group_1
server_that_belongs_to_this_group_2
server_that_belongs_to_this_group_3



Date_2 - Time_1

some-team
server_that_belongs_to_this_group_1
server_that_belongs_to_this_group_2
server_that_belongs_to_this_group_3

a different group
server_that_belongs_to_this_group_1
server_that_belongs_to_this_group_2
server_that_belongs_to_this_group_3



I hope this makes sense. Thank you!

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/baad6d30-6068-4087-be42-80d8f9cb6125%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible : get running config from aruba switches

2018-04-13 Thread Martial CHAVIGNY
Hello,

I'm new user of ansible and for the first projet, I would to get current 
config of aruba (2930F) switches (for backup).

I read these documentations :

https://docs.ansible.com/ansible/devel/network/getting_started/first_playbook.html
https://docs.ansible.com/ansible/2.4/aruba_config_module.html

For the debug, I test with this commande :

ansible all -i swautc02, -c network_cli -u manager -m aruba_config -e 
ansible_network_os=aruba - --private-key=bkpkey.key

but return :

ansible 2.5.0 (stable-2.5 955ef020ef) last updated 2018/04/12 16:44:14 (GMT 
> +200)
>   config file = /opt/ansible/ansible.cfg
>   configured module search path = [u'/opt/ansible/library']
>   ansible python module location = /opt/ansible/lib/ansible
>   executable location = /opt/ansible/bin/ansible
>   python version = 2.7.14 (default, Oct 31 2017, 21:12:13) [GCC 6.4.0]
> Using /opt/ansible/ansible.cfg as config file
> setting up inventory plugins
> Parsed swautc02, inventory source with host_list plugin
> Loading callback plugin minimal of type stdout, v2.0 from 
> /opt/ansible/lib/ansible/plugins/callback/minimal.pyc
> META: ran handlers
>  attempting to start connection
>  using connection plugin network_cli
>  local domain socket does not exist, starting it
>  control socket path is /home/mchavigny/.ansible/pc/632ab3f093
> 
> The full traceback is:
> Traceback (most recent call last):
>   File "/usr/bin/ansible-connection", line 70, in start
> self.connection._connect()
>   File "/opt/ansible/lib/ansible/plugins/connection/network_cli.py", line 
> 316, in _connect
> self.receive()
>   File "/opt/ansible/lib/ansible/plugins/connection/network_cli.py", line 
> 391, in receive
> data = self._ssh_shell.recv(256)
>   File "/usr/lib/python2.7/site-packages/paramiko/channel.py", line 685, 
> in recv
> raise socket.timeout()
> timeout
> swautc02 | FAILED! => {
> "msg": ""
> }


I check log on the aruba switch and I see :

I 04/13/18 12:55:00 03363 auth: User 'manager' logged out of SSH  session 
> from
> 172.20.0.25
> I 04/13/18 12:54:59 00179 mgr: SME SSH from 172.20.0.25 - MANAGER Mode
> I 04/13/18 12:54:49 03344 ssh: User manager : SSH session established with
> public-key authentication


Can you help me for this problem ?

Best regards,

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/150a3122-c024-411c-840b-db2185f44367%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ternary filter vs conditional expressions

2018-04-13 Thread Rastislav Barlik
Thanks Brian,

If people find the filter useful then that's fair enough. Everybody has a
difference preference. I probably suffer from Python's "There should be one
-- and preferably only one -- obvious way to do it."


On Thu, Apr 12, 2018 at 9:25 PM, Brian Coca  wrote:

> Other people found it confusing and wanted something they could easily
> lookup up, like a filter.
>
> Once I added it, I stopped hearing complaints, so not sure how much
> that is worth other than anecdotal evidence.
>
> Use whichever way suits you best.
>
>
>
>
>
> --
> --
> Brian Coca
>
> --
> 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/mi8zuVlRR3g/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/CACVha7cA6WoFgc7jOBcvwzr6nhpyA
> _uhBO3GoVfw%3Df0ys9%2BvGw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAPA8sOJ7d9Fg1bDzT3kZLB-Dg%2B4GdU1gpTC%3DngLUT9bOu8uuog%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to sort ansible output

2018-04-13 Thread Biswadip Dutta
Oh okay. I think I misunderstood your query.  What I was suggesting is that
you can write another script to sort the output based on your needs.
I don't think Ansible has such functionality. If there's one then I will
also like to know.

Regards,
Biswadip Dutta

On Fri, Apr 13, 2018 at 12:30 PM, The Wanderer 
wrote:

> I know, but how?
>
> On Fri, Apr 13, 2018 at 11:49 AM, Biswadip Dutta <
> biswadipdutta...@gmail.com> wrote:
>
>> I'd suggest you do the sorting part later. I mean after you get the
>> Ansible results and then sort it.
>>
>> Regards,
>> Biswadip Dutta
>>
>> On Fri, Apr 13, 2018 at 1:12 AM, The Wanderer 
>> wrote:
>>
>>> Hi all,
>>>
>>> I have a couple of servers that are managed via ansible. On all of them,
>>> I have got a script - free.sh - that when run, outputs just the free
>>> memory, like - 5GB. This is not the free system RAM, but a value that's
>>> obtained by complex calculations done via the script. I can call the script
>>> via ansible in this manner:
>>>
>>> ansible -bK -a "/usr/bin/free.sh" apache-servers
>>>
>>> (where apache-servers is the host-group on which I want to run the
>>> script)
>>>
>>> And here's the limitation that I'm facing - Ansible just returns results
>>> in the order the job completes. But, I want the result to be sorted
>>> according to the script's output. Is this possible?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible-project+unsubscr...@googlegroups.com.
>>> To post to this group, send email to ansible-project@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/ansible-project/2090253c-01a4-4db7-abe4-6275615ad826%40g
>>> ooglegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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/to
>> pic/ansible-project/i5uql5fjrAg/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> ansible-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/ansible-project/CAEC%3DuX%3Djp8ZidB7MWOaqf3%2BJ7cGTJ5Lna
>> OZh9iiisKA26mJ-Yw%40mail.gmail.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/CAM9iBPeQA3x9GBVRPWZb8zxH2mGf-
> dZyYh_eixwn9xCSm3zmFQ%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEC%3DuXmm%3Dk29Rqvc_6Mec%3DDXzO0f%2BL-SzM24Ax5ZePF5nZxQCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: List of running processes form multiple linux hosts using with_items

2018-04-13 Thread smitconsultant2017
HI Bishwajit Samanta

Thanks. It is creating file for each hostname but data is not in readable 
format. Are you able to do favor little more, how to get the data in each 
file as orignal form like as processes list show on linux machine? I was 
initially thinking to get output from all hosts in one file and somehow get 
processes list along with hostname one by one. But this can work as well. 
Many Thanks.



On Thursday, April 12, 2018 at 5:09:41 PM UTC+10, Bishwajit Samanta wrote:
>
> I just changed the host as devops
> ---
>
> - hosts: devops
>   gather_facts: no
>   tasks:
> - name: Get the running process across the systems
>   command: ps -ef
>   register: output
>
> - name: Getting some details of systems
>   local_action: copy content={{ output }} dest=/opt/{{ 
> inventory_hostname }}file
>
> Output::-
> -
>
> [root@ansible-master opt]# ls
> 192.168.56.111file  192.168.56.116file 
>
> You can try with this and see if your problem get resolved.
>
> On Wednesday, April 11, 2018 at 1:42:45 PM UTC+5:30, 
> smitconsu...@gmail.com wrote:
>>
>> Hi 
>> I am trying to achieve all running processes on our linux machines via 
>> ansible and get output in a file along with each host name and processes. I 
>> have made below playbook but not getting to the point how to get list of 
>> processes for each host one by one and store in a file. Can anyone please 
>> help with the code how can I achieve this? I am using with_items with list 
>> of hosts which is coming from inventory group hostlist. many thanks
>>
>> ---
>> - hosts: all
>>   gather_facts: false
>>   tasks:
>>
>>   - name: Get Running Processes
>> command: ps -ef
>> delegate_to: "{{ item }}"
>> run_once: false
>> with_items:
>>  - "{{ groups['hostlist'] }}"
>> register: process_list
>>
>>
On Thursday, April 12, 2018 at 5:09:41 PM UTC+10, Bishwajit Samanta wrote:
>
> I just changed the host as devops
> ---
>
> - hosts: devops
>   gather_facts: no
>   tasks:
> - name: Get the running process across the systems
>   command: ps -ef
>   register: output
>
> - name: Getting some details of systems
>   local_action: copy content={{ output }} dest=/opt/{{ 
> inventory_hostname }}file
>
> Output::-
> -
>
> [root@ansible-master opt]# ls
> 192.168.56.111file  192.168.56.116file 
>
> You can try with this and see if your problem get resolved.
>
> On Wednesday, April 11, 2018 at 1:42:45 PM UTC+5:30, 
> smitconsu...@gmail.com wrote:
>>
>> Hi 
>> I am trying to achieve all running processes on our linux machines via 
>> ansible and get output in a file along with each host name and processes. I 
>> have made below playbook but not getting to the point how to get list of 
>> processes for each host one by one and store in a file. Can anyone please 
>> help with the code how can I achieve this? I am using with_items with list 
>> of hosts which is coming from inventory group hostlist. many thanks
>>
>> ---
>> - hosts: all
>>   gather_facts: false
>>   tasks:
>>
>>   - name: Get Running Processes
>> command: ps -ef
>> delegate_to: "{{ item }}"
>> run_once: false
>> with_items:
>>  - "{{ groups['hostlist'] }}"
>> register: process_list
>>
>>
On Thursday, April 12, 2018 at 5:09:41 PM UTC+10, Bishwajit Samanta wrote:
>
> I just changed the host as devops
> ---
>
> - hosts: devops
>   gather_facts: no
>   tasks:
> - name: Get the running process across the systems
>   command: ps -ef
>   register: output
>
> - name: Getting some details of systems
>   local_action: copy content={{ output }} dest=/opt/{{ 
> inventory_hostname }}file
>
> Output::-
> -
>
> [root@ansible-master opt]# ls
> 192.168.56.111file  192.168.56.116file 
>
> You can try with this and see if your problem get resolved.
>
> On Wednesday, April 11, 2018 at 1:42:45 PM UTC+5:30, 
> smitconsu...@gmail.com wrote:
>>
>> Hi 
>> I am trying to achieve all running processes on our linux machines via 
>> ansible and get output in a file along with each host name and processes. I 
>> have made below playbook but not getting to the point how to get list of 
>> processes for each host one by one and store in a file. Can anyone please 
>> help with the code how can I achieve this? I am using with_items with list 
>> of hosts which is coming from inventory group hostlist. many thanks
>>
>> ---
>> - hosts: all
>>   gather_facts: false
>>   tasks:
>>
>>   - name: Get Running Processes
>> command: ps -ef
>> delegate_to: "{{ item }}"
>> run_once: false
>> with_items:
>>  - "{{ groups['hostlist'] }}"
>> register: process_list
>>
>>
On Thursday, April 12, 2018 at 5:09:41 PM UTC+10, Bishwajit Samanta wrote:
>
> I just changed the host as devops
> ---
>
> - hosts: devops
>   gather_facts: no
>   tasks:
> - name: Get the running process across the systems
>   command: ps -ef
>   register: output
>
> - name: Getting some details of systems
>   

[ansible-project] Re: HP ILO set from ansible (no OS installed)

2018-04-13 Thread Dave H
It's a python library. Create a new virtualenv, activate it, install 
ansible and python-hpilo and you should be good to run your playbook

virtualenv venv
. venv/bin/activate
pip install ansible python-hpilo
ansible-playbook -i "localhost," -c local playbook.yml



On Wednesday, 11 April 2018 10:10:11 UTC+1, Benny Kusman wrote:
>
> Hi  Dave,
>
> So i got this stupid question, where is the library of to put this hpilo ?
> i was looking at https://github.com/ansible/ansible/issues/7633, but 
> couldnt find the solution.
>
> Thank you
>
> On Tuesday, April 10, 2018 at 3:38:46 AM UTC, Dave H wrote:
>>
>> Hi Benny,
>>
>> There are a couple of development modules in the ansible docs, e.g. 
>> https://docs.ansible.com/ansible/devel/modules/hpilo_boot_module.html, 
>> but I have not used them.
>>
>> I use the python package from http://seveas.github.io/python-hpilo to 
>> expose a command line interface and use an example playbook like the 
>> following. You have to extract data from the output of the cli but it's 
>> fairly straightforward and very useful.
>>
>> ansible-playbook -i "localhost," -c local playbook.yml
>>
>> ---
>>
>> - hosts: localhost
>>   gather_facts: false
>>
>>   vars:
>>
>> ilo_host: "192.168.0.10"  # IP address / hostname of the iLO 
>> interface
>> ilo_user: "x" # username for the user to log into the iLO
>> ilo_password: "xx"# fetch from vault or other secret storage
>> hpilo_cli_cmd: "hpilo_cli {{ ilo_host }} --json --login='{{ ilo_user 
>> }}' --password='{{ ilo_password }}'"
>>
>>   tasks:
>>
>>   - name: Get current power status
>> command: "{{ hpilo_cli_cmd }} get_host_power_status"
>> register: hpilo_cli_get_host_power_status
>>   
>>   - name: Record power status
>> set_fact:
>>   power_status: "{% if 'ON' in 
>> hpilo_cli_get_host_power_status.stdout %}ON{% else %}OFF{% endif %}"
>>
>>   - name: Power on server - if it is powered down
>> command: "{{hpilo_cli_cmd}} press_pwr_btn"
>> when: power_status != "ON"
>>
>>   - name: Reboot server - if it is powered up
>> command: "{{hpilo_cli_cmd}} cold_boot_server"
>> when: power_status == "ON"
>>
>> Hope that helps.
>>
>> Dave
>>
>>
>> On Monday, 9 April 2018 09:37:15 UTC+1, Benny Kusman wrote:
>>>
>>> Hi,
>>>
>>> has anyone implemented setting up HP ILO using ansible, when the server 
>>> has no OS yet ?
>>> if the server has been installed and has hponcfg command, there is 
>>> ansible module for it.
>>>
>>> But wondering, if anyone has tried to setup the server in the ilo using 
>>> ansible (just simply specifying the ilo hostname, userid/password, port)
>>>
>>> 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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d843e73d-cca7-4896-b435-0998e84d372f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: vsphere wait for vm powered off

2018-04-13 Thread Zeljko Dokman
Hi, thank you for your replay

Do you know is it possible to list all undocumented parameters of a module 
and its states?

Regards


On Thursday, April 12, 2018 at 5:09:05 PM UTC+2, Kai Stian Olstad wrote:
>
> On 12.04.2018 14:11, Zeljko Dokman wrote: 
> > Hi, 
> > thank you for the info. 
> > one more question, for vsphere_guest module, how to know that "state" 
> > parameter should be referenced as 
> > "vm_state.ansible_facts.hw_power_status", this part a have not find in 
> > the 
> > documentation.? how is this contracted for all other parameters for 
> > particular module? 
>
> Some module has this documented, but most of them don't unfortunately. 
> So you are left with finding it yourself. 
>
> To do that you run the module with "register: ..." directive and print 
> the content of the variable. 
> The content you print like this 
>
>- debug: var=vm_state 
>
>
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fa0d51bb-527b-452b-9376-0514bce263aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to sort ansible output

2018-04-13 Thread The Wanderer
I know, but how?

On Fri, Apr 13, 2018 at 11:49 AM, Biswadip Dutta  wrote:

> I'd suggest you do the sorting part later. I mean after you get the
> Ansible results and then sort it.
>
> Regards,
> Biswadip Dutta
>
> On Fri, Apr 13, 2018 at 1:12 AM, The Wanderer 
> wrote:
>
>> Hi all,
>>
>> I have a couple of servers that are managed via ansible. On all of them,
>> I have got a script - free.sh - that when run, outputs just the free
>> memory, like - 5GB. This is not the free system RAM, but a value that's
>> obtained by complex calculations done via the script. I can call the script
>> via ansible in this manner:
>>
>> ansible -bK -a "/usr/bin/free.sh" apache-servers
>>
>> (where apache-servers is the host-group on which I want to run the script)
>>
>> And here's the limitation that I'm facing - Ansible just returns results
>> in the order the job completes. But, I want the result to be sorted
>> according to the script's output. Is this possible?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/ansible-project/2090253c-01a4-4db7-abe4-6275615ad826%
>> 40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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/i5uql5fjrAg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/CAEC%3DuX%3Djp8ZidB7MWOaqf3%
> 2BJ7cGTJ5LnaOZh9iiisKA26mJ-Yw%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] Trying to create a new user and password for server login . SSH permission denied error.

2018-04-13 Thread Biswadip Dutta
This

might
be helpful for you

Regards,
Biswadip Dutta

On Fri, Apr 13, 2018 at 2:38 AM, POOJA VENKATESH <
poojavenkateshre...@gmail.com> wrote:

> Hi,
>
>
> I am trying to create a new user and password for the server login. The
> user is created in /etc/passwd and also I can see the password entry in
> /etc/shadow however when I try to ssh through the new user I cannot login
> into the server. What steps are missing in the following code?
>
>
>
> ---
> - hosts: local host
>   vars:
> username: random
>   vars_prompt:
> - name: "user_passwd"
>   prompt: "Enter a password for the user"
>   private: yes
>   tasks:
> - name: Add a new user
>   become: yes
>   user:
> name: '{{ username }}'
> shell: /bin/bash
> group: sudo
> state: present
> createhome: yes
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/CAAGG3SAALojkjpgNW%3DcEUt7_wi%
> 2Bdd40CGc_-3LiYJTtYUKaTPA%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] How to sort ansible output

2018-04-13 Thread Biswadip Dutta
I'd suggest you do the sorting part later. I mean after you get the Ansible
results and then sort it.

Regards,
Biswadip Dutta

On Fri, Apr 13, 2018 at 1:12 AM, The Wanderer 
wrote:

> Hi all,
>
> I have a couple of servers that are managed via ansible. On all of them, I
> have got a script - free.sh - that when run, outputs just the free memory,
> like - 5GB. This is not the free system RAM, but a value that's obtained by
> complex calculations done via the script. I can call the script via ansible
> in this manner:
>
> ansible -bK -a "/usr/bin/free.sh" apache-servers
>
> (where apache-servers is the host-group on which I want to run the script)
>
> And here's the limitation that I'm facing - Ansible just returns results
> in the order the job completes. But, I want the result to be sorted
> according to the script's output. Is this possible?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/2090253c-01a4-4db7-abe4-6275615ad826%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEC%3DuX%3Djp8ZidB7MWOaqf3%2BJ7cGTJ5LnaOZh9iiisKA26mJ-Yw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: unable to fit the piece of code in ansible

2018-04-13 Thread Biswadip Dutta
Can you please let me know which Ansible version you are using and what
error you are getting?

Regards,
Biswadip Dutta

On Thu, Apr 12, 2018 at 7:16 PM, Bishwajit Samanta <
bishwajitsamanta1...@gmail.com> wrote:

> Thanks Karl, for your reply. Problem statement ::-
>
> My job is to find out the hostname which belongs to hostclass ess, which
> in this case the answer is host002.
>
> hostinfo:
>   'host001':
> ip: 192.168.43.10
> hostclass: 'puppet'
>   'host002':
> ip: 192.168.43.11
> hostclass: 'ess'
>   'host003':
> ip: 192.168.43.21
> hostclass: 'mdb'
>
>
> i got one solution from some friend in google ansible groups only, but i
> am unable to fit it my ansible playbook.
>
>
> - debug:
> msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto', 
> 'ess')|first|first }}"
>
>
> The playbook i am writing, which is wrong but i am not able to figure out
> how to fit the code in my playbook. Can anyone help me in modifying the
> code of mine.
>
> ---
>
> - hosts: somehost
>   gather_facts: no
>   vars_files:
> file: sometext.yaml
> name: sometext
>
>   - debug:
> msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto', 
> 'ess')|first|first }}
>
>
> On Thursday, April 12, 2018 at 5:52:14 PM UTC+5:30, Karl Auer wrote:
>>
>> Can I suggest that you describe what you want to achieve. That is,
>> describe the end result that you are seeking.
>>
>> That is more likely to get a useful response.
>>
>> Regards, K.
>>
>>
>> On Thu, Apr 12, 2018 at 9:58 PM, Bishwajit Samanta <
>> bishwajits...@gmail.com> wrote:
>>
>>> Any one can suggest any idea please..
>>>
>>> On Thursday, April 12, 2018 at 8:21:32 AM UTC+5:30, Bishwajit Samanta
>>> wrote:

 Hi all,

 I am a beginner in ansible. If anyone can help me in finding the
 answer. It would be great. My problem was finding a phrase in ansible which
 one of the person have helped me. But unfortunately i am not able to fit
 the piece of code in my playbook.

 hostinfo:
   host001':
 ip: 192.168.43.10
 hostclass: 'puppet'
   'host002':
 ip: 192.168.43.11
 hostclass: 'ess'
   'host003':
 ip: 192.168.43.21
 hostclass: 'mdb'

 the code was::

 - debug:
   msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto',
 'ess')|first|first }}"

 Now i am writing the code as given below. I know in this piece of code
 i am making mistakes. But since i am a beginner i am not able to understand
 it. Can anyone help me?

 ---
 - hosts: test
   gather_facts: no

 - debug:
   msg: "{{ hostinfo|dictsort|selectattr('1.hostclass', 'equalto',
 'ess')|first|first }}"

 --
>>> You received this message because you are 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 post to this group, send email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/ansible-project/4431f374-65b9-4884-9acb-f709bdd658f3%
>>> 40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Karl Auer
>>
>> Email  : ka...@2pisoftware.com
>> Website: http://2pisoftware.com
>>
>> GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>> Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/bacee1a5-37a0-423a-9dcf-a8625c361493%40googlegroups.
> com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEC%3DuX%3DgAuY8WkqJFnfoivSU8hu2-0At2WXE%3DWp5j2p%3DzZmAeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.