Re: [ansible-project] Ansible dynamic looping

2018-02-01 Thread Pshem Kowalczyk
Hi,

If you use the dynamic inventory script (ec2.py) you can use tags to
dynamically create groups. Have a look here:
https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/


kind regards
Pshem


On Fri, 2 Feb 2018 at 18:39 Andrew Morgan  wrote:

> Thanks for your reply, but the issue with that is , the servers in aws get
> removed and created again each build( every 1hr) , so I would need a way to
> get the servers dynamically.Is there anyway to do that? i want to
> dynamically have a list, not create a list of servers in inventory.
>
>
> On Thursday, 1 February 2018 21:08:51 UTC-5, Pshem Kowalczyk wrote:
>
>> with_items requires a list to iterate over. I think one way of achieving
>> your outcome is to create a group in the inventory and populate it with the
>> hosts and run the playbook against that group.
>>
>> kind regards
>> Pshem
>>
> On Fri, 2 Feb 2018 at 13:02 Andrew Morgan 
>> wrote:
>>
> Hello all,
>>>
>>> I have a play I want to run wich deletes all hosts matching a certain
>>> criteria:
>>>
>>> tasks:
>>>   - name: Delete unavailable nodes
>>> zabbix_host:
>>>  server_url: http://zabbix.aa.net/zabbix
>>>  login_user: Admin
>>>  login_password: aq!
>>>  host_groups: Discovered hosts
>>>  status: disabled
>>>  state: absent
>>>  host_name: "{{ item }}"
>>> with_items:
>>>  - ip-10-1-*-*.us-west-2.compute.internal
>>>
>>>
>>>
>>> The above doesnt work, but if I list out the items
>>> with_items:
>>>  - ip-10-1-65-27.us-west-2.compute.internal
>>>  - ip-10-1-65-28.us-west-2.compute.internal
>>>  - ip-10-1-65-37.us-west-2.compute.internal
>>>
>>> then it works, but I want it to be dynamic and find all ips matching
>>>- ip-10-1-*-*.us-west-2.compute.internal
>>>
>>> any help please?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>>
>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to ansible-proje...@googlegroups.com.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>
>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/dcd118b2-775b-44d3-baf5-713b9b0918be%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/698ae457-a362-4f57-a384-13f932a6f654%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


[ansible-project] Ansible Tower Installation failed in RHEL 7.4 with error pkg_resources.DistributionNotFound: awx==3.2.2

2018-02-01 Thread Triển Lập Lâm
Hi all

The installation fails in the step "Migrate the Tower database schema" 
after run file  setup.sh in ansible-tower-setup-3.2.2

May I miss any setting ?
Please help me to take a look.

Thanks


TASK [awx_install : Stop supervisor] 
***
ok: [localhost] => {"changed": false, "name": "supervisord", "state": 
"stopped", "status": {"ActiveEnterTimestampMonotonic": "0", 
"ActiveExitTimestampMonotonic": "0", "ActiveState": "inactive", "After": 
"systemd-journald.socket system.slice basic.target rc-local.service 
nss-user-lookup.target", "AllowIsolate": "no", "AmbientCapabilities": "0", 
"AssertResult": "no", "AssertTimestampMonotonic": "0", "Before": 
"shutdown.target", "BlockIOAccounting": "no", "BlockIOWeight": 
"18446744073709551615", "CPUAccounting": "no", "CPUQuotaPerSecUSec": 
"infinity", "CPUSchedulingPolicy": "0", "CPUSchedulingPriority": "0", 
"CPUSchedulingResetOnFork": "no", "CPUShares": "18446744073709551615", 
"CanIsolate": "no", "CanReload": "no", "CanStart": "yes", "CanStop": "yes", 
"CapabilityBoundingSet": "18446744073709551615", "ConditionResult": "no", 
"ConditionTimestampMonotonic": "0", "Conflicts": "shutdown.target", 
"ControlPID": "0", "DefaultDependencies": "yes", "Delegate": "no", 
"Description": "Process Monitoring and Control Daemon", "DevicePolicy": 
"auto", "ExecMainCode": "0", "ExecMainExitTimestampMonotonic": "0", 
"ExecMainPID": "0", "ExecMainStartTimestampMonotonic": "0", 
"ExecMainStatus": "0", "ExecStart": "{ path=/usr/bin/supervisord ; 
argv[]=/usr/bin/supervisord -c /etc/supervisord.conf ; ignore_errors=no ; 
start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }", 
"FailureAction": "none", "FileDescriptorStoreMax": "0", "FragmentPath": 
"/usr/lib/systemd/system/supervisord.service", "GuessMainPID": "yes", 
"IOScheduling": "0", "Id": "supervisord.service", "IgnoreOnIsolate": "no", 
"IgnoreOnSnapshot": "no", "IgnoreSIGPIPE": "yes", 
"InactiveEnterTimestampMonotonic": "0", "InactiveExitTimestampMonotonic": 
"0", "JobTimeoutAction": "none", "JobTimeoutUSec": "0", "KillMode": 
"control-group", "KillSignal": "15", "LimitAS": "18446744073709551615", 
"LimitCORE": "18446744073709551615", "LimitCPU": "18446744073709551615", 
"LimitDATA": "18446744073709551615", "LimitFSIZE": "18446744073709551615", 
"LimitLOCKS": "18446744073709551615", "LimitMEMLOCK": "65536", 
"LimitMSGQUEUE": "819200", "LimitNICE": "0", "LimitNOFILE": "4096", 
"LimitNPROC": "2063094", "LimitRSS": "18446744073709551615", "LimitRTPRIO": 
"0", "LimitRTTIME": "18446744073709551615", "LimitSIGPENDING": "2063094", 
"LimitSTACK": "18446744073709551615", "LoadState": "loaded", "MainPID": 
"0", "MemoryAccounting": "no", "MemoryCurrent": "18446744073709551615", 
"MemoryLimit": "18446744073709551615", "MountFlags": "0", "Names": 
"supervisord.service", "NeedDaemonReload": "no", "Nice": "0", 
"NoNewPrivileges": "no", "NonBlocking": "no", "NotifyAccess": "none", 
"OOMScoreAdjust": "0", "OnFailureJobMode": "replace", 
"PermissionsStartOnly": "no", "PrivateDevices": "no", "PrivateNetwork": 
"no", "PrivateTmp": "no", "ProtectHome": "no", "ProtectSystem": "no", 
"RefuseManualStart": "no", "RefuseManualStop": "no", "RemainAfterExit": 
"no", "Requires": "basic.target", "Restart": "no", "RestartUSec": "100ms", 
"Result": "success", "RootDirectoryStartOnly": "no", 
"RuntimeDirectoryMode": "0755", "SameProcessGroup": "no", "SecureBits": 
"0", "SendSIGHUP": "no", "SendSIGKILL": "yes", "Slice": "system.slice", 
"StandardError": "inherit", "StandardInput": "null", "StandardOutput": 
"journal", "StartLimitAction": "none", "StartLimitBurst": "5", 
"StartLimitInterval": "1000", "StartupBlockIOWeight": 
"18446744073709551615", "StartupCPUShares": "18446744073709551615", 
"StatusErrno": "0", "StopWhenUnneeded": "no", "SubState": "dead", 
"SyslogLevelPrefix": "yes", "SyslogPriority": "30", 
"SystemCallErrorNumber": "0", "TTYReset": "no", "TTYVHangup": "no", 
"TTYVTDisallocate": "no", "TasksAccounting": "no", "TasksCurrent": 
"18446744073709551615", "TasksMax": "18446744073709551615", 
"TimeoutStartUSec": "1min 30s", "TimeoutStopUSec": "1min 30s", 
"TimerSlackNSec": "5", "Transient": "no", "Type": "forking", "UMask": 
"0022", "UnitFilePreset": "disabled", "UnitFileState": "disabled", "Wants": 
"system.slice", "WatchdogTimestampMonotonic": "0", "WatchdogUSec": "0"}}

TASK [awx_install : Wait for supervisor to stop.] 
**
ok: [localhost] => {"attempts": 1, "changed": false, "stat": {"exists": 
false}}

