Re: [ansible-project] Ansible-playbook

2020-04-18 Thread James Cassell


On Sat, Apr 18, 2020, at 6:13 PM, Orkhan Mammadov wrote:
> Hi guys,
> 
> I have created file under /etc/sudoers.d/ directory with this entry: 
> ansible ALL=(ALL) NOPASSWD:ALL and copied to managed hosts in order to 
> install some service such as vsftpd on those hosts.
> 
> I can ssh and install any service with root user, but not with ansible 
> user. It gives the following error while installing service via 
> ansible-playbook command:
> 
> TASK [install vsftpd] 
> **
> fatal: [ansible1]: FAILED! => {"changed": false, "msg": "This command 
> has to be run under the root user.", "results": []}
> 
> 
> Can you please tell me which configs should be made in order to install 
> services on ansible user?
> 

Pass `-b` to your ansible command or add `become: yes` to your playbook.

V/r,
James Cassell

-- 
You received this message because you are 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/6c8126ac-ac88-4e98-bce4-a88408260edb%40www.fastmail.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Karl Auer
TERM=dumb

Sorry, I mistyped. The minus sign should have been an equals sign.

The idea is to set the environment variable TERM to the value "dumb"
immediately before starting the shell in which your program will be run.

Also can you please answer the question about whether you can redirect the
output of this program?

I strongly suggest you experiment manually rather than with Ansible. You
need to find out how to achieve what you want, then duplicate that in
Ansible. Doing both at once is very painful.

Regards, K.

On Sun, Apr 19, 2020 at 2:34 AM Samir Kothawade 
wrote:

> bash: TERM-dumb: command not found.
>
> gnome-terminal utility not available on remote  machine
>
>
> On Sat, 18 Apr 2020 at 21:53, Karl Auer  wrote:
>
>> You *might* be able to convince the console on the remote system to be a
>> dumb terminal by doing this as your command:
>>
>> TERM-dumb ; sh -c your_command
>>
>> This works in gnome-terminal as well - it seems to suppress most control
>> sequences except CR/LF and similar.
>>
>> Or in Ansible, setting the environment variable TERM to "dumb" then
>> running your command in a new shell. In my experiments here, when I set
>> TERM=dumb and ran sh from within a console or from within gnome-terminal,
>> the colourisation went away. However the console still had a fixed number
>> of lines.
>>
>> Regards, K.
>>
>> On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade <
>> kothawade.sa...@gmail.com> wrote:
>>
>>>
>>>
>>> >> Could you please explain how can use xterm command : xterm --tn dumb -cm
>>> -dc -e this is your command
>>>Fustratigly, xterm is not present in remote  machine and I am not
>>> allowed to install xterm utility on targeted remote machine. Still, is
>>> there any way to run it through ansible conroller?
>>>
>>>
>>> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:

 Hi,

 *Here is the brief about scenario: *

 1. login to Debian host machine using ansible
 2. Go to corresponding directory where the binary is and execute that
 binary. (This binary is written in c and C++. After execution it ask for
 the userid & password)
 3. After login into that binary's shell, it  has several commands which
 displays statistics. Those stats are lengthy and does not fit in current
 screen resolution. For seen seeing all the stats we have to press Down
 arrow Key or Enter key multiple time until we reach to last stat line.

 *How I am doing this: *

 *-** hosts: sam*
 *  gather_facts: no*
 *  tasks:*
 *  - name: capture all stats*
 *ignore_errors: yes*
 *expect:*
 *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
 *  responses:*
 *(.*)Username:(.*): "admin"*
 *(.*)Password:(.*): "admin"*
 *(.*)xyz_cli>(.*): display all debug stats*
 *(.*):(.*): ''*
 *register: stats*
 *  - local_action: copy content="{{ stats.stdout}}"
 dest="/home/sam/quickstats/stats.txt"*
 *ignore_errors: yes*


 *Issues Facing : *

 1. Multiple similar line gets copied in stats.txt file when above
 reaches to ==>>*  (.*):(.*): ''*  (See above code section marked in
 blue). Using this method to press  key.
 2. Actual stats counts are of line 500 hundred but above code returns
 2k + stats with repetitive stats and some garbage values appended.
 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above
 script only copies 20-30 lines which currently are displayed on screen or
 which displayed in current screen size.


 I guess I can achieve this by changing remote servers' screen size. but
 I could not able to get any such way in ansible.


 May I request you to help me in this ?

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible-project+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com
>>> 
>>> .
>>>
>>
>>
>> --
>>
>> *Karl Auer* { manager, systems support }
>> P: 1300 759 975
>> E: ka...@2pisoftware.com
>> 2pisoftware.com
>>
>> GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
>> Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
>>
>> --
>> You received this message because you are 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
>> 

[ansible-project] Ansible-playbook

2020-04-18 Thread Orkhan Mammadov
Hi guys,

I have created file under /etc/sudoers.d/ directory with this entry: 
ansible ALL=(ALL) NOPASSWD:ALL and copied to managed hosts in order to 
install some service such as vsftpd on those hosts.

I can ssh and install any service with root user, but not with ansible 
user. It gives the following error while installing service via 
ansible-playbook command:

TASK [install vsftpd] 
**
fatal: [ansible1]: FAILED! => {"changed": false, "msg": "This command has 
to be run under the root user.", "results": []}


Can you please tell me which configs should be made in order to install 
services on ansible user?

Thanks.

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


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread Dick Visser
What does 'ansible --version' say?

On Sat, 18 Apr 2020 at 23:26, Tony Wong  wrote:

> this is what i have. but still not working
>
> On Sat, Apr 18, 2020 at 1:55 PM David Foley  wrote:
>
>> Why Aren't you using your Local Machine using Atom or VS Code to build
>> your Yaml files then using WinSCP copy the playbooks over ?
>>
>> On Saturday, April 18, 2020 at 9:43:00 PM UTC+1, Tony Wong wrote:
>>>
>>> what editor can i use on my ubuntu box? I cant use anything other than
>>> vim.
>>>
>>>
>>> still getting the error.
>>>
>>> tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
>>>  [WARNING]: provided hosts list is empty, only localhost is available.
>>> Note that the implicit localhost does not match 'all'
>>>
>>> ERROR! Syntax Error while loading YAML.
>>>   mapping values are not allowed in this context
>>>
>>> The error appears to be in '/home/tony/ansiblework/info.yml': line 3,
>>> column 8, but may
>>> be elsewhere in the file depending on the exact syntax problem.
>>>
>>> The offending line appears to be:
>>>
>>> name: get info vm
>>>   hosts: localhost
>>>^ here
>>>
>>> On Sat, Apr 18, 2020 at 1:26 PM David Foley  wrote:
>>>
 ---
 - name: get info vm
   hosts: localhost
   connection: local
   gather_facts: false
   tasks:
   - name: get info about the virtual machine
 vmware_guest_info:
   hostname: vcnerter
   username:
   password: 
   datacenter: DC
   validate_certs: False
   name: myvm
   schema: "vsphere"
   properties: ["config.hardware.memoryMB", "guest.disk",
 "overallStatus"]
 delegate_to: localhost
 register: info


 --
 You received this message because you are 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/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.com
 
 .

>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/672cc33a-758f-4083-a48b-0882cb11e453%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CALmkhko58CP5KrYDHK6gBmqdnpqDS0f%2B-Q5hhE37QQ62fHe%2BGQ%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/CAL8fbwMSddLS4fxT1btN%2B99-pz_fZ5M%2BLjhiKoH9c7ZbNwiHOw%40mail.gmail.com.


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread Tony Wong
this is what i have. but still not working

On Sat, Apr 18, 2020 at 1:55 PM David Foley  wrote:

> Why Aren't you using your Local Machine using Atom or VS Code to build
> your Yaml files then using WinSCP copy the playbooks over ?
>
> On Saturday, April 18, 2020 at 9:43:00 PM UTC+1, Tony Wong wrote:
>>
>> what editor can i use on my ubuntu box? I cant use anything other than
>> vim.
>>
>>
>> still getting the error.
>>
>> tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
>>  [WARNING]: provided hosts list is empty, only localhost is available.
>> Note that the implicit localhost does not match 'all'
>>
>> ERROR! Syntax Error while loading YAML.
>>   mapping values are not allowed in this context
>>
>> The error appears to be in '/home/tony/ansiblework/info.yml': line 3,
>> column 8, but may
>> be elsewhere in the file depending on the exact syntax problem.
>>
>> The offending line appears to be:
>>
>> name: get info vm
>>   hosts: localhost
>>^ here
>>
>> On Sat, Apr 18, 2020 at 1:26 PM David Foley  wrote:
>>
>>> ---
>>> - name: get info vm
>>>   hosts: localhost
>>>   connection: local
>>>   gather_facts: false
>>>   tasks:
>>>   - name: get info about the virtual machine
>>> vmware_guest_info:
>>>   hostname: vcnerter
>>>   username:
>>>   password: 
>>>   datacenter: DC
>>>   validate_certs: False
>>>   name: myvm
>>>   schema: "vsphere"
>>>   properties: ["config.hardware.memoryMB", "guest.disk",
>>> "overallStatus"]
>>> delegate_to: localhost
>>> register: info
>>>
>>>
>>> --
>>> You received this message because you are 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/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/672cc33a-758f-4083-a48b-0882cb11e453%40googlegroups.com
> 
> .
>

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


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread David Foley
Why Aren't you using your Local Machine using Atom or VS Code to build your 
Yaml files then using WinSCP copy the playbooks over ? 

On Saturday, April 18, 2020 at 9:43:00 PM UTC+1, Tony Wong wrote:
>
> what editor can i use on my ubuntu box? I cant use anything other than 
> vim. 
>
>
> still getting the error. 
>
> tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
>  [WARNING]: provided hosts list is empty, only localhost is available. 
> Note that the implicit localhost does not match 'all'
>
> ERROR! Syntax Error while loading YAML.
>   mapping values are not allowed in this context
>
> The error appears to be in '/home/tony/ansiblework/info.yml': line 3, 
> column 8, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
> name: get info vm
>   hosts: localhost
>^ here
>
> On Sat, Apr 18, 2020 at 1:26 PM David Foley  > wrote:
>
>> ---
>> - name: get info vm
>>   hosts: localhost
>>   connection: local
>>   gather_facts: false
>>   tasks:
>>   - name: get info about the virtual machine
>> vmware_guest_info:
>>   hostname: vcnerter
>>   username: 
>>   password: 
>>   datacenter: DC
>>   validate_certs: False
>>   name: myvm
>>   schema: "vsphere"
>>   properties: ["config.hardware.memoryMB", "guest.disk", 
>> "overallStatus"]
>> delegate_to: localhost
>> register: info
>>   
>>
>> -- 
>> You received this message because you are 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/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.com
>>  
>> 
>> .
>>
>

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


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread David Foley
you missing* " - " *



On Saturday, April 18, 2020 at 9:46:14 PM UTC+1, Tony Wong wrote:
>
>
>
> On Sat, Apr 18, 2020 at 1:42 PM Tony Wong > 
> wrote:
>
>> what editor can i use on my ubuntu box? I cant use anything other than 
>> vim. 
>>
>>
>> still getting the error. 
>>
>> tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
>>  [WARNING]: provided hosts list is empty, only localhost is available. 
>> Note that the implicit localhost does not match 'all'
>>
>> ERROR! Syntax Error while loading YAML.
>>   mapping values are not allowed in this context
>>
>> The error appears to be in '/home/tony/ansiblework/info.yml': line 3, 
>> column 8, but may
>> be elsewhere in the file depending on the exact syntax problem.
>>
>> The offending line appears to be:
>>
>> name: get info vm
>>   hosts: localhost
>>^ here
>>
>> On Sat, Apr 18, 2020 at 1:26 PM David Foley > > wrote:
>>
>>> ---
>>> - name: get info vm
>>>   hosts: localhost
>>>   connection: local
>>>   gather_facts: false
>>>   tasks:
>>>   - name: get info about the virtual machine
>>> vmware_guest_info:
>>>   hostname: vcnerter
>>>   username: 
>>>   password: 
>>>   datacenter: DC
>>>   validate_certs: False
>>>   name: myvm
>>>   schema: "vsphere"
>>>   properties: ["config.hardware.memoryMB", "guest.disk", 
>>> "overallStatus"]
>>> delegate_to: localhost
>>> register: info
>>>   
>>>
>>> -- 
>>> You received this message because you are 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/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

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


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread Tony Wong
On Sat, Apr 18, 2020 at 1:42 PM Tony Wong  wrote:

> what editor can i use on my ubuntu box? I cant use anything other than
> vim.
>
>
> still getting the error.
>
> tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
>  [WARNING]: provided hosts list is empty, only localhost is available.
> Note that the implicit localhost does not match 'all'
>
> ERROR! Syntax Error while loading YAML.
>   mapping values are not allowed in this context
>
> The error appears to be in '/home/tony/ansiblework/info.yml': line 3,
> column 8, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
> name: get info vm
>   hosts: localhost
>^ here
>
> On Sat, Apr 18, 2020 at 1:26 PM David Foley  wrote:
>
>> ---
>> - name: get info vm
>>   hosts: localhost
>>   connection: local
>>   gather_facts: false
>>   tasks:
>>   - name: get info about the virtual machine
>> vmware_guest_info:
>>   hostname: vcnerter
>>   username:
>>   password: 
>>   datacenter: DC
>>   validate_certs: False
>>   name: myvm
>>   schema: "vsphere"
>>   properties: ["config.hardware.memoryMB", "guest.disk",
>> "overallStatus"]
>> delegate_to: localhost
>> register: info
>>
>>
>> --
>> You received this message because you are 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/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.com
>> 
>> .
>>
>

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


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread Tony Wong
what editor can i use on my ubuntu box? I cant use anything other than vim.


still getting the error.

tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
 [WARNING]: provided hosts list is empty, only localhost is available. Note
that the implicit localhost does not match 'all'

ERROR! Syntax Error while loading YAML.
  mapping values are not allowed in this context

The error appears to be in '/home/tony/ansiblework/info.yml': line 3,
column 8, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

name: get info vm
  hosts: localhost
   ^ here

On Sat, Apr 18, 2020 at 1:26 PM David Foley  wrote:

> ---
> - name: get info vm
>   hosts: localhost
>   connection: local
>   gather_facts: false
>   tasks:
>   - name: get info about the virtual machine
> vmware_guest_info:
>   hostname: vcnerter
>   username:
>   password: 
>   datacenter: DC
>   validate_certs: False
>   name: myvm
>   schema: "vsphere"
>   properties: ["config.hardware.memoryMB", "guest.disk",
> "overallStatus"]
> delegate_to: localhost
> register: info
>
>
> --
> You received this message because you are 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/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.com
> 
> .
>

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


[ansible-project] Module name not misspelled, but didn't exist yet

2020-04-18 Thread Dick Visser
Hi

The "misspelled module name" issue seems to be a recurring one.
In the majority of cases the spelling is actually correct, it's just
that that  module didn't exist yet in the version of ansible that
raises the error.
These days the error is slightly improved:
https://github.com/ansible/ansible/blob/devel/lib/ansible/parsing/mod_args.py#L306-L315

Would it be an idea to extended that wording to include something
along the lines of:

"or this module was introduced in a future version - check
https://docs.ansible.com/ansible/latest/modules/.html and
upgrade to be able to use it"

I realise this doesn't help any versions out there now, but it would
be of help for future versions.


thx


-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

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


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread David Foley
---
- name: get info vm
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
  - name: get info about the virtual machine
vmware_guest_info:
  hostname: vcnerter
  username: 
  password: 
  datacenter: DC
  validate_certs: False
  name: myvm
  schema: "vsphere"
  properties: ["config.hardware.memoryMB", "guest.disk", "overallStatus"
]
delegate_to: localhost
register: info
  

-- 
You received this message because you are 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/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.com.


[ansible-project] Re: Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread David Foley
hosts: localhost
  gather_facts: false
  tasks:
  - vmware_guest_info:
  hostname:  "{{ vcenter_hostname }}"
  username: eu\wavesservice
  password: GHb!DW|79Z5i
  validate_certs: no
  datacenter: Test
  name: "{{ VM_Name }}"
  schema: "vsphere"
  properties: ["runtime.powerState"]
delegate_to: localhost
register: vminfo

  - debug:
  var: vminfo

  - vmware_guest_powerstate:
  validate_certs: no
  hostname: "{{ vcenter_hostname }}"
  username: eu\wavesservice
  password: GHb!DW|79Z5i
  name: "{{ VM_Name }}"
  state: powered-off
delegate_to: localhost
when: vminfo != "poweredOff"


  - name: Deleting The Virutal Machine
vmware_guest:
  hostname:  "{{ vcenter_hostname }}"
  username: eu\wavesservice
  password: GHb!DW|79Z5i
  validate_certs: no
  cluster: "{{ cluster_name }}"
  name: "{{ VM_Name }}"
  state: absent
delegate_to: localhost
register: facts


---
- name: get info vm
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
  - name: get info about the virtual machine
vmware_guest_info:
  hostname: vcnerter
  username: 
  password: 
  datacenter: DC
  validate_certs: False
  name: myvm
  schema: "vsphere"
  properties: ["config.hardware.memoryMB", "guest.disk", "overallStatus"
]
delegate_to: localhost
register: info
  

-- 
You received this message because you are 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/05188019-3473-41eb-ba7a-1984ab313e81%40googlegroups.com.


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread Jean-Yves LENHOF

Please as said by another people here, respect indentations stricly !

vmware_guest_info& name have not the same indentation as written by A. 
Kasurde


Regards,

JYL


Le 18/04/2020 à 22:14, Tony Wong a écrit :

this is the playbook

---
- name: get info vm
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - name: get info about the virtual machine
        vmware_guest_info:
          hostname: vcnerter
          username: administrator@vsphere.local
          password: 
          validate_certs: False
          name: myvm
          schema: "vsphere"
          properties: ["config.hardware.memoryMB", "guest.disk", 
"overallStatus"]

          datacenter: DC
          register: info

On Sat, Apr 18, 2020 at 1:11 PM Dick Visser > wrote:


That module was introduced in ansible 2.5:

https://docs.ansible.com/ansible/latest/modules/vmware_guest_powerstate_module.html

Do you run an older version?



On Sat, 18 Apr 2020 at 20:22, Tony Wong mailto:tdubb...@gmail.com>> wrote:

Hi

why is it when i run this playbook I get this error

tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
 [WARNING]: provided hosts list is empty, only localhost is
available. Note that the implicit localhost does not match 'all'

ERROR! no action detected in task. This often indicates a
misspelled module name, or incorrect module path.

The error appears to be in
'/home/tony/ansiblework/vmware_tools.yml': line 9, column 5,
but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
  - name: Get information about the virtual machine
    ^ here

-- 
You received this message because you are subscribed to the

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

https://groups.google.com/d/msgid/ansible-project/201e9930-5b7d-432e-b801-d19070f1c81d%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/CAL8fbwNCN3M5sh3H%3D4rFgO3d1TRXogadBjxd4CnyQCn%2BeG%3DANg%40mail.gmail.com

.

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


--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7a8b6085-680e-646b-e670-832463387686%40lenhof.eu.org.


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread Tony Wong
this is the playbook

---
- name: get info vm
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
- name: get info about the virtual machine
vmware_guest_info:
  hostname: vcnerter
  username: administrator@vsphere.local
  password: 
  validate_certs: False
  name: myvm
  schema: "vsphere"
  properties: ["config.hardware.memoryMB", "guest.disk",
"overallStatus"]
  datacenter: DC
  register: info

On Sat, Apr 18, 2020 at 1:11 PM Dick Visser  wrote:

> That module was introduced in ansible 2.5:
>
> https://docs.ansible.com/ansible/latest/modules/vmware_guest_powerstate_module.html
>
> Do you run an older version?
>
>
>
> On Sat, 18 Apr 2020 at 20:22, Tony Wong  wrote:
>
>> Hi
>>
>> why is it when i run this playbook I get this error
>>
>> tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
>>  [WARNING]: provided hosts list is empty, only localhost is available.
>> Note that the implicit localhost does not match 'all'
>>
>> ERROR! no action detected in task. This often indicates a misspelled
>> module name, or incorrect module path.
>>
>> The error appears to be in '/home/tony/ansiblework/vmware_tools.yml':
>> line 9, column 5, but may
>> be elsewhere in the file depending on the exact syntax problem.
>>
>> The offending line appears to be:
>>
>>   tasks:
>>   - name: Get information about the virtual machine
>> ^ here
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/201e9930-5b7d-432e-b801-d19070f1c81d%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/CAL8fbwNCN3M5sh3H%3D4rFgO3d1TRXogadBjxd4CnyQCn%2BeG%3DANg%40mail.gmail.com
> 
> .
>

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


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread Dick Visser
That module was introduced in ansible 2.5:
https://docs.ansible.com/ansible/latest/modules/vmware_guest_powerstate_module.html

Do you run an older version?



On Sat, 18 Apr 2020 at 20:22, Tony Wong  wrote:

> Hi
>
> why is it when i run this playbook I get this error
>
> tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
>  [WARNING]: provided hosts list is empty, only localhost is available.
> Note that the implicit localhost does not match 'all'
>
> ERROR! no action detected in task. This often indicates a misspelled
> module name, or incorrect module path.
>
> The error appears to be in '/home/tony/ansiblework/vmware_tools.yml': line
> 9, column 5, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>   tasks:
>   - name: Get information about the virtual machine
> ^ here
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/201e9930-5b7d-432e-b801-d19070f1c81d%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/CAL8fbwNCN3M5sh3H%3D4rFgO3d1TRXogadBjxd4CnyQCn%2BeG%3DANg%40mail.gmail.com.


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread Jorge Rúa
That error message often indicates an indentation issue or a missing module
parameter.

On Sat, Apr 18, 2020, 20:22 Tony Wong  wrote:

> Hi
>
> why is it when i run this playbook I get this error
>
> tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
>  [WARNING]: provided hosts list is empty, only localhost is available.
> Note that the implicit localhost does not match 'all'
>
> ERROR! no action detected in task. This often indicates a misspelled
> module name, or incorrect module path.
>
> The error appears to be in '/home/tony/ansiblework/vmware_tools.yml': line
> 9, column 5, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>   tasks:
>   - name: Get information about the virtual machine
> ^ here
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/201e9930-5b7d-432e-b801-d19070f1c81d%40googlegroups.com
> 
> .
>

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


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-18 Thread Tony Wong
Hi

why is it when i run this playbook I get this error

tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
 [WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'

ERROR! no action detected in task. This often indicates a misspelled module 
name, or incorrect module path.

The error appears to be in '/home/tony/ansiblework/vmware_tools.yml': line 
9, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
  - name: Get information about the virtual machine
^ here

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


Re: [ansible-project] Try to put 1 Ansible facts from multiple servers into one list

2020-04-18 Thread Gregory Skelton
Many thanks, I'll give it a try. 

Greg

On Saturday, April 18, 2020 at 2:43:16 AM UTC-5, Stefan Hornburg (Racke) 
wrote:
>
> On 4/18/20 1:57 AM, Gregory Skelton wrote: 
> > I feel this should be easy.  
> > 
> > I'm trying to put a fact I set on each server into one central list.  
> > sat_id is the Big List 
> > sat_id_raw is the variable that I set earlier in the automation.  
> > 
> > What am I missing here? 
> > Thanks in advance 
> > 
>
> Try "{{ sat_id + sat_id_raw }}" if sat_id_raw is a list, "{{ sat_id + 
> [sat_id_raw] }}" if sat_id_raw is 
> a single value. 
>
> Regards 
>   Racke 
>
>
> > name: Put all of the var into a big list 
> > 
> >   set_fact: 
> > 
> > sat_id: "{{ sat_id }} + ['{{ sat_id_raw }}']" 
> > 
> >   delegate_to: localhost 
> > 
> > __ __ 
> > 
> > - name: Print object type 
> > 
> >   debug: 
> > 
> > var: sat_id 
> > 
> >   delegate_to: localhost 
> > 
> > __ __ 
> > 
> > __ __ 
> > 
> > TASK [Facts-list : Put all of the vars into a big list] 
> > 
> *
>  
>
> > 
> > ok: [MY-SERVER1 -> localhost] => { 
> > 
> > "ansible_facts": { 
> > 
> > "sat_id": [ 
> > 
> > "15929" 
> > 
> > ] 
> > 
> > }, 
> > 
> > "changed": false 
> > 
> > } 
> > 
> > ok: [MY-SERVER2 -> localhost] => { 
> > 
> > "ansible_facts": { 
> > 
> > "sat_id": [ 
> > 
> > "13409" 
> > 
> > ] 
> > 
> > }, 
> > 
> > "changed": false 
> > 
> > } 
> > 
> > __ __ 
> > 
> > TASK [Facts-list : Print object type] 
> > 
> ***
>  
>
> > 
> > task path: 
> /data/grskelt/satellite-devel/satellite-contentviews-list/tasks/main.yml:96
>  
>
> > 
> > ok: [MY-SERVER1 -> localhost] => { 
> > 
> > "sat_id": [ 
> > 
> > "15929" 
> > 
> > ] 
> > 
> > } 
> > 
> > ok: [MY-SERVER2 -> localhost] => { 
> > 
> > "sat_id": [ 
> > 
> > "13409" 
> > 
> > ] 
> > 
> > 
> > -- 
> > You received this message because you are 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/829bacc7-12b8-439d-8770-7cf956da2e9c%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/829bacc7-12b8-439d-8770-7cf956da2e9c%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/252caa64-b50d-4de7-8db2-453fbb78567a%40googlegroups.com.


Re: [ansible-project] Task Status at Playbook runtime

2020-04-18 Thread Ashish Sagar
Sure, By default, Ansible playbook executes tasks in sequence and summarize
task results at last. With this approach, it shows each task status on
running playbook verbose logs.

Question is,  Is there anyway to get task status like failed, changed etc
during playbook runtime (without parsing logs) ? I know this can be
achieved in async mode but my requirement is to keep executing task in
sequence.

Thanks.

On Sat, Apr 18, 2020, 20:53 Stefan Hornburg (Racke) 
wrote:

> On 4/18/20 4:24 PM, Ashish Sagar wrote:
> > Hi Folks,
> >
> > Is there anyway to get specific Task status like Changed, ignored or
> failed during Playbook runtime in synchronous mode ?
> >
> >
> > Thanks
> > Ashish
>
> Sorry, but your question is not clear. Please elaborate and/or illustrate
> it with an example.
>
> 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/CADa6Y5abqHGma96mnx9VbXLwf-QZndxSPTanMrbXFObXKdUFRQ%40mail.gmail.com
> > <
> https://groups.google.com/d/msgid/ansible-project/CADa6Y5abqHGma96mnx9VbXLwf-QZndxSPTanMrbXFObXKdUFRQ%40mail.gmail.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/2d22c5e7-63ef-52ff-68f4-ad659f04564a%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/CADa6Y5YOD130WiT6DPBfSJn46YhcDSR33SQxT%3D7faZjKUc_WEQ%40mail.gmail.com.


Re: [ansible-project] Task Status at Playbook runtime

2020-04-18 Thread Jean-Yves LENHOF

Hi,

Register a variable for the module you call and after test this variable...

More info here :

https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#rc

Example on a change (first link in google) :

https://raymii.org/s/tutorials/Ansible_-_Only-do-something-if-another-action-changed.html

Regards,

Le 18/04/2020 à 16:24, Ashish Sagar a écrit :

Hi Folks,

Is there anyway to get specific Task status like Changed, ignored or 
failed during Playbook runtime in synchronous mode ?



Thanks
Ashish
--
You received this message because you are 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/CADa6Y5abqHGma96mnx9VbXLwf-QZndxSPTanMrbXFObXKdUFRQ%40mail.gmail.com 
.


--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/29f68960-0c90-2885-15db-54d00c637a12%40lenhof.eu.org.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Samir Kothawade
bash: TERM-dumb: command not found.

gnome-terminal utility not available on remote  machine


On Sat, 18 Apr 2020 at 21:53, Karl Auer  wrote:

> You *might* be able to convince the console on the remote system to be a
> dumb terminal by doing this as your command:
>
> TERM-dumb ; sh -c your_command
>
> This works in gnome-terminal as well - it seems to suppress most control
> sequences except CR/LF and similar.
>
> Or in Ansible, setting the environment variable TERM to "dumb" then
> running your command in a new shell. In my experiments here, when I set
> TERM=dumb and ran sh from within a console or from within gnome-terminal,
> the colourisation went away. However the console still had a fixed number
> of lines.
>
> Regards, K.
>
> On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade 
> wrote:
>
>>
>>
>> >> Could you please explain how can use xterm command : xterm --tn dumb -cm
>> -dc -e this is your command
>>Fustratigly, xterm is not present in remote  machine and I am not
>> allowed to install xterm utility on targeted remote machine. Still, is
>> there any way to run it through ansible conroller?
>>
>>
>> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>>
>>> Hi,
>>>
>>> *Here is the brief about scenario: *
>>>
>>> 1. login to Debian host machine using ansible
>>> 2. Go to corresponding directory where the binary is and execute that
>>> binary. (This binary is written in c and C++. After execution it ask for
>>> the userid & password)
>>> 3. After login into that binary's shell, it  has several commands which
>>> displays statistics. Those stats are lengthy and does not fit in current
>>> screen resolution. For seen seeing all the stats we have to press Down
>>> arrow Key or Enter key multiple time until we reach to last stat line.
>>>
>>> *How I am doing this: *
>>>
>>> *-** hosts: sam*
>>> *  gather_facts: no*
>>> *  tasks:*
>>> *  - name: capture all stats*
>>> *ignore_errors: yes*
>>> *expect:*
>>> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>>> *  responses:*
>>> *(.*)Username:(.*): "admin"*
>>> *(.*)Password:(.*): "admin"*
>>> *(.*)xyz_cli>(.*): display all debug stats*
>>> *(.*):(.*): ''*
>>> *register: stats*
>>> *  - local_action: copy content="{{ stats.stdout}}"
>>> dest="/home/sam/quickstats/stats.txt"*
>>> *ignore_errors: yes*
>>>
>>>
>>> *Issues Facing : *
>>>
>>> 1. Multiple similar line gets copied in stats.txt file when above
>>> reaches to ==>>*  (.*):(.*): ''*  (See above code section marked in
>>> blue). Using this method to press  key.
>>> 2. Actual stats counts are of line 500 hundred but above code returns 2k
>>> + stats with repetitive stats and some garbage values appended.
>>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above
>>> script only copies 20-30 lines which currently are displayed on screen or
>>> which displayed in current screen size.
>>>
>>>
>>> I guess I can achieve this by changing remote servers' screen size. but
>>> I could not able to get any such way in ansible.
>>>
>>>
>>> May I request you to help me in this ?
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com
>> 
>> .
>>
>
>
> --
>
> *Karl Auer* { manager, systems support }
> P: 1300 759 975
> E: ka...@2pisoftware.com
> 2pisoftware.com
>
> GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
> Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
>
> --
> You received this message because you are 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%2B%2BT08SQ_etTQUJ%2BfTYMb1Jn-u-rd8m4BTJBnaoFhOf%2BL70Fbg%40mail.gmail.com
> 
> .
>

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


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Karl Auer
You *might* be able to convince the console on the remote system to be a
dumb terminal by doing this as your command:

TERM-dumb ; sh -c your_command

This works in gnome-terminal as well - it seems to suppress most control
sequences except CR/LF and similar.

Or in Ansible, setting the environment variable TERM to "dumb" then running
your command in a new shell. In my experiments here, when I set TERM=dumb
and ran sh from within a console or from within gnome-terminal, the
colourisation went away. However the console still had a fixed number of
lines.

Regards, K.

On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade 
wrote:

>
>
> >> Could you please explain how can use xterm command : xterm --tn dumb -cm
> -dc -e this is your command
>Fustratigly, xterm is not present in remote  machine and I am not
> allowed to install xterm utility on targeted remote machine. Still, is
> there any way to run it through ansible conroller?
>
>
> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>
>> Hi,
>>
>> *Here is the brief about scenario: *
>>
>> 1. login to Debian host machine using ansible
>> 2. Go to corresponding directory where the binary is and execute that
>> binary. (This binary is written in c and C++. After execution it ask for
>> the userid & password)
>> 3. After login into that binary's shell, it  has several commands which
>> displays statistics. Those stats are lengthy and does not fit in current
>> screen resolution. For seen seeing all the stats we have to press Down
>> arrow Key or Enter key multiple time until we reach to last stat line.
>>
>> *How I am doing this: *
>>
>> *-** hosts: sam*
>> *  gather_facts: no*
>> *  tasks:*
>> *  - name: capture all stats*
>> *ignore_errors: yes*
>> *expect:*
>> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>> *  responses:*
>> *(.*)Username:(.*): "admin"*
>> *(.*)Password:(.*): "admin"*
>> *(.*)xyz_cli>(.*): display all debug stats*
>> *(.*):(.*): ''*
>> *register: stats*
>> *  - local_action: copy content="{{ stats.stdout}}"
>> dest="/home/sam/quickstats/stats.txt"*
>> *ignore_errors: yes*
>>
>>
>> *Issues Facing : *
>>
>> 1. Multiple similar line gets copied in stats.txt file when above reaches
>> to ==>>*  (.*):(.*): ''*  (See above code section marked in blue). Using
>> this method to press  key.
>> 2. Actual stats counts are of line 500 hundred but above code returns 2k
>> + stats with repetitive stats and some garbage values appended.
>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above
>> script only copies 20-30 lines which currently are displayed on screen or
>> which displayed in current screen size.
>>
>>
>> I guess I can achieve this by changing remote servers' screen size. but I
>> could not able to get any such way in ansible.
>>
>>
>> May I request you to help me in this ?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com
> 
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are 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%2B%2BT08SQ_etTQUJ%2BfTYMb1Jn-u-rd8m4BTJBnaoFhOf%2BL70Fbg%40mail.gmail.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Karl Auer
What shell are you using on the remote machine? And what kind of terminal
is it running in? I have a suspicion that it is just running on a pty, and
that your program is blindly putting out control sequences. If it is, then
there's nothing you can do about it except strip them using regexp or
similar.

Is there any way to redirect the output from your program into a file? That
bypasses the terminal stuff completely , though as I said, if your program
is blindly colourising its output OR blindly waiting after every 24 lines,
there's nothing much you can do about it. The duplicate output is strange -
can you provide a sample? It may be the program trying to output bold text
or something.

Right about now I would be contacting the people responsible for a) the
Debian host and b) this program you are trying to run to see if there is
some way to solve this problem neatly.

Were you able to find out about possible additional command line controls
on the program? Anything Ansible can do, you can do too, so try manually
logging in and seeing what you can find out.

Regards, K.


On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade 
wrote:

>
>
> >> Could you please explain how can use xterm command : xterm --tn dumb -cm
> -dc -e this is your command
>Fustratigly, xterm is not present in remote  machine and I am not
> allowed to install xterm utility on targeted remote machine. Still, is
> there any way to run it through ansible conroller?
>
>
> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>
>> Hi,
>>
>> *Here is the brief about scenario: *
>>
>> 1. login to Debian host machine using ansible
>> 2. Go to corresponding directory where the binary is and execute that
>> binary. (This binary is written in c and C++. After execution it ask for
>> the userid & password)
>> 3. After login into that binary's shell, it  has several commands which
>> displays statistics. Those stats are lengthy and does not fit in current
>> screen resolution. For seen seeing all the stats we have to press Down
>> arrow Key or Enter key multiple time until we reach to last stat line.
>>
>> *How I am doing this: *
>>
>> *-** hosts: sam*
>> *  gather_facts: no*
>> *  tasks:*
>> *  - name: capture all stats*
>> *ignore_errors: yes*
>> *expect:*
>> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>> *  responses:*
>> *(.*)Username:(.*): "admin"*
>> *(.*)Password:(.*): "admin"*
>> *(.*)xyz_cli>(.*): display all debug stats*
>> *(.*):(.*): ''*
>> *register: stats*
>> *  - local_action: copy content="{{ stats.stdout}}"
>> dest="/home/sam/quickstats/stats.txt"*
>> *ignore_errors: yes*
>>
>>
>> *Issues Facing : *
>>
>> 1. Multiple similar line gets copied in stats.txt file when above reaches
>> to ==>>*  (.*):(.*): ''*  (See above code section marked in blue). Using
>> this method to press  key.
>> 2. Actual stats counts are of line 500 hundred but above code returns 2k
>> + stats with repetitive stats and some garbage values appended.
>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above
>> script only copies 20-30 lines which currently are displayed on screen or
>> which displayed in current screen size.
>>
>>
>> I guess I can achieve this by changing remote servers' screen size. but I
>> could not able to get any such way in ansible.
>>
>>
>> May I request you to help me in this ?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com
> 
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are 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%2B%2BT08SY0hyWapjMvWv%3DGFx92QDZVyZT1Fk59S0MBrbDnRN%2Bkw%40mail.gmail.com.