TASK [awx_install : Migrate the Tower database schema (may take awhile when 
upgrading).] 
***
fatal: [localhost]: FAILED! => {"changed": true, 

[ansible-project] Ansible 2.5.0 Alpha 1 is available

2018-02-01 Thread mattdavi
Hi all! We're happy to announce that Alpha 1 for 2.5.0 is now available.

Note that while the core engine is feature complete, community module 
freeze is next week, so new modules and features will appear in the next 
pre-release.


How do you get it?
--

For the first time, all Ansible pre-releases in the 2.5 series will be 
published to PyPI. This is probably the easiest way for most users to 
install:

$ pip install ansible==2.5.0a1 --user


The tar.gz of the release can be found here:

http://releases.ansible.com/ansible/ansible-2.5.0a1.tar.gz
SHA256: 629db1896086495a82a13e72078d7f1dc4f518d2c6af682d1cff6520e1c506c7


You can also test against the git repository as follows:

$ git clone https://github.com/ansible/ansible.git
$ cd ansible
$ git checkout v2.5.0a1


You can then source our testing script:

$ . hacking/env-setup

or you can build your own .tar.gz (output will be 
dist/ansible-2.5.0a1.tar.gz):

$ make sdist


We've published a draft porting guide at 
https://docs.ansible.com/ansible/devel/porting_guide_2.5.html to help 
migrate your content to 2.5. If you discover any errors, or if you see any 
regressions from playbooks which work on 2.4.x and prior, please open a 
Github issue, and be sure to mention you're testing against 2.5.0a1.

Thanks!

Matt Davis

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


Re: [ansible-project] How to add os based variables into group_vars

2018-02-01 Thread sriman dharba
Thanks Kai! Came across vars & hostvars from FAQ section of ansible. Missed
it, thanks for the response.

Regards
Sri

On Fri, Feb 2, 2018 at 12:52 AM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On Wednesday, 31 January 2018 05.43.36 CET sriman dharba wrote:
> > - set_fact: repo_name="rhel_{{ ansible_distribution_major_version
> }}_repo"
> >
> >
> > - name: 'Upgrading packages to latest'
> >   yum:
> >  name: "*"
> >  state: latest
> >  enablerepo: "{{ repo_name }}"
> >   when: ansible_distribution == "RedHat" or ansible__distribution ==
> > "CentOS"
>
> - name: 'Upgrading packages to latest'
>   yum:
>  name: "*"
>  state: latest
>  enablerepo: "{{ vars[repo_name] }}"
>   when: ansible_distribution == "RedHat" or ansible__distribution ==
> "CentOS"
>
> or just drop the set_fact and use
>
> - name: 'Upgrading packages to latest'
>   yum:
>  name: "*"
>  state: latest
>  enablerepo: "{{ vars['repo_' ~ ansible_distribution_major_version ~
> '_repo'] }}"
>   when: ansible_distribution == "RedHat" or ansible__distribution ==
> "CentOS"
>
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/12765257.BGxFR1VXkv%40x1.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] Ansible dynamic looping

2018-02-01 Thread Andrew Morgan
Thanks for your reply, but the issue with that is , the servers in aws get 
removed and created again each build( every 1hr) , so I would need a way to 
get the servers dynamically.Is there anyway to do that? i want to 
dynamically have a list, not create a list of servers in inventory.

On Thursday, 1 February 2018 21:08:51 UTC-5, Pshem Kowalczyk wrote:
>
> with_items requires a list to iterate over. I think one way of achieving 
> your outcome is to create a group in the inventory and populate it with the 
> hosts and run the playbook against that group.
>
> kind regards
> Pshem
>
>
> On Fri, 2 Feb 2018 at 13:02 Andrew Morgan  
> wrote:
>
>> Hello all,
>>
>> I have a play I want to run wich deletes all hosts matching a certain 
>> criteria:
>>
>> tasks:
>>   - name: Delete unavailable nodes
>> zabbix_host:
>>  server_url: http://zabbix.aa.net/zabbix
>>  login_user: Admin
>>  login_password: aq!
>>  host_groups: Discovered hosts
>>  status: disabled
>>  state: absent
>>  host_name: "{{ item }}"
>> with_items:
>>  - ip-10-1-*-*.us-west-2.compute.internal
>> 
>>
>>
>> The above doesnt work, but if I list out the items
>> with_items:
>>  - ip-10-1-65-27.us-west-2.compute.internal
>>  - ip-10-1-65-28.us-west-2.compute.internal
>>  - ip-10-1-65-37.us-west-2.compute.internal
>>
>> then it works, but I want it to be dynamic and find all ips matching   
>>- ip-10-1-*-*.us-west-2.compute.internal
>>
>> any help please?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/dcd118b2-775b-44d3-baf5-713b9b0918be%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


[ansible-project] Re: How to do stuff on the remote Windows node from the command node?

2018-02-01 Thread Jordan Borean
Here are some further tips for people reading

* Use the yaml syntax when writting task rather than the key=value format, 
this makes it a lot simpler to write Windows paths.

e.g for the first task do.

- name: Copy a windows file from control node to remote node
  win_copy:
src: /etc/ansible/winFiles/getFileVersion.exe
dest: C:\Temp\

* Use backslashes for the Windows paths, if you use the yaml syntax, you 
only need to escape them when using double quote ""

e.g all of the below lead to the same value.

- some_module:
path: C:\temp
quoted_path: 'C:\temp'
double_quoted_path: "C:\\temp"

* Avoid using the raw module, use win_command or win_shell instead, you 
can't use become or environment variables with raw
* Use win_command when you are running an executable, avoid using this 
when running shell commands like dir, del or PowerShell cmdlets like 
New-Item, Copy-Item and so on
* Use win_shell when you are running shell commands or powershell 
cmdlets, avoid using this to run executables as you need to deal with shell 
escaping for complex arguments

* For tasks that give you an access is denied, use become to run it like it 
would locally (not experimental as of the 2.5 release)

# this does not work and leads to an access is denied error
- name: upgrade powershell
  win_chocoletey:
name: poweshell
state: latest

# when using become this is no longer an issue
- name: upgrade powershell
  win_chocolatey:
name: powershell
state: latest
  become: yes
  become_method: runas
  become_user: SYSTEM

* If there is not an Windows module to complete a task you are looking for, 
look to see if there is an DSC resource instead (PowerShell v5 or newer is 
required)

e.g. to manage Hyper-V you can use the DSC resource like so

- name: install Hyper-V DSC resource
  win_psmodule:
name: xHyper-V
state: present

- name: create Hyper-V VM
  win_dsc:
resource_name: xVMHyperv  # the DSC module to use
# the below parameters are all the DSC parameters to set
Ensure: present
Name: HyperVHost
VhdPath: C:\temp\vm.vhd
StartupMemory: 6291456000
Generation: 2
ProcessorCount: 2

There are numerous other things that are good to know but you are probably 
best looking at the new documentation for Windows here 
http://docs.ansible.com/ansible/devel/windows.html.

Thanks

Jordan

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


Re: [ansible-project] Ansible dynamic looping

2018-02-01 Thread Pshem Kowalczyk
with_items requires a list to iterate over. I think one way of achieving
your outcome is to create a group in the inventory and populate it with the
hosts and run the playbook against that group.

kind regards
Pshem


On Fri, 2 Feb 2018 at 13:02 Andrew Morgan  wrote:

> Hello all,
>
> I have a play I want to run wich deletes all hosts matching a certain
> criteria:
>
> tasks:
>   - name: Delete unavailable nodes
> zabbix_host:
>  server_url: http://zabbix.aa.net/zabbix
>  login_user: Admin
>  login_password: aq!
>  host_groups: Discovered hosts
>  status: disabled
>  state: absent
>  host_name: "{{ item }}"
> with_items:
>  - ip-10-1-*-*.us-west-2.compute.internal
>
>
>
> The above doesnt work, but if I list out the items
> with_items:
>  - ip-10-1-65-27.us-west-2.compute.internal
>  - ip-10-1-65-28.us-west-2.compute.internal
>  - ip-10-1-65-37.us-west-2.compute.internal
>
> then it works, but I want it to be dynamic and find all ips matching
> - ip-10-1-*-*.us-west-2.compute.internal
>
> any help please?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/dcd118b2-775b-44d3-baf5-713b9b0918be%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


[ansible-project] Re: Ansible dynamic looping

2018-02-01 Thread Lê Mạnh Hùng
Vào 07:01:51 UTC+7 Thứ Sáu, ngày 02 tháng 2 năm 2018, Andrew Morgan đã viết:
> Hello all,
> 
> I have a play I want to run wich deletes all hosts matching a certain 
> criteria:
> 
> 
> 
> tasks:
>   - name: Delete unavailable nodes
>     zabbix_host:
>      server_url: http://zabbix.aa.net/zabbix
>      login_user: Admin
>      login_password: aq!
>      host_groups: Discovered hosts
>      status: disabled
>      state: absent
>      host_name: "{{ item }}"
>     with_items:
>      - ip-10-1-*-*.us-west-2.compute.internal
>     
> 
> The above doesnt work, but if I list out the items
> with_items:
>      - ip-10-1-65-27.us-west-2.compute.internal
>      - ip-10-1-65-28.us-west-2.compute.internal
>      - ip-10-1-65-37.us-west-2.compute.internal
> 
> then it works, but I want it to be dynamic and find all ips matching      - 
> ip-10-1-*-*.us-west-2.compute.internal
> 
> any help please?



Vào 07:01:51 UTC+7 Thứ Sáu, ngày 02 tháng 2 năm 2018, Andrew Morgan đã viết:
> Hello all,
> 
> I have a play I want to run wich deletes all hosts matching a certain 
> criteria:
> 
> 
> 
> tasks:
>   - name: Delete unavailable nodes
>     zabbix_host:
>      server_url: http://zabbix.aa.net/zabbix
>      login_user: Admin
>      login_password: aq!
>      host_groups: Discovered hosts
>      status: disabled
>      state: absent
>      host_name: "{{ item }}"
>     with_items:
>      - ip-10-1-*-*.us-west-2.compute.internal
>     
> 
> The above doesnt work, but if I list out the items
> with_items:
>      - ip-10-1-65-27.us-west-2.compute.internal
>      - ip-10-1-65-28.us-west-2.compute.internal
>      - ip-10-1-65-37.us-west-2.compute.internal
> 
> then it works, but I want it to be dynamic and find all ips matching      - 
> ip-10-1-*-*.us-west-2.compute.internal
> 
> any help please?



Vào 07:01:51 UTC+7 Thứ Sáu, ngày 02 tháng 2 năm 2018, Andrew Morgan đã viết:
> Hello all,
> 
> I have a play I want to run wich deletes all hosts matching a certain 
> criteria:
> 
> 
> 
> tasks:
>   - name: Delete unavailable nodes
>     zabbix_host:
>      server_url: http://zabbix.aa.net/zabbix
>      login_user: Admin
>      login_password: aq!
>      host_groups: Discovered hosts
>      status: disabled
>      state: absent
>      host_name: "{{ item }}"
>     with_items:
>      - ip-10-1-*-*.us-west-2.compute.internal
>     
> 
> The above doesnt work, but if I list out the items
> with_items:
>      - ip-10-1-65-27.us-west-2.compute.internal
>      - ip-10-1-65-28.us-west-2.compute.internal
>      - ip-10-1-65-37.us-west-2.compute.internal
> 
> then it works, but I want it to be dynamic and find all ips matching      - 
> ip-10-1-*-*.us-west-2.compute.internal
> 
> any help please?

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


[ansible-project] Re: Ansible dynamic looping

2018-02-01 Thread Lê Mạnh Hùng
Vào 07:01:51 UTC+7 Thứ Sáu, ngày 02 tháng 2 năm 2018, Andrew Morgan đã viết:
> Hello all,
> 
> I have a play I want to run wich deletes all hosts matching a certain 
> criteria:
> 
> 
> 
> tasks:
>   - name: Delete unavailable nodes
>     zabbix_host:
>      server_url: http://zabbix.aa.net/zabbix
>      login_user: Admin
>      login_password: aq!
>      host_groups: Discovered hosts
>      status: disabled
>      state: absent
>      host_name: "{{ item }}"
>     with_items:
>      - ip-10-1-*-*.us-west-2.compute.internal
>     
> 
> The above doesnt work, but if I list out the items
> with_items:
>      - ip-10-1-65-27.us-west-2.compute.internal
>      - ip-10-1-65-28.us-west-2.compute.internal
>      - ip-10-1-65-37.us-west-2.compute.internal
> 
> then it works, but I want it to be dynamic and find all ips matching      - 
> ip-10-1-*-*.us-west-2.compute.internal
> 
> any help please?

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


[ansible-project] Ansible dynamic looping

2018-02-01 Thread Andrew Morgan
Hello all,

I have a play I want to run wich deletes all hosts matching a certain 
criteria:

tasks:
  - name: Delete unavailable nodes
zabbix_host:
 server_url: http://zabbix.aa.net/zabbix
 login_user: Admin
 login_password: aq!
 host_groups: Discovered hosts
 status: disabled
 state: absent
 host_name: "{{ item }}"
with_items:
 - ip-10-1-*-*.us-west-2.compute.internal



The above doesnt work, but if I list out the items
with_items:
 - ip-10-1-65-27.us-west-2.compute.internal
 - ip-10-1-65-28.us-west-2.compute.internal
 - ip-10-1-65-37.us-west-2.compute.internal

then it works, but I want it to be dynamic and find all ips matching  - 
ip-10-1-*-*.us-west-2.compute.internal

any help please?

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


[ansible-project] yum module is not listing the appd packages

2018-02-01 Thread geetha chowdary chalapati
I am running yum module to list the packages of appdynamics. But i am not 
able to see the packages

- name: Appdynamics packages
  yum:
list: Appdynamics*
  register: result

other way i tried is

- name: Appdynamics packages
  yum:
list: insatlled
  register: result


Regards,
geetha

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


[ansible-project] I want to curl --unix-socket

2018-02-01 Thread Chris7444
Is there an ansible module that will let me do the same ?  It seems the 
uri: module does not support unix sockets

I would like to avoid using the shell: or command: module if possible
Thanks

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


Re: [ansible-project] Is the following ansible documentation incorrect? "the first 10: --limit boston[1:10]". Shouldn't it be "--limit boston[0:9]"

2018-02-01 Thread Mike Cavedon
On Thursday, February 1, 2018 at 5:06:58 PM UTC-5, Kai Stian Olstad wrote:
>
> On Thursday, 1 February 2018 22.49.06 CET Mike Cavedon wrote: 
> > I'm seeing what appears to be two different definitions of how limits 
> work. 
> > There is the first one here: 
> > 
> > http://docs.ansible.com/ansible/latest/playbooks_best_practices.html 
> > 
> > What about just the first 10, and then the next 10?: 
> > 
> > ansible-playbook -i production webservers.yml --limit boston[1:10] 
> > ansible-playbook -i production webservers.yml --limit boston[11:20] 
>
> This is not correct so it a documentation bug. 
> To make the statement correct it should be boston[0:9] and boston[10:19] 
>
>
> > Then there appears to be a different definition here: 
> > 
> > http://docs.ansible.com/ansible/latest/intro_patterns.html 
> > 
> > You can select a host or subset of hosts from a group by their position. 
> > For example, given the following group: 
> > 
> > [webservers] 
> > cobweb 
> > webbing 
> > weber 
> > 
> > You can refer to hosts within the group by adding a subscript to the 
> group 
> > name: 
> > 
> > webservers[0]   # == cobweb 
> > webservers[-1]  # == weber 
> > webservers[0:1] # == webservers[0],webservers[1] 
> > # == cobweb,webbing 
> > webservers[1:]  # == webbing,weber 
>
> This is correct. 
>
>
> > Is it "--limit boston[1:2], or "--limit webservers[0:1]" for the first 
> 2? 
>
> "--limit webservers[0:1]" 
>
>
> -- 
> Kai Stian Olstad 
>

I entered a PR to correct the bug. thanks again

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


Re: [ansible-project] Is the following ansible documentation incorrect? "the first 10: --limit boston[1:10]". Shouldn't it be "--limit boston[0:9]"