Re: [ansible-project] Task Status at Playbook runtime

2020-04-18 Thread Stefan Hornburg (Racke)
On 4/18/20 4:24 PM, Ashish Sagar wrote:
> Hi Folks,
> 
> Is there anyway to get specific Task status like Changed, ignored or failed 
> during Playbook runtime in synchronous mode ?
> 
> 
> Thanks
> Ashish

Sorry, but your question is not clear. Please elaborate and/or illustrate it 
with an example.

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/CADa6Y5abqHGma96mnx9VbXLwf-QZndxSPTanMrbXFObXKdUFRQ%40mail.gmail.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/2d22c5e7-63ef-52ff-68f4-ad659f04564a%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Samir Kothawade


>> Could you please explain how can use xterm command : xterm --tn dumb -cm 
-dc -e this is your command
   Fustratigly, xterm is not present in remote  machine and I am not 
allowed to install xterm utility on targeted remote machine. Still, is 
there any way to run it through ansible conroller?


On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>
> Hi, 
>
> *Here is the brief about scenario: *
>
> 1. login to Debian host machine using ansible
> 2. Go to corresponding directory where the binary is and execute that 
> binary. (This binary is written in c and C++. After execution it ask for 
> the userid & password) 
> 3. After login into that binary's shell, it  has several commands which 
> displays statistics. Those stats are lengthy and does not fit in current 
> screen resolution. For seen seeing all the stats we have to press Down 
> arrow Key or Enter key multiple time until we reach to last stat line.
>
> *How I am doing this: *
>
> *-** hosts: sam*
> *  gather_facts: no*
> *  tasks:*
> *  - name: capture all stats*
> *ignore_errors: yes*
> *expect:*
> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
> *  responses:*
> *(.*)Username:(.*): "admin"*
> *(.*)Password:(.*): "admin"*
> *(.*)xyz_cli>(.*): display all debug stats*
> *(.*):(.*): ''* 
> *register: stats*
> *  - local_action: copy content="{{ stats.stdout}}" 
> dest="/home/sam/quickstats/stats.txt"*
> *ignore_errors: yes*
> 
>
> *Issues Facing : *
>
> 1. Multiple similar line gets copied in stats.txt file when above reaches 
> to ==>>*  (.*):(.*): ''*  (See above code section marked in blue). Using 
> this method to press  key.  
> 2. Actual stats counts are of line 500 hundred but above code returns 2k + 
> stats with repetitive stats and some garbage values appended.
> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above 
> script only copies 20-30 lines which currently are displayed on screen or 
> which displayed in current screen size. 
>
>
> I guess I can achieve this by changing remote servers' screen size. but I 
> could not able to get any such way in ansible. 
>
>
> May I request you to help me in this ?
>

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