2018-02-01 Thread Kai Stian Olstad
On Thursday, 1 February 2018 22.49.06 CET Mike Cavedon wrote:
> I'm seeing what appears to be two different definitions of how limits work. 
> There is the first one here:
> 
> http://docs.ansible.com/ansible/latest/playbooks_best_practices.html
> 
> What about just the first 10, and then the next 10?:
> 
> ansible-playbook -i production webservers.yml --limit boston[1:10]
> ansible-playbook -i production webservers.yml --limit boston[11:20]

This is not correct so it a documentation bug.
To make the statement correct it should be boston[0:9] and boston[10:19]


> Then there appears to be a different definition here:
> 
> http://docs.ansible.com/ansible/latest/intro_patterns.html
> 
> You can select a host or subset of hosts from a group by their position. 
> For example, given the following group:
> 
> [webservers]
> cobweb
> webbing
> weber
> 
> You can refer to hosts within the group by adding a subscript to the group 
> name:
> 
> webservers[0]   # == cobweb
> webservers[-1]  # == weber
> webservers[0:1] # == webservers[0],webservers[1]
> # == cobweb,webbing
> webservers[1:]  # == webbing,weber

This is correct.


> Is it "--limit boston[1:2], or "--limit webservers[0:1]" for the first 2?

"--limit webservers[0:1]"


-- 
Kai Stian Olstad

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


Re: [ansible-project] --limit [exclusive:inclusive] not working as expected

2018-02-01 Thread Mike Cavedon
On Thursday, February 1, 2018 at 4:36:15 PM UTC-5, Kai Stian Olstad wrote:
>
> On Thursday, 1 February 2018 22.28.46 CET Mike Cavedon wrote: 
> > On Thursday, February 1, 2018 at 4:03:33 PM UTC-5, Kai Stian Olstad 
> wrote: 
> > > It's start on 0 not 1 
> > > router[0] = rr01 
> > > 
> > > 
> > 
> > Is it [inclusive:inclusive], or is it [exclusive:inclusive]? I seem to 
> > recall the first parameter was exclusive. Maybe that was when 
> > [exclusive,inclusive] was supported? 
> > 
> > If I have: 
> > 
> > [router] 
> > rr[01:99] 
> > 
> > How do I deploy to hosts rr39 through rr49? 
>
> It's inclusive:inclusive. 
> Since it start with 0 rr39 is 38 and rr49 is 48 so -l router[38:48] 
>
>
> -- 
> Kai Stian Olstad 
>

Thanks. I asked another question about what appears to be a bug in the doc. 

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


[ansible-project] Is the following ansible documentation incorrect? "the first 10: --limit boston[1:10]". Shouldn't it be "--limit boston[0:9]"

2018-02-01 Thread Mike Cavedon
I'm seeing what appears to be two different definitions of how limits work. 
There is the first one here:

http://docs.ansible.com/ansible/latest/playbooks_best_practices.html

What about just the first 10, and then the next 10?:

ansible-playbook -i production webservers.yml --limit 
boston[1:10]ansible-playbook -i production webservers.yml --limit boston[11:20]


Then there appears to be a different definition here:

http://docs.ansible.com/ansible/latest/intro_patterns.html

You can select a host or subset of hosts from a group by their position. 
For example, given the following group:

[webservers]cobwebwebbingweber

You can refer to hosts within the group by adding a subscript to the group 
name:

webservers[0]   # == cobwebwebservers[-1]  # == weberwebservers[0:1]
 # == webservers[0],webservers[1]
# == cobweb,webbingwebservers[1:]  # == webbing,weber


Is it "--limit boston[1:2], or "--limit webservers[0:1]" for the first 2?

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


Re: [ansible-project] --limit [exclusive:inclusive] not working as expected

2018-02-01 Thread Mike Cavedon
On Thursday, February 1, 2018 at 4:03:33 PM UTC-5, Kai Stian Olstad wrote:
>
> On Thursday, 1 February 2018 21.49.44 CET Mike Cavedon wrote: 
> > I have the following hosts defined: 
> > 
> > [router] 
> > rr01 
> > rr[03:99] 
> > rr[100:114] 
> > 
> > I then execute a command that contains "--limit router[39:49]". Hosts 
> rr41 
> > through rr51 have the command executed on them. I'm expecting the 
> command 
> > to be executed on hosts rr41 through rr50. Why does the command execute 
> on 
> > host rr51? 
>
> It's start on 0 not 1 
> router[0] = rr01 
>
> -- 
> Kai Stian Olstad 
>

Is it [inclusive:inclusive], or is it [exclusive:inclusive]? I seem to 
recall the first parameter was exclusive. Maybe that was when 
[exclusive,inclusive] was supported?

If I have:

[router]
rr[01:99]

How do I deploy to hosts rr39 through rr49?

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


[ansible-project] How to do stuff on the remote Windows node from the command node?

2018-02-01 Thread skinnedknuckles
Linux Command Node:   CentOs 6,  Ansible 2.1, Python 2.7.13
Windows Remote Nodes:Windows 7, Powershell 3.0
Encryption: SSL

So far I've figured out how to use these tricks in my playbook to do stuff 
on the remote Windows node from the command node.  Are there other methods 
I've left out?

Use Ansible Modules 
 (especially 
those starting with "win_" 
) to 
do something on a remote node

  - name: Copy a windows file from control node to remote node
win_copy : 
src="/etc/ansible/winFiles/getFileVersion.exe" dest="C:/Temp/"

  -name: Restart a remote node
win_reboot: 


Use the Ansible "raw:" module 
 to run commands or 
executables on the remote node

  - name: Issue a Windows command to run on a remote node from control node 
raw: Rename  
C:/temp/oldName.txt
 
C:/temp/newName.txt

  - name: Issue a Powershell Cmdlet to run on a remote node from control 
node 
raw: Copy-Item 

 "C:/source/*.*" 
-Destination "C:/destination/"

  - name: Execute windows executable previously copied to a remote node 
from the control node
raw: C:/temp/getFileVersion.exe "C:/Windows/driver.dll"

Use the Ansible "script:" 
 module to *copy, 
run and delete* a Powershell module on the remote node from the control 
node.  

  - name: run a powershell script on a remote node from the control node
script:  
/etc/ansible/psScripts/doesItemExist.ps1 
"C:/TempBackup/"

Other ideas?

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


Re: [ansible-project] --limit [exclusive:inclusive] not working as expected

2018-02-01 Thread Kai Stian Olstad
On Thursday, 1 February 2018 21.49.44 CET Mike Cavedon wrote:
> I have the following hosts defined:
> 
> [router]
> rr01
> rr[03:99]
> rr[100:114]
> 
> I then execute a command that contains "--limit router[39:49]". Hosts rr41 
> through rr51 have the command executed on them. I'm expecting the command 
> to be executed on hosts rr41 through rr50. Why does the command execute on 
> host rr51?

It's start on 0 not 1
router[0] = rr01

-- 
Kai Stian Olstad

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


[ansible-project] --limit [exclusive:inclusive] not working as expected

2018-02-01 Thread Mike Cavedon
I have the following hosts defined:

[router]
rr01
rr[03:99]
rr[100:114]

I then execute a command that contains "--limit router[39:49]". Hosts rr41 
through rr51 have the command executed on them. I'm expecting the command 
to be executed on hosts rr41 through rr50. Why does the command execute on 
host rr51?

Thanks.

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


[ansible-project] --limit [exclusive, inclusive] not working as expected

2018-02-01 Thread Mike Cavedon
I have the following hosts defined:

[router]
rr01
rr[03:99]
rr[100:114]

I then execute a command that contains :--limit router[39:49]". Hosts rr41 
through rr51 have the command executed on them. I'm expecting the command 
to be executed on hosts rr41 through rr50. Why does the command execute on 
host rr51?

Thanks.

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


[ansible-project] Role to Create/Tear Down EC2 Instances

2018-02-01 Thread Justin Seiser
I have a few questions on handling the creation/tear down of an ec2 
instance. 