Re: [ansible-project] Failed to lock apt for exclusive operation

2020-04-18 Thread Dick Visser
On Sat, 18 Apr 2020 at 15:41, George James  wrote:
>
> Okay, sorry I am new to Ansible and all this is a bit confusing.
>
> How do I set the super password, because now I change it to root, and even 
> though I use the flag --ask-pass and pass in the password I now get the error 
> `Missing sudo password`

Not sure what a "super password" is - but it indicates that you might
not have read the dedicated web page on Privilege escalation.
I would suggest doing that though:
https://docs.ansible.com/ansible/latest/user_guide/become.html.


-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

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


[ansible-project] Task Status at Playbook runtime

2020-04-18 Thread Ashish Sagar
Hi Folks,

Is there anyway to get specific Task status like Changed, ignored or failed
during Playbook runtime in synchronous mode ?


Thanks
Ashish

-- 
You received this message because you are 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/CADa6Y5abqHGma96mnx9VbXLwf-QZndxSPTanMrbXFObXKdUFRQ%40mail.gmail.com.


Re: [ansible-project] Failed to lock apt for exclusive operation

2020-04-18 Thread Stefan Hornburg (Racke)
On 4/18/20 3:41 PM, George James wrote:
> Okay, sorry I am new to Ansible and all this is a bit confusing.
> 
> How do I set the super password, because now I change it to root, and even 
> though I use the flag --ask-pass and pass in
> the password I now get the error `Missing sudo password`
> 

Hello George,

--ask-pass is for the SSH connection, --ask-become-pass for Sudo password.

Regards
 Racke

> |
> -name:InstallNginxUbuntu
>   hosts:web
>   remote_user:"{{ NGINX_USER }}"
>   become:yes
>   become_method:sudo
>   become_user:root
>   connection:ssh
>   gather_facts:no
>   vars:
>     NGINX_VERSION:nginx-1.17.10
>     NGINX_SBIN_PATH:/usr/sbin/
>     NGINX_ERROR_LOG_PATH:/var/log/nginx/error.log
>     NGINX_HTTP_LOG_PATH:/var/log/nginx/access.log
>     NGINX_PID_PATH:/var/run/nginx.pid
>   vars_files:
>     -../vars/global.yaml
>   tasks:
>     -name:CheckifNginxExists
>       stat:path=/etc/init.d/nginx
>       register:nginx_status
>       become:yes
>     -name:Stopnginx Service
>       service:name=nginx state=stopped
>       when:nginx_status.stat.exists
>       register:service_stopped
>     -name:Makesure a systemd isnotrunning
>       systemd:
>         state:stopped
>         name:nginx
>     -name:Installaptitude usingapt
>       apt:
>         name:aptitude
>         state:latest
>         update_cache:yes
>         force_apt_get:yes
> |
> 
> And I run with this playbook with the command 
> 
> |
> ansible-playbook nginx_ubuntu_18_04/playbook.yaml -i hosts --ask-pass
> |
> 
> But I now get the error 
> 
> |
> TASK [Check if Nginx Exists]
> 
> fatal: [142.93.15.195]: FAILED! => {"msg": "Missing sudo password"}
> |
> 
> 
> 
> On Saturday, April 18, 2020 at 5:25:04 PM UTC+4, Stefan Hornburg (Racke) 
> wrote:
> 
> On 4/18/20 3:13 PM, George James wrote:
> > Hi Stefan, I have attached my playbook below
> >
> >
> 
> Hello George,
> 
> you need to be superuser to install APT packages, but your become_user is 
> "{{ NGINX_USER }}" which
> is probably not root.
> 
> Regards
>        Racke
> 
> > |
> >
> >
> > -name:InstallNginxUbuntu
> >   hosts:web
> >   remote_user:"{{ NGINX_USER }}"
> >   become:yes
> >   become_method:sudo
> >   become_user:"{{ NGINX_USER }}"
> >   connection:ssh
> >   gather_facts:no
> >   vars:
> >     NGINX_VERSION:nginx-1.17.10
> >     NGINX_SBIN_PATH:/usr/sbin/
> >     NGINX_ERROR_LOG_PATH:/var/log/nginx/error.log
> >     NGINX_HTTP_LOG_PATH:/var/log/nginx/access.log
> >     NGINX_PID_PATH:/var/run/nginx.pid
> >   vars_files:
> >     -../vars/global.yaml
> >   tasks:
> >     -name:CheckifNginxExists
> >       stat:path=/etc/init.d/nginx
> >       register:nginx_status
> >       become:yes
> >     -name:Stopnginx Service
> >       service:name=nginx state=stopped
> >       when:nginx_status.stat.exists
> >       register:service_stopped
> >     -name:Makesure a systemd isnotrunning
> >       systemd:
> >         state:stopped
> >         name:nginx
> >     -name:Installaptitude usingapt
> >       apt:
> >         name:aptitude
> >         state:latest
> >         update_cache:yes
> >         force_apt_get:yes
> >     -name:Updateapt repo
> >       apt:
> >         update_cache:yes
> >         cache_valid_time:3600
> >     -name:Installrequired system packages
> >       apt:name={{item }}state=latest update_cache=yes
> >       loop:
> >         [
> >           "build-essential",
> >           "libpcre3",
> >           "libpcre3-dev",
> >           "zlib1g",
> >           "zlib1g-dev",
> >           "libssl-dev",
> >         ]
> > |
> >
> >
> >
> >
> > On Saturday, April 18, 2020 at 4:42:09 PM UTC+4, Stefan Hornburg 
> (Racke) wrote:
> >
> >     On 4/18/20 2:05 PM, George James wrote:
> >     > I create a new user using ansible called `nginx`, `nginx` is part 
> of the sudo group a, but when I try to do
> an apt
> >     > install with this user I get the below error 
> >     >
> >     > ```
> >     > : FAILED! => {"changed": false, "msg": "Failed to lock apt for 
> exclusive operation"}
> >     > ```
> >     >
> >     > What is the cause of the error and how can it be fixed?
> >
> >     Please show your playbook.
> >
> >     Regards
> >               Racke
> >
> >     >
> >     > --
> >     > You received this message because you are subscribed to the 
> Google Groups "Ansible Project" group.
> >     > To unsubscribe from this group and stop receiving emails from it, 
> send an email to
> >     > ansible...@googlegroups.com  
> 

Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Samir Kothawade
H[i, I tried with stty but that could  not help. output remained the same.

Here is how i used that : 


- hosts: opr
  gather_facts: no
  tasks:
  - name: set the winsize
shell: stty cols 500 rows 500
  - name: Get the debug status
ignore_errors: yes
   
...and kept rest script same.


On Saturday, 18 April 2020 15:33:20 UTC+5:30, Stefan Hornburg (Racke) wrote:
>
> On 4/18/20 11:50 AM, Samir Kothawade wrote: 
> > Also, There is a limitation on remote host - It does not have xrandr 
> module. So, changing screen size with xrandr will 
> > not be  available :( 
>
> You need to configure the size of the remote terminal, so xrandr won't be 
> the correct tool. So you can try 
> to manipulate the terminal with shell commands (resize, stty). 
>
> But I wonder why you can't tell this binary to write output in a file. 
>
> Regards 
>  Racke 
>
> > 
> > On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote: 
> > 
> > Hi,  
> > 
> > *_Here is the brief about scenario: _* 
> > 
> > 1. login to Debian host machine using ansible 
> > 2. Go to corresponding directory where the binary is and execute 
> that binary. (This binary is written in c and C++. 
> > After execution it ask for the userid & password)  
> > 3. After login into that binary's shell, it  has several commands 
> which displays statistics. Those stats are lengthy 
> > and does not fit in current screen resolution. For seen seeing all 
> the stats we have to press Down arrow Key or 
> > Enter key multiple time until we reach to last stat line. 
> > 
> > _*How I am doing this: *_ 
> > 
> > /-//hosts: sam/ 
> > /  gather_facts: no/ 
> > /  tasks:/ 
> > /  - name: capture all stats/ 
> > /ignore_errors: yes/ 
> > /expect:/ 
> > /  command: /opt/abc/xyz_Platform/bin/go_xyz_cli/ 
> > /  responses:/ 
> > /(.*)Username:(.*): "admin"/ 
> > /(.*)Password:(.*): "admin"/ 
> > /(.*)xyz_cli>(.*): display all debug stats/ 
> > /  *  (.*):(.*): ''*//* */ 
> > /register: stats/ 
> > /  - local_action: copy content="{{ stats.stdout}}" 
> dest="/home/sam/quickstats/stats.txt"/ 
> > /ignore_errors: yes/ 
> >  
> > 
> > *_Issues Facing : _* 
> > 
> > 1. Multiple similar line gets copied in stats.txt file when above 
> reaches to ==>>/  *(.*):(.*): ''*//* */ (See above 
> > code section marked in blue). Using this method to press  
> key.   
> > 2. Actual stats counts are of line 500 hundred but above code 
> returns 2k + stats with repetitive stats and some 
> > garbage values appended. 
> > 3. If i removes this  portion /*  (.*):(.*): ''*/ from code, then 
> above script only copies 20-30 lines which 
> > currently are displayed on screen or which displayed in current 
> screen size.  
> > 
> > 
> > I guess I can achieve this by changing remote servers' screen size. 
> but I could not able to get any such way in 
> > ansible.  
> > 
> > 
> > May I request you to help me in this ? 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to 
> > ansible...@googlegroups.com   ansible-project+unsubscr...@googlegroups.com >. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/1ee2dc0f-11c5-4644-b1fb-dec87ade59ed%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/1ee2dc0f-11c5-4644-b1fb-dec87ade59ed%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/11d7662e-9c91-4626-b274-72f39a772cf2%40googlegroups.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Samir Kothawade
As shown, there is some garbage data coming that file, we can remove that 
using regex. My initial objective it to capture all 500 stats lines in 
variable - stats
 
On Saturday, 18 April 2020 19:08:32 UTC+5:30, Samir Kothawade wrote:
>
>
>
> On Saturday, 18 April 2020 15:46:06 UTC+5:30, Karl Auer wrote:
>>
>> How exactly are the stats output on the host?
>>
>
> *Actual Output received in stats.txt file though method which is I am 
> using.*
>
>   "OPR>display debug info PP ip 192.168.30.26 port 8686 data", 
> "\u001b[H\u001b[JSending command to get debug data from {
> 192.168.30.26:8686} PP", 
> "", 
> " Current counters in PP:", 
> "", 
> "Data Counters Summary:", 
> "\u001b[5GTotal Pkt Received\u001b[6;49H{ 10202784 PPS }", 
> "\u001b[7G3G pkt Rvcd\u001b[7;49H{ 5101392 PPS }", 
> "\u001b[7G4G pkt Rvcd\u001b[8;49H{ 0 PPS }", 
> "\u001b[7Gunknown rat type pkt Rvcd\u001b[9;49H{ 5101392 PPS }", 
> "\u001b[5GArp-Rsp Pkt Drop\u001b[10;49H{ 0 PPS }", 
> "\u001b[5GArp-Req Pkt process\u001b[11;49H{ 549683392 PPS }", 
> "\u001b[5GICMP-Req Pkt process\u001b[12;49H{ 32765 PPS }", 
> "", 
>
> *Note: there are 2K lines below (as I described in my initial comment)*
>
> *Expected results -- or output displayed when we hit the command manually.*
>
>  Current counters in PP:
>
> Data Counters Summary:
> Total Pkt Received  { 10202784 PPS }
>   3G pkt Rvcd   { 5101392 PPS }
>   4G pkt Rvcd   { 0 PPS }
>   unknown rat type pkt Rvcd { 5101392 PPS }
> Arp-Rsp Pkt Drop{ 0 PPS }
> Arp-Req Pkt process { 3508911440 PPS }
> ICMP-Req Pkt process{ 32765 PPS }
>
>   Pkt BB PP License Expired { 0 PPS }
>  
>
> Pkt BB Configuration not recieved { 5101392 PPS }
>
>
> *Note : There are 500 lines below...not adding all here.*
>  
>
>>
>> If the programs that produce them send them to standard output, then one 
>> option would be to run the commands and redirect their outputs to a file. 
>> When all the programs have been run, copy that file to wherever you need 
>> it. Remember to append for all but the first command.
>>
>> Also, I don't understand what you mean about *(.*):(.*): ''*
>>
>
>  >>This method is to scroll down or go to next line. Ref:  
> https://blog.linuxserver.io/2018/03/23/ansible-tip-expect-module/ 
>  
>
>> A better mechanism (IMHO) would be to write a shell script that 
>> generates all the stats in the order you want them, and either have that 
>> script write to a file or redirect its output to a file. Then just grab 
>> that file. If the stats are to be obtained from multiple machines you 
>> could copy the script to each with Ansible and then execute it. If it's 
>> just one host, you could leave the script on that host. It depends on 
>> where would be the most appropriate place to maintain the script.
>>
>>
> >>This binary has its own commands it does not allow our routine bash 
> commands. If you type date command there, it wont work. After pressing  \q 
> in that utility, it takes user to bash cli prompt i.e sam@golden:~# 
> >>So, coping that output is little tricky.  
>  
>
>> Regards, K.
>>
>>
>>
>>
>> On Sat, Apr 18, 2020 at 7:50 PM Samir Kothawade  
>> wrote:
>>
>>> Also, There is a limitation on remote host - It does not have xrandr 
>>> module. So, changing screen size with xrandr will not be  available :( 
>>>
>>> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:

 Hi, 

 *Here is the brief about scenario: *

 1. login to Debian host machine using ansible
 2. Go to corresponding directory where the binary is and execute that 
 binary. (This binary is written in c and C++. After execution it ask for 
 the userid & password) 
 3. After login into that binary's shell, it  has several commands which 
 displays statistics. Those stats are lengthy and does not fit in current 
 screen resolution. For seen seeing all the stats we have to press Down 
 arrow Key or Enter key multiple time until we reach to last stat line.

 *How I am doing this: *

 *-** hosts: sam*
 *  gather_facts: no*
 *  tasks:*
 *  - name: capture all stats*
 *ignore_errors: yes*
 *expect:*
 *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
 *  responses:*
 *(.*)Username:(.*): "admin"*
 *(.*)Password:(.*): "admin"*
 *(.*)xyz_cli>(.*): display all debug stats*
 *(.*):(.*): ''* 
 *register: stats*
 *  - local_action: copy content="{{ stats.stdout}}" 
 dest="/home/sam/quickstats/stats.txt"*
 *ignore_errors: yes*
 

 *Issues Facing : *

 1. Multiple similar line gets copied in stats.txt file when above 

Re: [ansible-project] Failed to lock apt for exclusive operation

2020-04-18 Thread George James
Okay, sorry I am new to Ansible and all this is a bit confusing.

How do I set the super password, because now I change it to root, and even 
though I use the flag --ask-pass and pass in the password I now get the 
error `Missing sudo password`

- name: Install Nginx Ubuntu
  hosts: web
  remote_user: "{{ NGINX_USER }}"
  become: yes
  become_method: sudo
  become_user: root
  connection: ssh
  gather_facts: no
  vars:
NGINX_VERSION: nginx-1.17.10
NGINX_SBIN_PATH: /usr/sbin/
NGINX_ERROR_LOG_PATH: /var/log/nginx/error.log
NGINX_HTTP_LOG_PATH: /var/log/nginx/access.log
NGINX_PID_PATH: /var/run/nginx.pid
  vars_files:
- ../vars/global.yaml
  tasks:
- name: Check if Nginx Exists
  stat: path=/etc/init.d/nginx
  register: nginx_status
  become: yes
- name: Stop nginx Service
  service: name=nginx state=stopped
  when: nginx_status.stat.exists
  register: service_stopped
- name: Make sure a systemd is not running
  systemd:
state: stopped
name: nginx
- name: Install aptitude using apt
  apt:
name: aptitude
state: latest
update_cache: yes
force_apt_get: yes

And I run with this playbook with the command 

ansible-playbook nginx_ubuntu_18_04/playbook.yaml -i hosts --ask-pass

But I now get the error 

TASK [Check if Nginx Exists] 

fatal: [142.93.15.195]: FAILED! => {"msg": "Missing sudo password"}



On Saturday, April 18, 2020 at 5:25:04 PM UTC+4, Stefan Hornburg (Racke) 
wrote:
>
> On 4/18/20 3:13 PM, George James wrote: 
> > Hi Stefan, I have attached my playbook below 
> > 
> > 
>
> Hello George, 
>
> you need to be superuser to install APT packages, but your become_user is 
> "{{ NGINX_USER }}" which 
> is probably not root. 
>
> Regards 
>Racke 
>
> > | 
> > 
> > 
> > -name:InstallNginxUbuntu 
> >   hosts:web 
> >   remote_user:"{{ NGINX_USER }}" 
> >   become:yes 
> >   become_method:sudo 
> >   become_user:"{{ NGINX_USER }}" 
> >   connection:ssh 
> >   gather_facts:no 
> >   vars: 
> > NGINX_VERSION:nginx-1.17.10 
> > NGINX_SBIN_PATH:/usr/sbin/ 
> > NGINX_ERROR_LOG_PATH:/var/log/nginx/error.log 
> > NGINX_HTTP_LOG_PATH:/var/log/nginx/access.log 
> > NGINX_PID_PATH:/var/run/nginx.pid 
> >   vars_files: 
> > -../vars/global.yaml 
> >   tasks: 
> > -name:CheckifNginxExists 
> >   stat:path=/etc/init.d/nginx 
> >   register:nginx_status 
> >   become:yes 
> > -name:Stopnginx Service 
> >   service:name=nginx state=stopped 
> >   when:nginx_status.stat.exists 
> >   register:service_stopped 
> > -name:Makesure a systemd isnotrunning 
> >   systemd: 
> > state:stopped 
> > name:nginx 
> > -name:Installaptitude usingapt 
> >   apt: 
> > name:aptitude 
> > state:latest 
> > update_cache:yes 
> > force_apt_get:yes 
> > -name:Updateapt repo 
> >   apt: 
> > update_cache:yes 
> > cache_valid_time:3600 
> > -name:Installrequired system packages 
> >   apt:name={{item }}state=latest update_cache=yes 
> >   loop: 
> > [ 
> >   "build-essential", 
> >   "libpcre3", 
> >   "libpcre3-dev", 
> >   "zlib1g", 
> >   "zlib1g-dev", 
> >   "libssl-dev", 
> > ] 
> > | 
> > 
> > 
> > 
> > 
> > On Saturday, April 18, 2020 at 4:42:09 PM UTC+4, Stefan Hornburg (Racke) 
> wrote: 
> > 
> > On 4/18/20 2:05 PM, George James wrote: 
> > > I create a new user using ansible called `nginx`, `nginx` is part 
> of the sudo group a, but when I try to do an apt 
> > > install with this user I get the below error  
> > > 
> > > ``` 
> > > : FAILED! => {"changed": false, "msg": "Failed to lock apt for 
> exclusive operation"} 
> > > ``` 
> > > 
> > > What is the cause of the error and how can it be fixed? 
> > 
> > Please show your playbook. 
> > 
> > Regards 
> >   Racke 
> > 
> > > 
> > > -- 
> > > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> > > To unsubscribe from this group and stop receiving emails from it, 
> send an email to 
> > > ansible...@googlegroups.com   ansible-project+unsubscr...@googlegroups.com  
> >. 
> > > To view this discussion on the web visit 
> > > 
> https://groups.google.com/d/msgid/ansible-project/eca36773-19e9-48fc-b1e7-d93be6489de0%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/eca36773-19e9-48fc-b1e7-d93be6489de0%40googlegroups.com>
>  
>
> > > 
> > <
> https://groups.google.com/d/msgid/ansible-project/eca36773-19e9-48fc-b1e7-d93be6489de0%40googlegroups.com?utm_medium=email_source=footer
>  
> > <

Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Samir Kothawade


On Saturday, 18 April 2020 15:46:06 UTC+5:30, Karl Auer wrote:
>
> How exactly are the stats output on the host?
>

*Actual Output received in stats.txt file though method which is I am 
using.*

  "OPR>display debug info PP ip 192.168.30.26 port 8686 data", 
"\u001b[H\u001b[JSending command to get debug data from 
{192.168.30.26:8686} PP", 
"", 
" Current counters in PP:", 
"", 
"Data Counters Summary:", 
"\u001b[5GTotal Pkt Received\u001b[6;49H{ 10202784 PPS }", 
"\u001b[7G3G pkt Rvcd\u001b[7;49H{ 5101392 PPS }", 
"\u001b[7G4G pkt Rvcd\u001b[8;49H{ 0 PPS }", 
"\u001b[7Gunknown rat type pkt Rvcd\u001b[9;49H{ 5101392 PPS }", 
"\u001b[5GArp-Rsp Pkt Drop\u001b[10;49H{ 0 PPS }", 
"\u001b[5GArp-Req Pkt process\u001b[11;49H{ 549683392 PPS }", 
"\u001b[5GICMP-Req Pkt process\u001b[12;49H{ 32765 PPS }", 
"", 

*Note: there are 2K lines below (as I described in my initial comment)*

*Expected results -- or output displayed when we hit the command manually.*

 Current counters in PP:

Data Counters Summary:
Total Pkt Received  { 10202784 PPS }
  3G pkt Rvcd   { 5101392 PPS }
  4G pkt Rvcd   { 0 PPS }
  unknown rat type pkt Rvcd { 5101392 PPS }
Arp-Rsp Pkt Drop{ 0 PPS }
Arp-Req Pkt process { 3508911440 PPS }
ICMP-Req Pkt process{ 32765 PPS }

  Pkt BB PP License Expired { 0 PPS }
 

Pkt BB Configuration not recieved { 5101392 PPS }


*Note : There are 500 lines below...not adding all here.*
 

>
> If the programs that produce them send them to standard output, then one 
> option would be to run the commands and redirect their outputs to a file. 
> When all the programs have been run, copy that file to wherever you need 
> it. Remember to append for all but the first command.
>
> Also, I don't understand what you mean about *(.*):(.*): ''*
>

 >>This method is to scroll down or go to next line. Ref:  
https://blog.linuxserver.io/2018/03/23/ansible-tip-expect-module/ 
 

> A better mechanism (IMHO) would be to write a shell script that generates 
> all the stats in the order you want them, and either have that script 
> write to a file or redirect its output to a file. Then just grab that 
> file. If the stats are to be obtained from multiple machines you could 
> copy the script to each with Ansible and then execute it. If it's just one 
> host, you could leave the script on that host. It depends on where would 
> be the most appropriate place to maintain the script.
>
>
>>This binary has its own commands it does not allow our routine bash 
commands. If you type date command there, it wont work. After pressing  \q 
in that utility, it takes user to bash cli prompt i.e sam@golden:~# 
>>So, coping that output is little tricky.  
 

> Regards, K.
>
>
>
>
> On Sat, Apr 18, 2020 at 7:50 PM Samir Kothawade  > wrote:
>
>> Also, There is a limitation on remote host - It does not have xrandr 
>> module. So, changing screen size with xrandr will not be  available :( 
>>
>> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>>
>>> Hi, 
>>>
>>> *Here is the brief about scenario: *
>>>
>>> 1. login to Debian host machine using ansible
>>> 2. Go to corresponding directory where the binary is and execute that 
>>> binary. (This binary is written in c and C++. After execution it ask for 
>>> the userid & password) 
>>> 3. After login into that binary's shell, it  has several commands which 
>>> displays statistics. Those stats are lengthy and does not fit in current 
>>> screen resolution. For seen seeing all the stats we have to press Down 
>>> arrow Key or Enter key multiple time until we reach to last stat line.
>>>
>>> *How I am doing this: *
>>>
>>> *-** hosts: sam*
>>> *  gather_facts: no*
>>> *  tasks:*
>>> *  - name: capture all stats*
>>> *ignore_errors: yes*
>>> *expect:*
>>> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>>> *  responses:*
>>> *(.*)Username:(.*): "admin"*
>>> *(.*)Password:(.*): "admin"*
>>> *(.*)xyz_cli>(.*): display all debug stats*
>>> *(.*):(.*): ''* 
>>> *register: stats*
>>> *  - local_action: copy content="{{ stats.stdout}}" 
>>> dest="/home/sam/quickstats/stats.txt"*
>>> *ignore_errors: yes*
>>> 
>>>
>>> *Issues Facing : *
>>>
>>> 1. Multiple similar line gets copied in stats.txt file when above 
>>> reaches to ==>>*  (.*):(.*): ''*  (See above code section marked in 
>>> blue). Using this method to press  key.  
>>> 2. Actual stats counts are of line 500 hundred but above code returns 2k 
>>> + stats with repetitive stats and some garbage values appended.
>>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above 
>>> script only copies 20-30 lines which currently are displayed 

Re: [ansible-project] Failed to lock apt for exclusive operation

2020-04-18 Thread Stefan Hornburg (Racke)
On 4/18/20 3:13 PM, George James wrote:
> Hi Stefan, I have attached my playbook below
> 
> 

Hello George,

you need to be superuser to install APT packages, but your become_user is "{{ 
NGINX_USER }}" which
is probably not root.