I have a role ( its a task atm, but Ill be migrating it over')

- name: dallascowboys | Deployments
  include_tasks:
tasks/customer-instance.yml
  vars:
customer_name: dallascowboys
customer_ip: '10.99.100.10'
customer_instance_count: 1
customer_eip_state: present
customer_eni_state: present
  tags:
- dallascowboys

- name: Customer | Configure ENI
  ec2_eni:
state: "{{ customer_eni_state }}"
description: '{{ customer_name }} ENI'
private_ip_address: '{{ customer_ip }}'
region: "{{ vpc_region }}"
security_groups: "{{ secgrp_appliance_id }}"
subnet_id: "{{ public_subnet_id }}"
  register: customer_eni


- name: Customer | Configure EIP
  ec2_eip:
state: "{{ customer_eip_state }}"
region: "{{ vpc_region }}"
in_vpc: true
device_id: "{{ customer_eni.interface.id }}"


- name: Customer | Configure EC2 Instance
  ec2:
key_name: "{{ aws_mfacloud_key }}"
instance_type: t2.medium
image: "{{ mfa_ami }}"
region: "{{ vpc_region }}"
instance_profile_name: '{{ role_appliance_name }}'
network_interfaces: "{{ customer_eni.interface.id }}"
user_data: "{{ lookup('file','windows-remoting') }}"
instance_tags:
  Name: ec2-cloudmfa-{{ customer_name }}-prd
  Customer: "{{ customer_name }}"
  Environment: prd
  Patch Group: cloudmfa
  Ansible: true
  AMI: True
count_tag:
  Name: ec2-cloudmfa-{{ customer_name }}-prd
exact_count: "{{ customer_instance_count }}"
  register: instance


- name: debug instance 
  debug:
var: instance


- name: Customer | Grab Password
  ec2_win_password:
instance_id: "{{ instance.tagged_instances[0].id }}"
region: "{{ vpc_region }}"
key_file: "~/.ssh/{{ aws_mfacloud_key }}.pem"
wait: yes
wait_timeout: 300
  register: winpass


This works OK to spin an instance up, my issue is when I want to destroy 
the instance for some reason.  I first set count to 0, which causes the job 
to fail because the ec2_win_password module.  So I run it again, with eip 
absent and this works, but again fails on the ec2_win_password.  I then run 
it a third time with eni absent, and it fails with the following error.

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": 
> "state is absent but all of the following are missing: eni_id"}



My issues are.  Is there a better way to create these instances?  Its going 
to be ~20 or so instances, that are configured the same, but will end up 
with different software on them.  So I cant just say "spin up 20 
instances".  Is there a better way to have ec2_win_password only execute 
when I have created, or started an instance?  As opposed to turned 
off/terminated an instance?  I assume im missing something obvious about 
the tear down of the EIP and ENI as well.

Sorry for the vagueness here, I know im probably missing some info that 
would be helpful so please just ask.

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


Re: [ansible-project] How to add os based variables into group_vars

2018-02-01 Thread Kai Stian Olstad
On Wednesday, 31 January 2018 05.43.36 CET sriman dharba wrote:
> - set_fact: repo_name="rhel_{{ ansible_distribution_major_version }}_repo"
> 
> 
> - name: 'Upgrading packages to latest'
>   yum:
>  name: "*"
>  state: latest
>  enablerepo: "{{ repo_name }}"
>   when: ansible_distribution == "RedHat" or ansible__distribution ==
> "CentOS"

- name: 'Upgrading packages to latest'
  yum:
 name: "*"
 state: latest
 enablerepo: "{{ vars[repo_name] }}"
  when: ansible_distribution == "RedHat" or ansible__distribution == "CentOS"

or just drop the set_fact and use 

- name: 'Upgrading packages to latest'
  yum:
 name: "*"
 state: latest
 enablerepo: "{{ vars['repo_' ~ ansible_distribution_major_version ~ 
'_repo'] }}"
  when: ansible_distribution == "RedHat" or ansible__distribution == "CentOS"


-- 
Kai Stian Olstad

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


[ansible-project] Re: Block/Always Always section not executing.

2018-02-01 Thread Josh Smift
There's a bunch of issues about 
this; https://github.com/ansible/ansible/issues/20736 is one, but I think 
maybe isn't yours. If you search there for "block always", though, you'll 
probably find some stuff.

(I also had to reply to this, since I used to also be Josh Smith. But a 
different one. :^ )

On Thursday, February 1, 2018 at 2:10:34 PM UTC-5, Josh Smith wrote:
>
> Hello everyone, 
>
> I was asking about this in the IRC channel yesterday when we experienced a 
> power outage at my office and I was thusly disconnected so I’m giving it a 
> try here now. 
>
> I have a playbook which contains include/import (I have tried both methods 
> with the same results) role statements in a Block/Always structure.  See 
> example here: 
>
> https://gist.github.com/jcsmith/c6688e1506f6136b5d858b29ccda5d74 
>
> When a task fails in the included/imported role in the block section the 
> always section never executes.  Is this expected behavior? 
>
> Thanks, 
> Josh 
>
>

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


[ansible-project] How to add os based variables into group_vars

2018-02-01 Thread sriman dharba
Hello,

I wanted to manage repo names from group_vars based on OS type. I have a
requirement to set reponames for different OS & versions like
Centos/Redhat/Ubuntu with all stable versions. The goal is to manage future
repo names from group_vars

My variables looks like this

group_vars/all.yml

---
rhel_5_repo: redhat-5-rpms-stable <-- name of the repo which i will use to
install latest kernel patches
rhel_6_repo: redhat-6-rpms-stable
rhel_7_repo: redhat-7-rpms-stable
ubuntu_12_repo: ubuntu-12-deb-stable

I would like to use use repo keys into roles based on
fact  ansible_distribution_major_version and fetch the variable from
group_vars

- set_fact: repo_name="rhel_{{ ansible_distribution_major_version }}_repo"

- name: 'Upgrading packages to latest'
  yum:
 name: "*"
 state: latest
 enablerepo: "{{ repo_name }}"
  when: ansible_distribution == "RedHat" or ansible__distribution ==
"CentOS"

How can i achieve this..Please suggest.

Thanks
Sri

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


[ansible-project] Block/Always Always section not executing.

2018-02-01 Thread Josh Smith
Hello everyone,

I was asking about this in the IRC channel yesterday when we experienced a 
power outage at my office and I was thusly disconnected so I’m giving it a try 
here now.

I have a playbook which contains include/import (I have tried both methods with 
the same results) role statements in a Block/Always structure.  See example 
here:

https://gist.github.com/jcsmith/c6688e1506f6136b5d858b29ccda5d74

When a task fails in the included/imported role in the block section the always 
section never executes.  Is this expected behavior?

Thanks,
Josh

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3CF41708-3E69-4A18-9E0F-A90E3ABAF3A4%40systems.wvu.edu.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to measure the time a task is taking to complete

2018-02-01 Thread Guillaume Coré
There is https://github.com/jlafon/ansible-profile

just put

callback_whitelist = profile_tasks

in you ansible.cfg


On Wed, Jan 24, 2018 at 5:38 PM, Narahari Lakshminarayana <
itsme.narah...@gmail.com> wrote:

> Friends:
>
> Is there a way to measure the amount of time it takes to run task so I can
> get an idea how much time we are spending to deploy packages ?
>
> -N
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/59e8194b-6cc5-4134-b6b0-638254dd12cd%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


[ansible-project] OPEN LDAP integration

2018-02-01 Thread Nawaz Ibrahim
Hi 

Is there any other steps we want to do other than configuring the LDAP 
details in the UI TOWER settings ? I need help !

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


[ansible-project] Re: Cygwin breaking ansible

2018-02-01 Thread lpescatore via Ansible Project
Bumping-Anyone at all know why?