Regards
   Racke

> |
> 
> 
> -name:InstallNginxUbuntu
>   hosts:web
>   remote_user:"{{ NGINX_USER }}"
>   become:yes
>   become_method:sudo
>   become_user:"{{ NGINX_USER }}"
>   connection:ssh
>   gather_facts:no
>   vars:
>     NGINX_VERSION:nginx-1.17.10
>     NGINX_SBIN_PATH:/usr/sbin/
>     NGINX_ERROR_LOG_PATH:/var/log/nginx/error.log
>     NGINX_HTTP_LOG_PATH:/var/log/nginx/access.log
>     NGINX_PID_PATH:/var/run/nginx.pid
>   vars_files:
>     -../vars/global.yaml
>   tasks:
>     -name:CheckifNginxExists
>       stat:path=/etc/init.d/nginx
>       register:nginx_status
>       become:yes
>     -name:Stopnginx Service
>       service:name=nginx state=stopped
>       when:nginx_status.stat.exists
>       register:service_stopped
>     -name:Makesure a systemd isnotrunning
>       systemd:
>         state:stopped
>         name:nginx
>     -name:Installaptitude usingapt
>       apt:
>         name:aptitude
>         state:latest
>         update_cache:yes
>         force_apt_get:yes
>     -name:Updateapt repo
>       apt:
>         update_cache:yes
>         cache_valid_time:3600
>     -name:Installrequired system packages
>       apt:name={{item }}state=latest update_cache=yes
>       loop:
>         [
>           "build-essential",
>           "libpcre3",
>           "libpcre3-dev",
>           "zlib1g",
>           "zlib1g-dev",
>           "libssl-dev",
>         ]
> |
> 
> 
> 
> 
> On Saturday, April 18, 2020 at 4:42:09 PM UTC+4, Stefan Hornburg (Racke) 
> wrote:
> 
> On 4/18/20 2:05 PM, George James wrote:
> > I create a new user using ansible called `nginx`, `nginx` is part of 
> the sudo group a, but when I try to do an apt
> > install with this user I get the below error 
> >
> > ```
> > : FAILED! => {"changed": false, "msg": "Failed to lock apt for 
> exclusive operation"}
> > ```
> >
> > What is the cause of the error and how can it be fixed?
> 
> Please show your playbook.
> 
> Regards
>           Racke
> 
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to
> > ansible...@googlegroups.com  
> .
> > To view this discussion on the web visit
> > 
> https://groups.google.com/d/msgid/ansible-project/eca36773-19e9-48fc-b1e7-d93be6489de0%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/6b3010ea-35f1-4a0d-86bc-cd9245691bf8%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/795fb1c6-ec85-3940-158c-58b5f7a054d7%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


Re: [ansible-project] Failed to lock apt for exclusive operation

2020-04-18 Thread George James
Hi Stefan, I have attached my playbook below




- name: Install Nginx Ubuntu
  hosts: web
  remote_user: "{{ NGINX_USER }}"
  become: yes
  become_method: sudo
  become_user: "{{ NGINX_USER }}"
  connection: ssh
  gather_facts: no
  vars:
NGINX_VERSION: nginx-1.17.10
NGINX_SBIN_PATH: /usr/sbin/
NGINX_ERROR_LOG_PATH: /var/log/nginx/error.log
NGINX_HTTP_LOG_PATH: /var/log/nginx/access.log
NGINX_PID_PATH: /var/run/nginx.pid
  vars_files:
- ../vars/global.yaml
  tasks:
- name: Check if Nginx Exists
  stat: path=/etc/init.d/nginx
  register: nginx_status
  become: yes
- name: Stop nginx Service
  service: name=nginx state=stopped
  when: nginx_status.stat.exists
  register: service_stopped
- name: Make sure a systemd is not running
  systemd:
state: stopped
name: nginx
- name: Install aptitude using apt
  apt:
name: aptitude
state: latest
update_cache: yes
force_apt_get: yes
- name: Update apt repo
  apt:
update_cache: yes
cache_valid_time: 3600
- name: Install required system packages
  apt: name={{ item }} state=latest update_cache=yes
  loop:
[
  "build-essential",
  "libpcre3",
  "libpcre3-dev",
  "zlib1g",
  "zlib1g-dev",
  "libssl-dev",
]




On Saturday, April 18, 2020 at 4:42:09 PM UTC+4, Stefan Hornburg (Racke) 
wrote:
>
> On 4/18/20 2:05 PM, George James wrote: 
> > I create a new user using ansible called `nginx`, `nginx` is part of the 
> sudo group a, but when I try to do an apt 
> > install with this user I get the below error  
> > 
> > ``` 
> > : FAILED! => {"changed": false, "msg": "Failed to lock apt for exclusive 
> operation"} 
> > ``` 
> > 
> > What is the cause of the error and how can it be fixed? 
>
> Please show your playbook. 
>
> Regards 
>   Racke 
>
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to 
> > ansible...@googlegroups.com   ansible-project+unsubscr...@googlegroups.com >. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/eca36773-19e9-48fc-b1e7-d93be6489de0%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/eca36773-19e9-48fc-b1e7-d93be6489de0%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/6b3010ea-35f1-4a0d-86bc-cd9245691bf8%40googlegroups.com.


Re: [ansible-project] Failed to lock apt for exclusive operation

2020-04-18 Thread Stefan Hornburg (Racke)
On 4/18/20 2:05 PM, George James wrote:
> I create a new user using ansible called `nginx`, `nginx` is part of the sudo 
> group a, but when I try to do an apt
> install with this user I get the below error 
> 
> ```
> : FAILED! => {"changed": false, "msg": "Failed to lock apt for exclusive 
> operation"}
> ```
> 
> What is the cause of the error and how can it be fixed?

Please show your playbook.

Regards
  Racke

> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to
> ansible-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/eca36773-19e9-48fc-b1e7-d93be6489de0%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/7ca496a7-ad06-04f9-22ba-9b38d31c65c5%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Failed to lock apt for exclusive operation

2020-04-18 Thread George James
I create a new user using ansible called `nginx`, `nginx` is part of the 
sudo group a, but when I try to do an apt install with this user I get the 
below error 

```
: FAILED! => {"changed": false, "msg": "Failed to lock apt for exclusive 
operation"}
```

What is the cause of the error and how can it be fixed?

-- 
You received this message because you are 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/eca36773-19e9-48fc-b1e7-d93be6489de0%40googlegroups.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Karl Auer
How exactly are the stats output on the host?

If the programs that produce them send them to standard output, then one
option would be to run the commands and redirect their outputs to a file.
When all the programs have been run, copy that file to wherever you need
it. Remember to append for all but the first command.

Also, I don't understand what you mean about *(.*):(.*): ''*

A better mechanism (IMHO) would be to write a shell script that generates
all the stats in the order you want them, and either have that script write
to a file or redirect its output to a file. Then just grab that file. If
the stats are to be obtained from multiple machines you could copy the
script to each with Ansible and then execute it. If it's just one host, you
could leave the script on that host. It depends on where would be the most
appropriate place to maintain the script.

Regards, K.




On Sat, Apr 18, 2020 at 7:50 PM Samir Kothawade 
wrote:

> Also, There is a limitation on remote host - It does not have xrandr
> module. So, changing screen size with xrandr will not be  available :(
>
> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>
>> Hi,
>>
>> *Here is the brief about scenario: *
>>
>> 1. login to Debian host machine using ansible
>> 2. Go to corresponding directory where the binary is and execute that
>> binary. (This binary is written in c and C++. After execution it ask for
>> the userid & password)
>> 3. After login into that binary's shell, it  has several commands which
>> displays statistics. Those stats are lengthy and does not fit in current
>> screen resolution. For seen seeing all the stats we have to press Down
>> arrow Key or Enter key multiple time until we reach to last stat line.
>>
>> *How I am doing this: *
>>
>> *-** hosts: sam*
>> *  gather_facts: no*
>> *  tasks:*
>> *  - name: capture all stats*
>> *ignore_errors: yes*
>> *expect:*
>> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>> *  responses:*
>> *(.*)Username:(.*): "admin"*
>> *(.*)Password:(.*): "admin"*
>> *(.*)xyz_cli>(.*): display all debug stats*
>> *(.*):(.*): ''*
>> *register: stats*
>> *  - local_action: copy content="{{ stats.stdout}}"
>> dest="/home/sam/quickstats/stats.txt"*
>> *ignore_errors: yes*
>>
>>
>> *Issues Facing : *
>>
>> 1. Multiple similar line gets copied in stats.txt file when above reaches
>> to ==>>*  (.*):(.*): ''*  (See above code section marked in blue). Using
>> this method to press  key.
>> 2. Actual stats counts are of line 500 hundred but above code returns 2k
>> + stats with repetitive stats and some garbage values appended.
>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above
>> script only copies 20-30 lines which currently are displayed on screen or
>> which displayed in current screen size.
>>
>>
>> I guess I can achieve this by changing remote servers' screen size. but I
>> could not able to get any such way in ansible.
>>
>>
>> May I request you to help me in this ?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1ee2dc0f-11c5-4644-b1fb-dec87ade59ed%40googlegroups.com
> 
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are 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%2B%2BT08QCC3hzXjPPcyfYoRygtC0GzwWMiKhUqxOJ18F-UmiSKQ%40mail.gmail.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Stefan Hornburg (Racke)
On 4/18/20 11:50 AM, Samir Kothawade wrote:
> Also, There is a limitation on remote host - It does not have xrandr module. 
> So, changing screen size with xrandr will
> not be  available :( 

You need to configure the size of the remote terminal, so xrandr won't be the 
correct tool. So you can try
to manipulate the terminal with shell commands (resize, stty).

But I wonder why you can't tell this binary to write output in a file.

Regards
 Racke

> 
> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
> 
> Hi, 
> 
> *_Here is the brief about scenario: _*
> 
> 1. login to Debian host machine using ansible
> 2. Go to corresponding directory where the binary is and execute that 
> binary. (This binary is written in c and C++.
> After execution it ask for the userid & password) 
> 3. After login into that binary's shell, it  has several commands which 
> displays statistics. Those stats are lengthy
> and does not fit in current screen resolution. For seen seeing all the 
> stats we have to press Down arrow Key or
> Enter key multiple time until we reach to last stat line.
> 
> _*How I am doing this: *_
> 
> /-//hosts: sam/
> /  gather_facts: no/
> /  tasks:/
> /  - name: capture all stats/
> /    ignore_errors: yes/
> /    expect:/
> /      command: /opt/abc/xyz_Platform/bin/go_xyz_cli/
> /      responses:/
> /        (.*)Username:(.*): "admin"/
> /        (.*)Password:(.*): "admin"/
> /        (.*)xyz_cli>(.*): display all debug stats/
> /  *      (.*):(.*): ''*//* */
> /    register: stats/
> /  - local_action: copy content="{{ stats.stdout}}" 
> dest="/home/sam/quickstats/stats.txt"/
> /    ignore_errors: yes/
>     
> 
> *_Issues Facing : _*
> 
> 1. Multiple similar line gets copied in stats.txt file when above reaches 
> to ==>>/  *(.*):(.*): ''*//* */ (See above
> code section marked in blue). Using this method to press  key.  
> 2. Actual stats counts are of line 500 hundred but above code returns 2k 
> + stats with repetitive stats and some
> garbage values appended.
> 3. If i removes this  portion /*  (.*):(.*): ''*/ from code, then above 
> script only copies 20-30 lines which
> currently are displayed on screen or which displayed in current screen 
> size. 
> 
> 
> I guess I can achieve this by changing remote servers' screen size. but I 
> could not able to get any such way in
> ansible. 
> 
> 
> May I request you to help me in this ?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to
> ansible-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1ee2dc0f-11c5-4644-b1fb-dec87ade59ed%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/055cc481-f366-84a8-823a-2edc8b989236%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Samir Kothawade
Also, There is a limitation on remote host - It does not have xrandr 
module. So, changing screen size with xrandr will not be  available :( 

On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>
> Hi, 
>
> *Here is the brief about scenario: *
>
> 1. login to Debian host machine using ansible
> 2. Go to corresponding directory where the binary is and execute that 
> binary. (This binary is written in c and C++. After execution it ask for 
> the userid & password) 
> 3. After login into that binary's shell, it  has several commands which 
> displays statistics. Those stats are lengthy and does not fit in current 
> screen resolution. For seen seeing all the stats we have to press Down 
> arrow Key or Enter key multiple time until we reach to last stat line.
>
> *How I am doing this: *
>
> *-** hosts: sam*
> *  gather_facts: no*
> *  tasks:*
> *  - name: capture all stats*
> *ignore_errors: yes*
> *expect:*
> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
> *  responses:*
> *(.*)Username:(.*): "admin"*
> *(.*)Password:(.*): "admin"*
> *(.*)xyz_cli>(.*): display all debug stats*
> *(.*):(.*): ''* 
> *register: stats*
> *  - local_action: copy content="{{ stats.stdout}}" 
> dest="/home/sam/quickstats/stats.txt"*
> *ignore_errors: yes*
> 
>
> *Issues Facing : *
>
> 1. Multiple similar line gets copied in stats.txt file when above reaches 
> to ==>>*  (.*):(.*): ''*  (See above code section marked in blue). Using 
> this method to press  key.  
> 2. Actual stats counts are of line 500 hundred but above code returns 2k + 
> stats with repetitive stats and some garbage values appended.
> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above 
> script only copies 20-30 lines which currently are displayed on screen or 
> which displayed in current screen size. 
>
>
> I guess I can achieve this by changing remote servers' screen size. but I 
> could not able to get any such way in ansible. 
>
>
> May I request you to help me in this ?
>

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


[ansible-project] How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Samir Kothawade
Hi, 

*Here is the brief about scenario: *

1. login to Debian host machine using ansible
2. Go to corresponding directory where the binary is and execute that 
binary. (This binary is written in c and C++. After execution it ask for 
the userid & password) 
3. After login into that binary's shell, it  has several commands which 
displays statistics. Those stats are lengthy and does not fit in current 
screen resolution. For seen seeing all the stats we have to press Down 
arrow Key or Enter key multiple time until we reach to last stat line.

*How I am doing this: *

*-** hosts: sam*
*  gather_facts: no*
*  tasks:*
*  - name: capture all stats*
*ignore_errors: yes*
*expect:*
*  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
*  responses:*
*(.*)Username:(.*): "admin"*
*(.*)Password:(.*): "admin"*
*(.*)xyz_cli>(.*): display all debug stats*
*(.*):(.*): ''* 
*register: stats*
*  - local_action: copy content="{{ stats.stdout}}" 
dest="/home/sam/quickstats/stats.txt"*
*ignore_errors: yes*


*Issues Facing : *

1. Multiple similar line gets copied in stats.txt file when above reaches 
to ==>>*  (.*):(.*): ''*  (See above code section marked in blue). Using 
this method to press  key.  
2. Actual stats counts are of line 500 hundred but above code returns 2k + 
stats with repetitive stats and some garbage values appended.
3. If i removes this  portion *  (.*):(.*): ''*  from code, then above 
script only copies 20-30 lines which currently are displayed on screen or 
which displayed in current screen size. 


I guess I can achieve this by changing remote servers' screen size. but I 
could not able to get any such way in ansible. 


May I request you to help me in this ?

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


Re: [ansible-project] how to use suexec su in ansible

2020-04-18 Thread Stefan Hornburg (Racke)
On 4/18/20 1:19 AM, Pradeep Tiwari wrote:
> Hi All, 
> 
> I did look at various privilege escalation tools available but i dont see 
> suexec listed there. Could you please guide me how to achieve this become 
> method
> 

You would need to find or write a custom become plugin for suexec:
https://docs.ansible.com/ansible/latest/plugins/become.html.

Regards
Racke

-- 
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/807069e3-57d6-e1b7-b078-384f1ef48d7e%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


Re: [ansible-project] Try to put 1 Ansible facts from multiple servers into one list

2020-04-18 Thread Stefan Hornburg (Racke)
On 4/18/20 1:57 AM, Gregory Skelton wrote:
> I feel this should be easy. 
> 
> I'm trying to put a fact I set on each server into one central list. 
> sat_id is the Big List
> sat_id_raw is the variable that I set earlier in the automation. 
> 
> What am I missing here?
> Thanks in advance
> 

Try "{{ sat_id + sat_id_raw }}" if sat_id_raw is a list, "{{ sat_id + 
[sat_id_raw] }}" if sat_id_raw is
a single value.

Regards
  Racke


> name: Put all of the var into a big list
> 
>   set_fact:
> 
>     sat_id: "{{ sat_id }} + ['{{ sat_id_raw }}']"
> 
>   delegate_to: localhost
> 
> __ __
> 
> - name: Print object type
> 
>   debug:
> 
>     var: sat_id
> 
>   delegate_to: localhost
> 
> __ __
> 
> __ __
> 
> TASK [Facts-list : Put all of the vars into a big list]
> *
> 
> ok: [MY-SERVER1 -> localhost] => {
> 
>     "ansible_facts": {
> 
>     "sat_id": [
> 
>     "15929"
> 
>     ]
> 
>     },
> 
>     "changed": false
> 
> }
> 
> ok: [MY-SERVER2 -> localhost] => {
> 
>     "ansible_facts": {
> 
>     "sat_id": [
> 
>     "13409"
> 
>     ]
> 
>     },
> 
>     "changed": false
> 
> }
> 
> __ __
> 
> TASK [Facts-list : Print object type]
> ***
> 
> task path: 
> /data/grskelt/satellite-devel/satellite-contentviews-list/tasks/main.yml:96
> 
> ok: [MY-SERVER1 -> localhost] => {
> 
>     "sat_id": [
> 
>     "15929"
> 
>     ]
> 
> }
> 
> ok: [MY-SERVER2 -> localhost] => {
> 
>     "sat_id": [
> 
>     "13409"
> 
>     ]
> 
> 
> -- 
> You received this message because you are 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/829bacc7-12b8-439d-8770-7cf956da2e9c%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/a9e2f690-1279-1e54-3a01-0a540aec26a8%40linuxia.de.


signature.asc
Description: OpenPGP digital signature