On Tuesday, January 30, 2018 at 1:59:24 PM UTC-8, lpesc...@google.com wrote:
>
> Hi folks, I have a WEIRD problem. 
> After running cygwin ssh-host-config on my PC, which starts sshd and rsync 
> services, suddenly I can no longer run ansible. 
> I get this error:
>
> root@Raspi_Ctrl:/ansible/playbook/nuc# ansible -i /ansible/hosts nuc -m 
> win_ping
>
> * [WARNING]: FATAL ERROR DURING FILE TRANSFER: Traceback (most recent call 
> last):   File*
>
> *"/usr/local/lib/python2.7/dist-packages/ansible/plugins/connection/winrm.py",
>  
> line 276, in _winrm_exec*
>
> *self._winrm_send_input(self.protocol, self.shell_id, command_id, data, 
> eof=is_last)   File*
>
> *"/usr/local/lib/python2.7/dist-packages/ansible/plugins/connection/winrm.py",
>  
> line 256, in _winrm_send_input*
>
> *protocol.send_message(xmltodict.unparse(rq))   File 
> "/usr/local/lib/python2.7/dist-*
>
> *packages/winrm/protocol.py", line 207, in send_message return 
> self.transport.send_message(message)   File*
>
> *"/usr/local/lib/python2.7/dist-packages/winrm/transport.py", line 202, in 
> send_message raise*
>
> *WinRMTransportError('http', error_message) WinRMTransportError: (u'http', 
> u'Bad HTTP response returned from*
>
> *server. Code 500')*
>
>
> 100.126.255.201 | FAILED! => {
>
> "msg": "winrm send_input failed"
>
> }
>
> root@Raspi_Ctrl:/ansible/playbook/nuc# ansible -i /ansible/hosts nuc -m 
> win_ping
>
> *100.126.255.201 | UNREACHABLE! => {*
>
> *"changed": false, *
>
> *"msg": "basic: HTTPSConnectionPool(host='100.126.255.201', 
> port=5986): Max retries exceeded with url: /wsman (Caused by 
> ConnectTimeoutError( 0x749335b0>, 'Connection to 100.126.255.201 timed out. (connect 
> timeout=30)'))", *
>
> *"unreachable": true*
>
> *}*
>
>
>
>
> *When I run system restore to before this ssd-host-config, I can reach it 
> again. *
>
> *rsync uses port 873, sshd uses 22, and I believe ansible uses 5986 so 
> there should be no conflict. *
>
>
> *Has anyone else had this issue?*
>
>
> *By the way, this is the script that does the config. I do have this set 
> to become: so i dont think it's a privelege thing.*
>
>
> #!/bin/bash
>
>
> #::Configure sshd service
>
> if ! ssh-host-config --yes --pwd "foo"; then
>
> echo "ERROR: Failed to configure sshd"
>
> exit 1
>
> fi
>
> #echo db_home: /cygdrive/c/home/YRunner > C:\cygwin\etc\nsswitch.conf || 
> exit /b 1
>
>
> if ! net start sshd; then
>
> echo "ERROR: Failed to start sshd service."
>
> exit 1
>
> fi
>
>
> #configure the rsyncd service
>
> cat < /etc/rsyncd.conf
>
> use chroot = yes
>
>
> [yrunner_rsyncer]
>
> #path = /cygdrive/c/home/YRunner
>
> comment = YRunner Rsyncer
>
> auth users = YRunner
>
> secrets file = /etc/rsyncd.secrets
>
> write only = false
>
> read only = false
>
> list = true
>
> strict modes = false
>
> hosts allow = *
>
> EOF
>
>
>
> /usr/bin/cygrunsrv.exe --install "rsyncd" --path /usr/bin/rsync --args 
> "--daemon --no-detach" -f "Rsync daemon service"
>
> if [[ "$?" -ne 0 ]]; then
>
> echo "ERROR: Failed to install rsyncd service"
>
> exit 1
>
> fi
>
>
> net start rsyncd
>

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


[ansible-project] Running yml inside a playbook but different inventories

2018-02-01 Thread Ansible Krazy
Hi All,

I've a requirement where i want to run a playbook inside the main playbook,
however inventory(host) for inside playbook will be different

For example : main.ini will be having hosts

a, b, c, d

whereas inside.ini

r , h

Is it possible to achieve this ?

Any help will be appreciated

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


[ansible-project] Check disk space/cleanup if full

2018-02-01 Thread Gabriel Forster
Across a number of different flavors of Linux as well as AIX, I need to 
clean up our splunkforwarder space. I've tried numerous different 
approaches and am running into errors. This should be rather simple, but it 
is proving not to be.  Below is my latest iteration and some of the 
relevant errors. 

My next approach will to be straight up df -h (df -g for aix) with some awk 
stuff...also checking if the mount even exists (it doesn't necessarily on 
every system). But, I think this should be simpler to do with normal 
Ansible modules.

Any ideas on the obvious bits I'm missing?

*Relevant playbook portion:*

  tasks:
#- name: Test for 20% disk space available
#  assert:
#that:
#  - not {{ item.mount == '/opt/splunkforwarder' and ( 
item.size_available > (item.size_total|float * 0.6) ) }}
#  with_items: '{{ ansible_mounts }}'
#  ignore_errors: yes
#  register: disk_free

- name: Test for 20% disk space available on {{ mountname }}
  assert:
that: mount.size_available > mount.size_total|float * 0.2
msg: Disk space has reached the 80% threshold
  register: disk_free

- name: For full systems, run splunk clean
  command: "/opt/splunkforwarder/bin/splunk clean all -f"
  when: disk_free|failed

  vars:
mountname: '/opt/splunkforwarder' 
mount: "{{ ansible_mounts | selectattr('mount','equalto', mountname) | 
first }}"

*Errors:*
FAILED! => {"msg": "The conditional check '{ mount.size_available > 
mount.size_total|float * 0.2 }' failed. The error was: template error while 
templating string: expected token ':', got '}'. String: {% if { 
mount.size_available > mount.size_total|float * 0.2 } %} True {% else %} 
False {% endif %}\n\nThe error appears to have been in 
'/app/ansible-playbooks/splunk-clean.yml': line 18, column 7, but may\nbe 
elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n- name: For full systems, run splunk 
clean\n  ^ here\n"}

FAILED! => {"msg": "The conditional check 'mount.size_available > 
mount.size_total|float * 0.2' failed. The error was: error while evaluating 
conditional (mount.size_available > mount.size_total|float * 0.2): {{ 
ansible_mounts | selectattr('mount','equalto', mountname) | first }}: No 
first item, sequence was empty."}



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


[ansible-project] ansible conditions

2018-02-01 Thread Sudhir Kumar
Hi,

Below snippet sometimes working and sometimes failing. So, i am executing 
it with jenkins and idea is that if parameter is defined then script should 
run otherwise it should not run. 

Can anyone please enlighten me what's wrong ?

#
  - name: Executing lvm script 
shell: /tmp/lvm-script.sh sdb {{ vg_name }} {{ mtpt_size }} 
args:
  chdir: /tmp/
when: vg_name is defined
##

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


Re: [ansible-project] Re: Item name in task name.

2018-02-01 Thread Kai Stian Olstad
On Thursday, 1 February 2018 16.10.27 CET Varun Chopra wrote:
> Yeah, you're right!

There is a workaround to get if you want it, it involves include_tasks.

file-to-include.yml
---
- name: Installing {{ item }}
  yum:
name: "{{ item }}"
state: latest



tasks:
  - include_tasks: file-to-include.yml
with_items:
  - httpd
  - firewalld


But this will be a bit slower since you are running yum one by one for each 
item.
When you have with_items on the yum task it will install all of them in one yum 
command.


-- 
Kai Stian Olstad

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


[ansible-project] assert and fail. When to use what?

2018-02-01 Thread Varun Chopra
Hi,

I've been working on a playbook that asserts prerequisites required for a 
mssql installation and I'm not entirely confident with what I've come up 
with.

https://gist.githubusercontent.com/chopraaa/1b74480a7b286ee91dd855ae670104f1/raw/660b758b4e82e0b68e6fe73946d005cfcac9/mssql.yml

What I know is that if an assert is false, it fails the playbook, and the 
same can be done using the fail module. So what's the difference between 
the two?

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


[ansible-project] Re: Item name in task name.

2018-02-01 Thread Varun Chopra
Yeah, you're right!

Thanks!

On Thursday, February 1, 2018 at 3:56:32 AM UTC+5:30, Malcolm 
Hussain-Gambles wrote:
>
> I don't think you can do that, as the item isn't defined when it prints 
> the name section. I also seem to remember that certain modules,like yum 
> will process the list in one go. Rather than doing two yum installs.

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


[ansible-project] Re: Item name in task name.

2018-02-01 Thread Varun Chopra
This doesn't matter.

On Thursday, February 1, 2018 at 1:37:49 AM UTC+5:30, ZillaYT wrote:
>
> Try enclosing the name in double-quotes, e.g.,
>
>   tasks:
> - name: "Installing {{ item }}"
>   yum:
> name: "{{ item }}"
> state: latest
>   with_items:
> - httpd
> - firewalld
>
>
> On Monday, January 29, 2018 at 11:02:58 AM UTC-5, Varun Chopra wrote:
>>
>> Hi,
>>
>> I'm trying to display the item name in the name of the task but it 
>> doesn't work as intended.
>>
>> Here's part of my play:
>>
>>   tasks:
>> - name: Installing {{ item }}
>>   yum:
>> name: "{{ item }}"
>> state: latest
>>   with_items:
>> - httpd
>> - firewalld
>>
>> This is what I get when I run the play:
>>
>> TASK [Installing {{ item }}] 
>> **
>> ok: [servera.example.com] => (item=[u'httpd', u'firewalld'])
>>
>> Is this supposed to work this way? I
>>
>>

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


Re: [ansible-project] Re: Ansible & Jenkins integration issue

2018-02-01 Thread GornerM
I have launched empty Ubuntu 16.04 system and installed ansible & required 
ansible modules in following way:
-
sudo su
apt-get install python-pip
apt-get install python-dev libxml2-dev libxslt-dev libssl-devlibffi-dev
pip install junos-eznc
apt-get install ansible
ansible-galaxy install Juniper.junos  
ansible-galaxy install --roles-path . Juniper.jenkins
ansible-galaxy install --roles-path /etc/ansible/roles Juniper.jenkins
ansible-galaxy install Juniper.jenkins
pip install -U jxmlease
pip install ncclient
---
Possibly is it required to install additional packages for ansible?

Ansible project (ansible.cfg, hosts, test2.yml) has been installed in three 
different directories: /ets/ansible, /root/.ansible ; 
/root/Project_22.01.2018

Now each time when I run playbook from different directories I receive the 
same error output:


root@Jenkins:~/Project_22.01.2018# /usr/bin/ansible-playbook test2.yml -f 1 
--private-key ~/.ssh/id_rsa -u root -v
Using /root/Project_22.01.2018/ansible.cfg as config file
Loaded callback jsnapy of type aggregate, v2.0
Loaded callback default of type stdout, v2.0
1 plays in test2.yml

PLAY [GET] 
*

TASK [CHECK-NETCONF] 
***
task path: /root/Project_22.01.2018/test2.yml:14
ESTABLISH LOCAL CONNECTION FOR USER: root
10.10.10.11 EXEC mkdir -p "$( echo 
$HOME/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332 )" && echo "$( 
echo $HOME/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332 )"
10.10.10.11 PUT /tmp/tmpukU7TW TO 
/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/wait_for
10.10.10.11 EXEC LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 
LC_MESSAGES=en_US.UTF-8 /usr/bin/python 
/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/wait_for; rm 
-rf "/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/" > 
/dev/null 2>&1
ok: [10.10.10.11] => {"changed": false, "elapsed": 0, "invocation": 
{"module_args": {"connect_timeout": 5, "delay": 0, "exclude_hosts": null, 
"host": "10.219.167.11", "path": null, "port": "830", "search_regex": null, 
"state": "started", "timeout": "5"}, "module_name": "wait_for"}, "path": 
null, "port": 830, "search_regex": null, "state": "started"}

TASK [Retrive information from devices running Junos OS] 
***
task path: /root/Project_22.01.2018/test2.yml:17
fatal: [10.10.10.11]: FAILED! => {"failed": true, "msg": "ERROR! the 
handler 'juniper_junos_facts' was not found"}

PLAY RECAP 
*
10.10.10.11  : ok=1changed=0unreachable=0failed=1


Here is my test ansible project:
root@Jenkins:~/Project_22.01.2018# pwd
/root/Project_22.01.2018
root@Jenkins:~/Project_22.01.2018# ll
total 60
drwxr-xr-x 5 root root  4096 Feb  1 14:56 ./
drwx-- 7 root root  4096 Feb  1 14:56 ../
-rw-r--r-- 1 root root   338 Feb  1 14:56 ansible.cfg
drwxr-xr-x 8 root root  4096 Feb  1 14:46 .git/
-rw-r--r-- 1 root root69 Feb  1 14:46 hosts
drwxr-xr-x 4 root root  4096 Feb  1 14:46 roles/
-rw-r--r-- 1 root root   567 Feb  1 14:46 test2.yml
root@Jenkins:~/Project_22.01.2018#

--- ansible.cfg
[defaults]
inventory=./hosts
remote_user=root
ask_pass=False
transport = netconf
host_key_checking = False
roles_path = 
/etc/ansible/roles:/root/.ansible/roles:/root/Project_22.01.2018/roles
library = 
/etc/ansible/roles/Juniper.junos/library:/root/.ansible/roles/Juniper.junos/library:/root/Project_22.01.2018/roles/Juniper.junos/library
- hosts
[vsrx]
10.219.167.11 ansible_ssh_user=root ansible_connection=local
- test2.yml
---
- name: GET
  hosts: vsrx
  roles:
  - Juniper.junos
  connection: local
  gather_facts: no
  vars:
ansible_python_interpreter: /usr/bin/python

  # Execute tasks (plays) this way "ansible-playbook /GET.yml --tags 
"
  tasks:
  # Check if a device is NETCONF-aware
  - name: CHECK-NETCONF
wait_for: host={{ inventory_hostname }} port=830 timeout=5

  - name: Retrive information from devices running Junos OS
juniper_junos_facts:
  host: "{{ inventory_hostname }}"
register: junos

  - name: version
debug:
  var: junos


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


Re: [ansible-project] Re: Ansible & Jenkins integration issue

2018-02-01 Thread GornerM
root@Jenkins:~/Project_22.01.2018# pwd
/root/Project_22.01.2018
root@Jenkins:~/Project_22.01.2018# ll
total 60
drwxr-xr-x 5 root root  4096 Feb  1 14:56 ./
drwx-- 7 root root  4096 Feb  1 14:56 ../
-rw-r--r-- 1 root root   338 Feb  1 14:56 ansible.cfg
drwxr-xr-x 8 root root  4096 Feb  1 14:46 .git/
-rw-r--r-- 1 root root69 Feb  1 14:46 hosts
drwxr-xr-x 4 root root  4096 Feb  1 14:46 roles/
-rw-r--r-- 1 root root   567 Feb  1 14:46 test2.yml

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


Re: [ansible-project] Re: Ansible & Jenkins integration issue

2018-02-01 Thread GornerM
I have launched empty Ubuntu 16.04 system and installed ansible & required 
ansible modules in following way:


sudo apt-get install python-pip

sudo apt-get install python-dev libxml2-dev libxslt-dev libssl-dev 
   libffi-dev

sudo pip install junos-eznc

apt-get install ansible

ansible-galaxy install Juniper.junos

ansible-galaxy install --roles-path /etc/ansible/roles Juniper.junos

ansible-galaxy install --roles-path . Juniper.junos

pip install -U jxmlease

pip install -U jxmlease

pip install ncclient
===
Possible is it required installation some additional packets for ansible?

Python version is 2.7.12.

I installed test ansible project (ansible.cfg, test2.yml, hosts), 
Juniper.junos module at different directories: /etc/ansible 
; /root/.ansible/ ; /root/Project_22.01.2018/roles/

And now the issue is reproduced each time when I run playbook from cli.


 
Here is my test ansible project

[defaults]
inventory=./hosts
remote_user=root
ask_pass=False
transport = netconf
host_key_checking = False
roles_path = 
/etc/ansible/roles:/root/.ansible/roles:/root/Project_22.01.2018/roles
library = 
/etc/ansible/roles/Juniper.junos/library:/root/.ansible/roles/Juniper.junos/library:/root/Project_22.01.2018/roles/Juniper.junos/library

#test2.yml
---
- name: GET
  hosts: vsrx
  roles:
  - Juniper.junos
  connection: local
  gather_facts: no
  vars:
ansible_python_interpreter: /usr/bin/python

  # Execute tasks (plays) this way "ansible-playbook /GET.yml --tags 
"
  tasks:
  # Check if a device is NETCONF-aware
  - name: CHECK-NETCONF
wait_for: host={{ inventory_hostname }} port=830 timeout=5

  - name: Retrive information from devices running Junos OS
juniper_junos_facts:
  host: "{{ inventory_hostname }}"
register: junos

  - name: version
debug:
  var: junos

#hosts
[vsrx]
10.10.10.11 ansible_ssh_user=root ansible_connection=local
ansible_python_interpreter=/usr/bin/python
---
---

Here is cli output:

root@Jenkins:~/Project_22.01.2018# /usr/bin/ansible-playbook test2.yml -f 1 
--private-key ~/.ssh/id_rsa -u root -v
Using /root/Project_22.01.2018/ansible.cfg as config file
Loaded callback jsnapy of type aggregate, v2.0
Loaded callback default of type stdout, v2.0
1 plays in test2.yml

PLAY [GET] 
*

TASK [CHECK-NETCONF] 
***
task path: /root/Project_22.01.2018/test2.yml:14
ESTABLISH LOCAL CONNECTION FOR USER: root
10.219.167.11 EXEC mkdir -p "$( echo 
$HOME/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332 )" && echo "$( 
echo $HOME/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332 )"
10.219.167.11 PUT /tmp/tmpukU7TW TO 
/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/wait_for
10.219.167.11 EXEC LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 
LC_MESSAGES=en_US.UTF-8 /usr/bin/python 
/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/wait_for; rm 
-rf "/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/" > 
/dev/null 2>&1
ok: [10.219.167.11] => {"changed": false, "elapsed": 0, "invocation": 
{"module_args": {"connect_timeout": 5, "delay": 0, "exclude_hosts": null, 
"host": "10.219.167.11", "path": null, "port": "830", "search_regex": null, 
"state": "started", "timeout": "5"}, "module_name": "wait_for"}, "path": 
null, "port": 830, "search_regex": null, "state": "started"}

TASK [Retrive information from devices running Junos OS] 
***
task path: /root/Project_22.01.2018/test2.yml:17
fatal: [10.219.167.11]: FAILED! => {"failed": true, "msg": "ERROR! the 
handler 'juniper_junos_facts' was not found"}

PLAY RECAP 
*
10.219.167.11  : ok=1changed=0unreachable=0failed=1





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


[ansible-project] Re: Need help about Ansible block syntax

2018-02-01 Thread JiElPe-Fr38
Thanks all for your help.
I have been really bored with the block... but I finally succeed. The 
ansible / yaml syntax is not always straightforward to understand (or I 
lack some skills).

I went back to the ansible block documentation 
, and make a 
trial replacing my main.yml file with the example on the page, i.e.  :
cat roles/devTools/tasks/main.yml
tasks:
  - name: Install Apache
block:
  - yum: name={{ item }} state=installed
with_items:
  - httpd
  - memcached
  - template: src=templates/src.j2 dest=/etc/foo.conf
  - service: name=bar state=started enabled=True
when: ansible_distribution == 'CentOS'
become: true
become_user: root

And I still get an error saying that the role must contain a list of task :
ERROR! The tasks/main.yml file for role 'devTools' must contain a list of 
tasks

The error appears to have been in 
'/home/jeanlupi/centos_test/myKnowledge/devOps/playbook/roles/devTools/tasks/main.yml'
: line 1, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


tasks:
^ here

Ok... I removed "tasks" (don't clearly understand why it must not be 
there...) and the problem disappeared.
After several other syntax errors (probably not totally sticked to block), 
I succeeded with :

cat roles/devTools/tasks/RedHat.yml
  - name: Update Red Hat machine
block:
  - yum: update_cache=yes name="*" state=latest
notify: "restart {{ ansible_os_family }} host"
  - yum: name="{{item}}" state=present
with_items: "{{ toolList }}"
notify: "restart {{ ansible_os_family }} host"
when: ansible_pkg_mgr == 'yum'
become: true
become_user: root



As mentioned in the answers, notify must not be set at block level, but 
after each enclosed task.

Thanks for your help.
Have a nice day.
JiElPe

Le mercredi 31 janvier 2018 16:29:00 UTC+1, JiElPe-Fr38 a écrit :
>
> Dear all,
>
> I am quite new to Ansible and try to "make a tour"...
> I am using ansible 2.4.2.0 with cygwin64 on Win7.
>
>
> I am currently make a personal training and find that I could use a block 
> to "enclose" (ok, perhaps wrong term) a couple of task that have some 
> common "properties" (like become_user: root ...).
> The idea is to change this :
>
> ---
> - name: Update Red Hat machine
>   yum:
> update_cache: yes
> name: '*'
> state: latest
>   when: ansible_pkg_mgr == 'yum'
>   become: true
>   become_user: root
>   ignore_errors: yes
>   notify: "restart {{ ansible_os_family }} host"
>
> - name: Install RedHat tools
>   yum:
> name: "{{ item }}"
> state: present
>   with_items: "{{ toolList }}"
>   when: ansible_pkg_mgr == 'yum'
>   become: true
>   become_user: root
>   ignore_errors: yes
>   notify: "restart {{ ansible_os_family }} host"
>
>
>
> into a block based syntax so that I can factorize the become / notify and 
> when statement.
> II have made several trials without any success.
> Playing the file below :
> ---
> -block:
>   - name: Update Red Hat machine
> yum:
>   update_cache: yes
>   name: '*'
>   state: latest
>
>   - name: Install RedHat tools
> yum:
>   name: "{{ item }}"
>   state: present
>   with_items: "{{ toolList }}"
>
>   when: ansible_pkg_mgr == 'yum'
>   become: true
>   become_user: root
>   ignore_errors: yes
>   notify: "restart {{ ansible_os_family }} host"
>
> I get this error :
> fatal: [ci-server]: FAILED! => {"reason": "Syntax Error while loading 
> YAML.\n\n\nThe error appears to have been in 
> '/home/jeanlupi/centos_test/myKnowledge/devOps/playbook/roles/devTools/tasks/RedHat.yml':
>  
> line 16, column 3, but may\nbe elsewhere in the file depending on the exact 
> syntax problem.\n\nThe offending line appears to be:\n\n\n  when: 
> ansible_pkg_mgr == 'yum'\n  ^ here\n\nexception type:  'yaml.parser.ParserError'>\nexception: while parsing a block collection\n  
> in \"\", line 3, column 3:\n  - name: Update Red Hat 
> machine\n  ^\nexpected , but found '?'\n  in \" string>\", line 16, column 3:\n  when: ansible_pkg_mgr == 'yum'\n  
> ^"}
>
>
>
> If someone could help I would be very glad ! 
>
> Thanks !
> JiElPe
>
>

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


[ansible-project] Create AWS RDS with Ansible script

2018-02-01 Thread Reddy Myyb
I have a requirement to create AWS RDS for Oracle Standard Edition 2. I 
have created the script and gave values as available in the AWS RDS 
console. The problem is Ansible is not accepting the Engine version 
available in the AWS console. I'm using the exact version and the fields 
mentioned in AWS console. If the script accepts the version it says the 
instance type doesn't match and I'm not able to find the correct engine 
version and instance type together. I searched the aws docs for the engine 
and instance type mappings and used the same, but still the script fails to 
create the rds and complaints about either of them.Please find below my 
script. Any suggestions welcome !

Below is my role:

- rds:
aws_access_key: X
aws_secret_key: xxx
command: create
license_model: license-included
instance_name: Prod
db_engine: oracle-se2
db_name: ERPDB
engine_version: 11.2.0.4
port: 1433
region: ap-southeast-2
size: 300
#iops:
#instance_type: db.m4.2xlarge
instance_type: db.t2.micro
username: oracle_admin
password: x
tags:
  Environment: Production
  Application: APAC

Below is my playbook:

---
 - hosts: localhost
   become: yes
   become_method: sudo
   roles:
  - { role: rds-ora }

Below is the error:

PLAY [localhost] 


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

TASK [rds-ora : rds] 

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to create 
instance: Cannot find version 11.2.0.4 for oracle-se2"}
to retry, use: --limit @/home/ec2-user/callrds.retry

PLAY RECAP 
**
localhost  : ok=1changed=0unreachable=0failed=1

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