Re: [ansible-project] F5 Policy with Multiple Rules

2020-03-31 Thread Dick Visser
By adding an extra key:

rules:
- name: rule1
  policy: Policy-Foo
  actions:
- type: forward
  pool: pool-svrs
  conditions:
- type: http_uri
  path_starts_with: /euro
- name: rule2
  policy: Policy-Bar
  actions:
- type: forward
  pool: pool-svrs
  conditions:
- type: http_uri
  path_starts_with: /HomePage/

Your task would be looking like this:


- name: Add multiple rules to the new policy
  bigip_policy_rule:
policy: "{{ item.policy }}"
name: "{{ item.name }}"
conditions: "{{ item.conditions }}"
actions: "{{ item.actions }}"
provider:
  server: lb.mydomain.com
  user: admin
  password: secret
  delegate_to: localhost
  loop: "{{ rules }}"


Dick


On Wed, 1 Apr 2020 at 02:20, Sharon Day  wrote:
>
> I'm having trouble getting my variables correct to add multiple rules to a 
> single policy.  I need a loop because I will be adding multiple VIP with 
> different policy names and multiple rules per policy.   The module I'm using 
> is bigip_policy_rule.
>
> - name: Add multiple rules to the new policy
>   bigip_policy_rule:
> policy: Policy-Foo  <-- I want to use a variable for the policy name 
> as well
> name: "{{ item.name }}"
> conditions: "{{ item.conditions }}"
> actions: "{{ item.actions }}"
> provider:
>   server: lb.mydomain.com
>   user: admin
>   password: secret
>   delegate_to: localhost
>   loop: "{{ rules }}"
>
> Variables file looks like this:
>
> rules:
>
> - name: rule1
>   actions:
> - type: forward
>   pool: pool-svrs
>   conditions:
> - type: http_uri
>   path_starts_with: /euro
> - name: rule2
>   actions:
> - type: forward
>   pool: pool-svrs
>   conditions:
> - type: http_uri
>   path_starts_with: /HomePage/
>
> My question is how can I create a variable for the policy instead of entering 
> it in my playbook task?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "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/a713a018-8eee-4e48-ab20-4aa1ab5e0f37%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/CAL8fbwN1dybg218aJoK%2BbGoJ2gQAMu3Vkaxuz0PPDyHKTQeaGA%40mail.gmail.com.


Re: [ansible-project] Ignore imported playbooks completely when defined

2020-03-31 Thread Stefan Hornburg (Racke)
On 3/31/20 9:00 PM, Ronen Levinson wrote:
> Hi, 
> 
> I'm using ansible version 2.7.17 and combining multiple playbooks in one file.
> One of my playbooks I'm running conditionally with when and a condition.
> My problem is when my condition is false, I want ansible to completely ignore 
> my playbook and not load anything related
> to this playbook.
> I tried using both import_playbook and include, which seems to have similar 
> results.
> The call to the playbook looks like that:
> 
> - name: Include kubespray tasks
> include: ../kubespray/cluster.yml
> when: cluster_installation
> 
> in my output you can see ansible run the handlers inside the ignored playbook 
> (keeping for 2 more minutes):
> 
> PLAYBOOK: cluster.yml
> ***
> 16 plays in cluster.yml
> 
> PLAY [localhost]
> 
> META: ran handlers
> Tuesday 31 March 2020 18:55:46 + (0:00:00.043) 0:00:00.043 *
> META: ran handlers
> META: ran handlers
> [WARNING]: Could not match supplied host pattern, ignoring: bastion
> 
> 
> PLAY [bastion[0]]
> ***
> skipping: no hosts matched
> 
> PLAY [k8s-cluster:etcd]
> *
> META: ran handlers
> Tuesday 31 March 2020 18:55:46 + (0:00:00.037) 0:00:00.081 *
> Tuesday 31 March 2020 18:55:46 + (0:00:00.049) 0:00:00.130 *
> Tuesday 31 March 2020 18:55:46 + (0:00:00.048) 0:00:00.178 *
> Tuesday 31 March 2020 18:55:46 + (0:00:00.051) 0:00:00.230 *
> Tuesday 31 March 2020 18:55:46 + (0:00:00.024) 0:00:00.254 *
> Tuesday 31 March 2020 18:55:46 + (0:00:00.021) 0:00:00.275 *
> 
> Thanks for the help,
> Ronen

Hello Ronen,

as far as I know that's not possible. Ansible will parse the role even if the 
condition evalulates to false.
Also note that allows you to use the variables in the role, even if all tasks 
are skipped due to the condition.

Does it really run the handlers? I don't see no output indicating this.

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/ce7a36bb-ceab-46ee-ae75-817417cc8fb7%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/7d3c030b-857a-e056-a929-c11271bd2292%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


Re: [ansible-project] Re: win_xml module 'cannot call a method on a null-valued expression'

2020-03-31 Thread Dick Visser
Hi

While that does work, it looks like the xpath expression is flattening too
much with all those wildcards.
The correct way would be to provide the actual namespace, this is supported
by the module:

https://docs.ansible.com/ansible/latest/modules/xml_module.html#parameter-namespaces

Dick



On Wed, 1 Apr 2020 at 03:27, Dave York  wrote:

> I figured this out.  Turned out that my xml was using a different
> namespace? I had to follow guidance I found on stackoverflow:
> https://stackoverflow.com/questions/5239685/xml-namespace-breaking-my-xpath
>
> So my play now looks like this (and works):
>   tasks:
>   - name: Test modifying XML
> win_xml:
>   path: e:\jboss-eap-6.4\X\configuration\domain.xml
>   xpath:
> '/*[local-name()="domain"]/*[local-name()="server-groups"]/*[local-name()="server-group"]/*[local-name()="jvm"]/*[local-name()="heap"]'
>   attribute: 'size'
>   fragment: '123m'
>   type: attribute
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/4c0d8605-8923-4346-bb06-e252c1a18142%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/CAL8fbwN86DO0Vympw%2B_uWRb5auwGHVFVnZmyz0-Kr%2BN-haUuQw%40mail.gmail.com.


[ansible-project] Re: win_xml module 'cannot call a method on a null-valued expression'

2020-03-31 Thread Dave York
I figured this out.  Turned out that my xml was using a different 
namespace? I had to follow guidance I found on stackoverflow:
https://stackoverflow.com/questions/5239685/xml-namespace-breaking-my-xpath

So my play now looks like this (and works):
  tasks:
  - name: Test modifying XML
win_xml:
  path: e:\jboss-eap-6.4\X\configuration\domain.xml
  xpath: 
'/*[local-name()="domain"]/*[local-name()="server-groups"]/*[local-name()="server-group"]/*[local-name()="jvm"]/*[local-name()="heap"]'
  attribute: 'size'
  fragment: '123m'
  type: attribute

-- 
You received this message because you are subscribed to the Google Groups 
"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/4c0d8605-8923-4346-bb06-e252c1a18142%40googlegroups.com.


Re: [ansible-project] Ansible Reboot Error...

2020-03-31 Thread kmarty009
I got it all working.  I had to update the hosts, file and use new syntax 
that was outlined in the documentation.  Thanks everyone, I'm all good!  

On Tuesday, March 31, 2020 at 7:02:01 PM UTC-5, kmarty009 wrote:
>
> Interesting!  Thanks for the responses!  I really appreciate it.  
>
> I'm new to ansible and trying to get into a love affair with it.  I'm 
> running CentOS 7.7.1908 and Ansible 2.4.2.0 was installed.  
>
> I did a yum install epel-release and I got installed new version at 2.9.6  
>
> Of course, that worked and rebooted my machine!  However, I did run into 
> new issues with DEPRECATION WARNING.  I think it's not liking the 
> state=installed.  If I'm reading the manual (RTFM) it wants a newer flag of 
> state=present.  
>
> I also don't think it's loving the {{ item }} flag and wants something 
> different.  {{ packages }}?  
>
> [DEPRECATION WARNING]: Invoking "yum" only once while using a loop via 
> squash_actions is deprecated. Instead of using a loop to supply
> multiple items and specifying `pkg: "{{ item }}"`, please use `pkg: 
> ['nano', 'vim', 'tar', 'xz', 'unzip', 'wget', 'curl', 'bind-utils', 'net-
> tools', 'ntp', 'epel-release']` and remove the loop. This feature will be 
> removed in version 2.11. Deprecation warnings can be disabled by
> setting deprecation_warnings=False in ansible.cfg.
> [DEPRECATION WARNING]: Invoking "yum" only once while using a loop via 
> squash_actions is deprecated. Instead of using a loop to supply
> multiple items and specifying `pkg: "{{ item }}"`, please use `pkg: 
> ['nano', 'vim', 'tar', 'xz', 'unzip', 'wget', 'curl', 'bind-utils', 'net-
> tools', 'ntp', 'epel-release']` and remove the loop. This feature will be 
> removed in version 2.11. Deprecation warnings can be disabled by
> setting deprecation_warnings=False in ansible.cfg.
>
>
>
> On Tuesday, March 31, 2020 at 3:22:35 PM UTC-5, Dick Visser wrote:
>>
>> This usually means that the ansible version you use does not know that 
>> module. 
>> According to 
>> https://docs.ansible.com/ansible/latest/modules/reboot_module.html 
>> the reboot module was introduced in 2.7. 
>> This indicates you're using something older. 
>>
>> What is the output of 'ansible --version'? 
>>
>>
>>
>> On Tue, 31 Mar 2020 at 21:11, kmarty009  wrote: 
>> > 
>> > I get this error when executing my playbook.  I need to reboot the 
>> machine but cannot get around this insane error that is preventing me from 
>> doing so.. the plybook works until I add the last line for reboot.  Can 
>> anyone tell me what is wrong here please???  Thanks in advance. 
>> > 
>> >  ERROR SECTION* 
>> > 
>> > ERROR! no action detected in task. This often indicates a misspelled 
>> module name, or incorrect module path. 
>> > 
>> > The error appears to have been in 
>> '/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but 
>> may 
>> > be elsewhere in the file depending on the exact syntax problem. 
>> > 
>> > The offending line appears to be: 
>> > 
>> > 
>> > - name: Reboot Machine 
>> >   ^ here 
>> > 
>> > 
>> > The error appears to have been in 
>> '/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but 
>> may 
>> > be elsewhere in the file depending on the exact syntax problem. 
>> > 
>> > The offending line appears to be: 
>> > 
>> > 
>> > - name: Reboot Machine 
>> >   ^ here 
>> > 
>> > exception type:  
>> > exception: no action detected in task. This often indicates a 
>> misspelled module name, or incorrect module path. 
>> > 
>> > The error appears to have been in 
>> '/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but 
>> may 
>> > be elsewhere in the file depending on the exact syntax problem. 
>> > 
>> > The offending line appears to be: 
>> > 
>> > 
>> > - name: Reboot Machine 
>> >   ^ here 
>> > 
>> >  PLAYBOOK** 
>> > 
>> > 
>> > #Ansible Configuration Playbook for On-Premise Installs 
>> > #Created by: Kirk Marty kmar...@gmail.com 
>> > #Version 1.0 
>> > #Date: 3/31/2020 
>> > 
>> > - name: "Required Software Packages that will be utilized - yum 
>> installs" 
>> >   yum: pkg={{ item }} state=installed 
>> >   with_items: 
>> >   - nano 
>> >   - vim 
>> >   - tar 
>> >   - xz 
>> >   - unzip 
>> >   - wget 
>> >   - curl 
>> >   - bind-utils 
>> >   - net-tools 
>> >   - ntp 
>> >   - epel-release 
>> > 
>> > # Update the system to latest patches and applications via yum 
>> > 
>> > - name: "update the Centos Server 7 with latest patches and 
>> applications" 
>> >   yum: 
>> > name: "*" 
>> > state: latest 
>> > 
>> > - name: be sure firewalld is installed 
>> >   yum: name=firewalld state=installed 
>> >   tags: 
>> >- install 
>> >- firewalld 
>> > 
>> > - name: be sure firewalld is disabled 
>> >   systemd: name=firewalld enabled=no 
>> >   tags: 
>> >- install 
>> >- atomic 
>> >- firewalld 
>> > 
>> > - name: be sure firewalld is stopped 
>> >   systemd: name=firewalld state=stopped 
>> >   ignore_errors: 

[ansible-project] F5 Policy with Multiple Rules

2020-03-31 Thread Sharon Day
I'm having trouble getting my variables correct to add multiple rules to a 
single policy.  I need a loop because I will be adding multiple VIP with 
different policy names and multiple rules per policy.   The module I'm 
using is bigip_policy_rule.

- name: Add multiple rules to the new policy
  bigip_policy_rule:
policy: Policy-Foo  <-- I want to use a variable for the policy name as 
well
name: "{{ item.name }}"
conditions: "{{ item.conditions }}"
actions: "{{ item.actions }}"
provider:
  server: lb.mydomain.com
  user: admin
  password: secret
  delegate_to: localhost
  loop: "{{ rules }}"

Variables file looks like this:

rules:

- name: rule1
  actions:
- type: forward
  pool: pool-svrs
  conditions:
- type: http_uri
  path_starts_with: /euro
- name: rule2
  actions:
- type: forward
  pool: pool-svrs
  conditions:
- type: http_uri
  path_starts_with: /HomePage/

My question is how can I create a variable for the policy instead of entering 
it in my playbook task?

-- 
You received this message because you are subscribed to the Google Groups 
"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/a713a018-8eee-4e48-ab20-4aa1ab5e0f37%40googlegroups.com.


Re: [ansible-project] Ansible Reboot Error...

2020-03-31 Thread kmarty009
Interesting!  Thanks for the responses!  I really appreciate it.  

I'm new to ansible and trying to get into a love affair with it.  I'm 
running CentOS 7.7.1908 and Ansible 2.4.2.0 was installed.  

I did a yum install epel-release and I got installed new version at 2.9.6  

Of course, that worked and rebooted my machine!  However, I did run into 
new issues with DEPRECATION WARNING.  I think it's not liking the 
state=installed.  If I'm reading the manual (RTFM) it wants a newer flag of 
state=present.  

I also don't think it's loving the {{ item }} flag and wants something 
different.  {{ packages }}?  

[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via 
squash_actions is deprecated. Instead of using a loop to supply
multiple items and specifying `pkg: "{{ item }}"`, please use `pkg: 
['nano', 'vim', 'tar', 'xz', 'unzip', 'wget', 'curl', 'bind-utils', 'net-
tools', 'ntp', 'epel-release']` and remove the loop. This feature will be 
removed in version 2.11. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via 
squash_actions is deprecated. Instead of using a loop to supply
multiple items and specifying `pkg: "{{ item }}"`, please use `pkg: 
['nano', 'vim', 'tar', 'xz', 'unzip', 'wget', 'curl', 'bind-utils', 'net-
tools', 'ntp', 'epel-release']` and remove the loop. This feature will be 
removed in version 2.11. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.



On Tuesday, March 31, 2020 at 3:22:35 PM UTC-5, Dick Visser wrote:
>
> This usually means that the ansible version you use does not know that 
> module. 
> According to 
> https://docs.ansible.com/ansible/latest/modules/reboot_module.html 
> the reboot module was introduced in 2.7. 
> This indicates you're using something older. 
>
> What is the output of 'ansible --version'? 
>
>
>
> On Tue, 31 Mar 2020 at 21:11, kmarty009 > 
> wrote: 
> > 
> > I get this error when executing my playbook.  I need to reboot the 
> machine but cannot get around this insane error that is preventing me from 
> doing so.. the plybook works until I add the last line for reboot.  Can 
> anyone tell me what is wrong here please???  Thanks in advance. 
> > 
> >  ERROR SECTION* 
> > 
> > ERROR! no action detected in task. This often indicates a misspelled 
> module name, or incorrect module path. 
> > 
> > The error appears to have been in 
> '/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but 
> may 
> > be elsewhere in the file depending on the exact syntax problem. 
> > 
> > The offending line appears to be: 
> > 
> > 
> > - name: Reboot Machine 
> >   ^ here 
> > 
> > 
> > The error appears to have been in 
> '/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but 
> may 
> > be elsewhere in the file depending on the exact syntax problem. 
> > 
> > The offending line appears to be: 
> > 
> > 
> > - name: Reboot Machine 
> >   ^ here 
> > 
> > exception type:  
> > exception: no action detected in task. This often indicates a misspelled 
> module name, or incorrect module path. 
> > 
> > The error appears to have been in 
> '/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but 
> may 
> > be elsewhere in the file depending on the exact syntax problem. 
> > 
> > The offending line appears to be: 
> > 
> > 
> > - name: Reboot Machine 
> >   ^ here 
> > 
> >  PLAYBOOK** 
> > 
> > 
> > #Ansible Configuration Playbook for On-Premise Installs 
> > #Created by: Kirk Marty kmar...@gmail.com  
> > #Version 1.0 
> > #Date: 3/31/2020 
> > 
> > - name: "Required Software Packages that will be utilized - yum 
> installs" 
> >   yum: pkg={{ item }} state=installed 
> >   with_items: 
> >   - nano 
> >   - vim 
> >   - tar 
> >   - xz 
> >   - unzip 
> >   - wget 
> >   - curl 
> >   - bind-utils 
> >   - net-tools 
> >   - ntp 
> >   - epel-release 
> > 
> > # Update the system to latest patches and applications via yum 
> > 
> > - name: "update the Centos Server 7 with latest patches and 
> applications" 
> >   yum: 
> > name: "*" 
> > state: latest 
> > 
> > - name: be sure firewalld is installed 
> >   yum: name=firewalld state=installed 
> >   tags: 
> >- install 
> >- firewalld 
> > 
> > - name: be sure firewalld is disabled 
> >   systemd: name=firewalld enabled=no 
> >   tags: 
> >- install 
> >- atomic 
> >- firewalld 
> > 
> > - name: be sure firewalld is stopped 
> >   systemd: name=firewalld state=stopped 
> >   ignore_errors: yes 
> >   tags: 
> >- install 
> >- atomic 
> >- firewalld 
> > 
> > - name: Disable SELinux 
> >   selinux: 
> > state: disabled 
> > 
> > - name: Reboot Server to apply some changes and updates 
> >   reboot: 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> > To unsubscribe from this 

[ansible-project] Re: win_xml module 'cannot call a method on a null-valued expression'

2020-03-31 Thread Dave York
I forgot to add, the domain tag is:



not just 



if that's relevant.  



On Tuesday, March 31, 2020 at 3:15:35 PM UTC-7, Dave York wrote:
>
> I have an JBoss domain.xml file im trying to manipulate with win_xml:
>
> 
> ...
> 
> 
> 
> 
> 
> 
> 
> 
>  "XXX.ear"/>
> 
> 
> 
>
>
> 
>
>
> When I try to modify the heap size attribute above using win_xml with this 
> play:
>   - name: Test modifying XML
> win_xml:
>   path: e:\jboss-eap-6.4\XXX\configuration\domain.xml
>   xpath: '/domain/server-groups/server-group/jvm/heap'
>   attribute: 'size'
>   fragment: '123m'
>   type: attribute
>
>
> However, I get an exception that looks like its coming from powershell 
> "You cannot call a method on a null-valued expression
> "exception": "You cannot call a method on a null-valued expression.\r\nAt 
> line:204 char:5\r\n+ [bool]$add = !$node.HasAttribute($attribute) -Or 
> ($node.$attribut ...\r\n+ 
> ~\r\n+ 
> CategoryInfo  : InvalidOperation: (:) [], 
> ParentContainsErrorRecordException\r\n+ FullyQualifiedErrorId : 
> InvokeMethodOnNull\r\n\r\nScriptStackTrace:\r\nat , : 
> line 204\r\n",
>
> "msg": "Unhandled exception while executing module: You cannot call a 
> method on a null-valued expression.",
> "_ansible_no_log": false,
> "changed": false
>
> }
>
>
> Anyone see my problem? I checked the xpath using Notepad++ xml tools 
> plugin and it seems correct.  Scratchin my head
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/178c8aed-886a-4b1d-9f95-96e429efc59c%40googlegroups.com.


[ansible-project] win_xml module 'cannot call a method on a null-valued expression'

2020-03-31 Thread Dave York
I have an JBoss domain.xml file im trying to manipulate with win_xml:


...

















When I try to modify the heap size attribute above using win_xml with this 
play:
  - name: Test modifying XML
win_xml:
  path: e:\jboss-eap-6.4\XXX\configuration\domain.xml
  xpath: '/domain/server-groups/server-group/jvm/heap'
  attribute: 'size'
  fragment: '123m'
  type: attribute


However, I get an exception that looks like its coming from powershell "You 
cannot call a method on a null-valued expression
"exception": "You cannot call a method on a null-valued expression.\r\nAt 
line:204 char:5\r\n+ [bool]$add = !$node.HasAttribute($attribute) -Or 
($node.$attribut ...\r\n+ 
~\r\n+ 
CategoryInfo  : InvalidOperation: (:) [], 
ParentContainsErrorRecordException\r\n+ FullyQualifiedErrorId : 
InvokeMethodOnNull\r\n\r\nScriptStackTrace:\r\nat , : 
line 204\r\n",

"msg": "Unhandled exception while executing module: You cannot call a 
method on a null-valued expression.",
"_ansible_no_log": false,
"changed": false

}


Anyone see my problem? I checked the xpath using Notepad++ xml tools plugin 
and it seems correct.  Scratchin my head

-- 
You received this message because you are subscribed to the Google Groups 
"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/2f64b3f1-ae5b-4a5b-8281-c78981ece725%40googlegroups.com.


[ansible-project] Ansible Reboot Error...

2020-03-31 Thread Jordan Borean
It’s telling you it cannot find the reboot module/plugin. Make sure you are on 
Ansible 2.7 or higher as that is when the module was added 
https://docs.ansible.com/ansible/latest/modules/reboot_module.html,

-- 
You received this message because you are subscribed to the Google Groups 
"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/3ccf48e5-95c3-4201-b12c-a99226da48eb%40googlegroups.com.


Re: [ansible-project] Ansible Reboot Error...

2020-03-31 Thread Dick Visser
This usually means that the ansible version you use does not know that module.
According to https://docs.ansible.com/ansible/latest/modules/reboot_module.html
the reboot module was introduced in 2.7.
This indicates you're using something older.

What is the output of 'ansible --version'?



On Tue, 31 Mar 2020 at 21:11, kmarty009  wrote:
>
> I get this error when executing my playbook.  I need to reboot the machine 
> but cannot get around this insane error that is preventing me from doing so.. 
> the plybook works until I add the last line for reboot.  Can anyone tell me 
> what is wrong here please???  Thanks in advance.
>
>  ERROR SECTION*
>
> ERROR! no action detected in task. This often indicates a misspelled module 
> name, or incorrect module path.
>
> The error appears to have been in 
> '/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>
> - name: Reboot Machine
>   ^ here
>
>
> The error appears to have been in 
> '/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>
> - name: Reboot Machine
>   ^ here
>
> exception type: 
> exception: no action detected in task. This often indicates a misspelled 
> module name, or incorrect module path.
>
> The error appears to have been in 
> '/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>
> - name: Reboot Machine
>   ^ here
>
>  PLAYBOOK**
>
>
> #Ansible Configuration Playbook for On-Premise Installs
> #Created by: Kirk Marty kmarty...@gmail.com
> #Version 1.0
> #Date: 3/31/2020
>
> - name: "Required Software Packages that will be utilized - yum installs"
>   yum: pkg={{ item }} state=installed
>   with_items:
>   - nano
>   - vim
>   - tar
>   - xz
>   - unzip
>   - wget
>   - curl
>   - bind-utils
>   - net-tools
>   - ntp
>   - epel-release
>
> # Update the system to latest patches and applications via yum
>
> - name: "update the Centos Server 7 with latest patches and applications"
>   yum:
> name: "*"
> state: latest
>
> - name: be sure firewalld is installed
>   yum: name=firewalld state=installed
>   tags:
>- install
>- firewalld
>
> - name: be sure firewalld is disabled
>   systemd: name=firewalld enabled=no
>   tags:
>- install
>- atomic
>- firewalld
>
> - name: be sure firewalld is stopped
>   systemd: name=firewalld state=stopped
>   ignore_errors: yes
>   tags:
>- install
>- atomic
>- firewalld
>
> - name: Disable SELinux
>   selinux:
> state: disabled
>
> - name: Reboot Server to apply some changes and updates
>   reboot:
>
> --
> You received this message because you are subscribed to the Google Groups 
> "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/8ef94b84-40cd-4105-857b-f82a6787d89a%40googlegroups.com.



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

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


[ansible-project] Ansible Reboot Error...

2020-03-31 Thread kmarty009
I get this error when executing my playbook.  I need to reboot the machine 
but cannot get around this insane error that is preventing me from doing 
so.. the plybook works until I add the last line for reboot.  Can anyone 
tell me what is wrong here please???  Thanks in advance.  

 ERROR SECTION*

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

The error appears to have been in 
'/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but 
may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Reboot Machine
  ^ here


The error appears to have been in 
'/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but 
may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Reboot Machine
  ^ here

exception type: 
exception: no action detected in task. This often indicates a misspelled 
module name, or incorrect module path.

The error appears to have been in 
'/home/kmarty/ansible/roles/basic/tasks/main.yml': line 53, column 3, but 
may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Reboot Machine
  ^ here

 PLAYBOOK**


#Ansible Configuration Playbook for On-Premise Installs
#Created by: Kirk Marty kmarty...@gmail.com
#Version 1.0 
#Date: 3/31/2020

- name: "Required Software Packages that will be utilized - yum installs"
  yum: pkg={{ item }} state=installed
  with_items:
  - nano
  - vim
  - tar
  - xz
  - unzip
  - wget
  - curl
  - bind-utils
  - net-tools
  - ntp
  - epel-release

# Update the system to latest patches and applications via yum

- name: "update the Centos Server 7 with latest patches and applications"
  yum:
name: "*"
state: latest

- name: be sure firewalld is installed
  yum: name=firewalld state=installed
  tags:
   - install
   - firewalld
 
- name: be sure firewalld is disabled
  systemd: name=firewalld enabled=no
  tags:
   - install
   - atomic
   - firewalld

- name: be sure firewalld is stopped
  systemd: name=firewalld state=stopped
  ignore_errors: yes
  tags:
   - install
   - atomic
   - firewalld

- name: Disable SELinux
  selinux:
state: disabled

- name: Reboot Server to apply some changes and updates
  reboot:

-- 
You received this message because you are subscribed to the Google Groups 
"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/8ef94b84-40cd-4105-857b-f82a6787d89a%40googlegroups.com.


[ansible-project] Ignore imported playbooks completely when defined

2020-03-31 Thread Ronen Levinson
Hi, 

I'm using ansible version 2.7.17 and combining multiple playbooks in one 
file.
One of my playbooks I'm running conditionally with when and a condition.
My problem is when my condition is false, I want ansible to completely 
ignore my playbook and not load anything related to this playbook.
I tried using both import_playbook and include, which seems to have similar 
results.
The call to the playbook looks like that:

- name: Include kubespray tasks
include: ../kubespray/cluster.yml
when: cluster_installation

in my output you can see ansible run the handlers inside the ignored 
playbook (keeping for 2 more minutes):

PLAYBOOK: cluster.yml 
***
16 plays in cluster.yml

PLAY [localhost] 

META: ran handlers
Tuesday 31 March 2020 18:55:46 + (0:00:00.043) 0:00:00.043 *
META: ran handlers
META: ran handlers
[WARNING]: Could not match supplied host pattern, ignoring: bastion


PLAY [bastion[0]] 
***
skipping: no hosts matched

PLAY [k8s-cluster:etcd] 
*
META: ran handlers
Tuesday 31 March 2020 18:55:46 + (0:00:00.037) 0:00:00.081 *
Tuesday 31 March 2020 18:55:46 + (0:00:00.049) 0:00:00.130 *
Tuesday 31 March 2020 18:55:46 + (0:00:00.048) 0:00:00.178 *
Tuesday 31 March 2020 18:55:46 + (0:00:00.051) 0:00:00.230 *
Tuesday 31 March 2020 18:55:46 + (0:00:00.024) 0:00:00.254 *
Tuesday 31 March 2020 18:55:46 + (0:00:00.021) 0:00:00.275 * 

Thanks for the help,
Ronen

-- 
You received this message because you are subscribed to the Google Groups 
"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/ce7a36bb-ceab-46ee-ae75-817417cc8fb7%40googlegroups.com.


Re: [ansible-project] Re: combine the playbooks

2020-03-31 Thread J
can you run   *ansible-playbook myplaybook.yml --syntax-check*and see
if it reports errors? If it doesn't then run *ansible-playbook
myplaybook.yml -C *and see where it fails.  This is in check mode.

On Tue, Mar 31, 2020 at 2:02 PM mahesh g o  wrote:

> only Plyabook 1 ran successfully, playbook 2 has not ran
>
> On Tuesday, 31 March 2020 20:41:39 UTC+5:30, mahesh g o wrote:
>>
>> how to combine the playbooks:
>>
>> I have below 2 playbooks which creates 4 svm's each, one with nfs
>> protocol and another with fcpprotocol.
>>
>> Playbook 1 which creates 4 svm's with fcp protocol
>> - hosts: localhost
>>   gather_facts: false
>>   vars_files:
>> - /etc/ansible/group_vars/host_vars
>>   tasks:
>> - name: Create SVM
>>   na_ontap_svm:
>> state: present
>> name: "systemic_fcp_{{item}}"
>> root_volume: "systemic_fcp_aggr8svm{{item}}_root"
>> root_volume_aggregate: sti49_vsim_ucs100f_aggr1
>> allowed_protocols: fcp
>> root_volume_security_style: mixed
>> hostname: "{{ aiqumip }}"
>> username: "{{ aiqumusername }}"
>> password: "{{ aiqumpassword }}"
>> https: false
>>   with_sequence: start=1 end=4
>>
>> Playbook 2 which creates 4 svm's with iscsi protocol:
>>
>> - hosts: localhost
>>   gather_facts: false
>>   vars_files:
>> - /etc/ansible/group_vars/host_vars
>>   tasks:
>> - name: Create SVM
>>   na_ontap_svm:
>> state: absent
>> name: "systemic_iscsi_{{item}}"
>> root_volume: "systemic_fcp_aggr8svm{{item}}_root"
>> root_volume_aggregate: sti49_vsim_ucs100e_aggr1
>> allowed_protocols: fcp
>> root_volume_security_style: mixed
>> hostname: "{{ aiqumip }}"
>> username: "{{ aiqumusername }}"
>> password: "{{ aiqumpassword }}"
>> https: false
>>   with_sequence: start=1 end=4
>>
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "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/e2af9a7c-af48-4421-b47c-511e4217d93c%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/CAFFkYJLngpdnk2ZqX2wnpRzX8DhE%3DWU4uSba2i04y4XDfH8ACQ%40mail.gmail.com.


[ansible-project] Re: combine the playbooks

2020-03-31 Thread mahesh g o
only Plyabook 1 ran successfully, playbook 2 has not ran

On Tuesday, 31 March 2020 20:41:39 UTC+5:30, mahesh g o wrote:
>
> how to combine the playbooks:
>
> I have below 2 playbooks which creates 4 svm's each, one with nfs protocol 
> and another with fcpprotocol.
>
> Playbook 1 which creates 4 svm's with fcp protocol
> - hosts: localhost
>   gather_facts: false
>   vars_files:
> - /etc/ansible/group_vars/host_vars
>   tasks:
> - name: Create SVM
>   na_ontap_svm:
> state: present
> name: "systemic_fcp_{{item}}"
> root_volume: "systemic_fcp_aggr8svm{{item}}_root"
> root_volume_aggregate: sti49_vsim_ucs100f_aggr1
> allowed_protocols: fcp
> root_volume_security_style: mixed
> hostname: "{{ aiqumip }}"
> username: "{{ aiqumusername }}"
> password: "{{ aiqumpassword }}"
> https: false
>   with_sequence: start=1 end=4
>
> Playbook 2 which creates 4 svm's with iscsi protocol:
>
> - hosts: localhost
>   gather_facts: false
>   vars_files:
> - /etc/ansible/group_vars/host_vars
>   tasks:
> - name: Create SVM
>   na_ontap_svm:
> state: absent
> name: "systemic_iscsi_{{item}}"
> root_volume: "systemic_fcp_aggr8svm{{item}}_root"
> root_volume_aggregate: sti49_vsim_ucs100e_aggr1
> allowed_protocols: fcp
> root_volume_security_style: mixed
> hostname: "{{ aiqumip }}"
> username: "{{ aiqumusername }}"
> password: "{{ aiqumpassword }}"
> https: false
>   with_sequence: start=1 end=4
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/e2af9a7c-af48-4421-b47c-511e4217d93c%40googlegroups.com.


Re: [ansible-project] combine the playbooks

2020-03-31 Thread J
Try this!

---
- name: Playbook 1 which creates 4 svm's with fcp protocol
  hosts: localhost
  gather_facts: false
  vars_files:
- /etc/ansible/group_vars/host_vars
  tasks:
- name: Create SVM
  na_ontap_svm:
state: present
name: "systemic_fcp_{{item}}"
root_volume: "systemic_fcp_aggr8svm{{item}}_root"
root_volume_aggregate: sti49_vsim_ucs100f_aggr1
allowed_protocols: fcp
root_volume_security_style: mixed
hostname: "{{ aiqumip }}"
username: "{{ aiqumusername }}"
password: "{{ aiqumpassword }}"
https: false
  with_sequence: start=1 end=4


- name: Playbook 2 which creates 4 svm's with iscsi protocol
  hosts: localhost
  gather_facts: false
  vars_files:
- /etc/ansible/group_vars/host_vars
  tasks:
- name: Create SVM
  na_ontap_svm:
state: absent
name: "systemic_iscsi_{{item}}"
root_volume: "systemic_fcp_aggr8svm{{item}}_root"
root_volume_aggregate: sti49_vsim_ucs100e_aggr1
allowed_protocols: fcp
root_volume_security_style: mixed
hostname: "{{ aiqumip }}"
username: "{{ aiqumusername }}"
password: "{{ aiqumpassword }}"
https: false
  with_sequence: start=1 end=4


On Tue, Mar 31, 2020 at 11:11 AM mahesh g o  wrote:

> how to combine the playbooks:
>
> I have below 2 playbooks which creates 4 svm's each, one with nfs protocol
> and another with fcpprotocol.
>
> Playbook 1 which creates 4 svm's with fcp protocol
> - hosts: localhost
>   gather_facts: false
>   vars_files:
> - /etc/ansible/group_vars/host_vars
>   tasks:
> - name: Create SVM
>   na_ontap_svm:
> state: present
> name: "systemic_fcp_{{item}}"
> root_volume: "systemic_fcp_aggr8svm{{item}}_root"
> root_volume_aggregate: sti49_vsim_ucs100f_aggr1
> allowed_protocols: fcp
> root_volume_security_style: mixed
> hostname: "{{ aiqumip }}"
> username: "{{ aiqumusername }}"
> password: "{{ aiqumpassword }}"
> https: false
>   with_sequence: start=1 end=4
>
> Playbook 2 which creates 4 svm's with iscsi protocol:
>
> - hosts: localhost
>   gather_facts: false
>   vars_files:
> - /etc/ansible/group_vars/host_vars
>   tasks:
> - name: Create SVM
>   na_ontap_svm:
> state: absent
> name: "systemic_iscsi_{{item}}"
> root_volume: "systemic_fcp_aggr8svm{{item}}_root"
> root_volume_aggregate: sti49_vsim_ucs100e_aggr1
> allowed_protocols: fcp
> root_volume_security_style: mixed
> hostname: "{{ aiqumip }}"
> username: "{{ aiqumusername }}"
> password: "{{ aiqumpassword }}"
> https: false
>   with_sequence: start=1 end=4
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/aa442a41-0288-43b7-8b3e-d44c3171d7f7%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/CAFFkYJ%2BmK7DqJr0in6xik0T3dGFy4PKhs%2B38gY95sio7bpXQ7A%40mail.gmail.com.


[ansible-project] combine the playbooks

2020-03-31 Thread mahesh g o
how to combine the playbooks:

I have below 2 playbooks which creates 4 svm's each, one with nfs protocol 
and another with fcpprotocol.

Playbook 1 which creates 4 svm's with fcp protocol
- hosts: localhost
  gather_facts: false
  vars_files:
- /etc/ansible/group_vars/host_vars
  tasks:
- name: Create SVM
  na_ontap_svm:
state: present
name: "systemic_fcp_{{item}}"
root_volume: "systemic_fcp_aggr8svm{{item}}_root"
root_volume_aggregate: sti49_vsim_ucs100f_aggr1
allowed_protocols: fcp
root_volume_security_style: mixed
hostname: "{{ aiqumip }}"
username: "{{ aiqumusername }}"
password: "{{ aiqumpassword }}"
https: false
  with_sequence: start=1 end=4

Playbook 2 which creates 4 svm's with iscsi protocol:

- hosts: localhost
  gather_facts: false
  vars_files:
- /etc/ansible/group_vars/host_vars
  tasks:
- name: Create SVM
  na_ontap_svm:
state: absent
name: "systemic_iscsi_{{item}}"
root_volume: "systemic_fcp_aggr8svm{{item}}_root"
root_volume_aggregate: sti49_vsim_ucs100e_aggr1
allowed_protocols: fcp
root_volume_security_style: mixed
hostname: "{{ aiqumip }}"
username: "{{ aiqumusername }}"
password: "{{ aiqumpassword }}"
https: false
  with_sequence: start=1 end=4



-- 
You received this message because you are subscribed to the Google Groups 
"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/aa442a41-0288-43b7-8b3e-d44c3171d7f7%40googlegroups.com.


Re: [ansible-project] Re: ansible windows inventory get hostname/user/password ad-hoc from external script

2020-03-31 Thread Gregory Storme
I've managed to write a workaround, by writing a playbook which runs
the get-admin-credential command task, with "delegate_to: localhost".
>From this I build a dictionary with the parsed values for
host/login/password from the command output, and in the ansible inventory
file I do a hostvars lookup of these values.

An inventory plugin could also work, thanks for the tip I'll check that out
later.


On Thu, Mar 26, 2020 at 9:49 AM 'J Hawkesworth' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> Would constructing your own lookup plugin be an option?
>
> There seem to be lots of lookup plugins that look things up in various
> kinds of vaults:
> https://docs.ansible.com/ansible/latest/plugins/lookup.html#plugin-list
> Could you create one of your own.
>
> If you created an inventory plugin, rather than an older style dynamic
> inventory script, I believe the inventory plugins can make use of the
> internal cache, so you might be able to cache credentials for a little
> while, which might speed things up, but I'd be inclined to see if you could
> create your own lookup plugin.
>
> Hope this helps,
>
> Jon
>
> On Tuesday, March 17, 2020 at 7:49:01 PM UTC, Gregory Storme wrote:
>>
>> Hi,
>>
>> We have a couple of hundred Windows hosts, with each host having
>> different credentials (both login and password), which are stored in an
>> on-premise, in-house developed "vault" system.
>> A dream scenario would be to install win32-openssh on all of them, and
>> use ssh key authentication :) however until there's MSI(X) support for
>> win32-openssh and/or it goes out of beta, this is not an option.
>>
>> We have an API to access our vault, which returns the
>> hostname/username/password for the host.
>> As a workaround now, I've written a simple wrapper for ansible-playbook
>> which works, but the disadvantage is that each host is a new playbook run.
>> I'm looking for a solution to run a playbook, and where ansible polls the
>> hostname/username/password for each alias in the ansible inventory.
>> Tried looking to patch the winrm.py connection plugin, but this didn't
>> work, and I think it would poll for each task that's executed by the winrm
>> plugin instead of only once?
>>
>> Solution I'm using now:
>>
>> ansible hosts file:
>>
>> [windows]
>> L001
>> L002
>> L003
>>
>> ansible-playbook wrapper:
>>
>> #!/bin/bash
>>
>> CONNECTION="ansible_connection=winrm ansible_port=5985
>> ansible_winrm_transport=credssp"
>>
>> for host in `cat ~/.ansible/hosts`
>>   do
>> SECRET=`/opt/scripts/vault-functions/bin/console
>> app:get-admin-credential --tag=$host`
>> HOST=`echo $SECRET | cut -d ';' -f1`
>> LOGIN=`echo $SECRET | cut -d ';' -f2`
>> DOMAIN=`echo $SECRET | cut -d ';' -f3`
>> PWD=`echo $SECRET | cut -d ';' -f4`
>>
>> if [ -z "$DOMAIN" ]; then
>>   ansible-playbook -i ~/.ansible/hosts ~/.ansible/windows.yml -e
>> "ansible_host=$HOST ansible_user=$LOGIN ansible_password=$PWD $CONNECTION"
>> else
>>   ansible-playbook -i ~/.ansible/hosts ~/.ansible/windows.yml -e
>> "ansible_host=$HOST ansible_user=$LOGIN@$DOMAIN ansible_password=$PWD
>> $CONNECTION"
>> fi
>>   done
>>
>> This works, but as stated before this runs an ansible-playbook for each
>> host.
>> Could someone point me in the right direction on how to be able to run an
>> ansible-playbook, upon which ansible does a lookup of the
>> ansible_hostname/ansible_user/ansible-password during the connection phase
>> to the host?
>>
>> Important detail, once a secret is requested from our vault, the password
>> will be reset within a couple of hours. So it's not possible for us to
>> build a static (encrypted) inventory.
>> Building a dynamic inventory is also not desired, because of the large
>> amount of hosts and the time it takes to request the credentials, this
>> would take too long and by the time it's finished, it's possible the
>> credentials of the first hosts have already been reset.
>>
>> So I'm looking for something that can pull data ad-hoc upon the ansible
>> connection, like the wrapper above does, but whilst staying in 1 playbook
>> run ... tips are much appreciated!
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/bc28M8NwuvA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/42d09dda-7d9d-440e-b5dd-cb3612990aea%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 

Re: [ansible-project] Passing bulk data from ansible uri module to service and gettings status code -1 error

2020-03-31 Thread Stefan Hornburg (Racke)
On 3/31/20 1:19 PM, Diyawary wrote:
> Thanks For Reply Racke, I have checked with the snow guy and there side has 
> no time limtiation for connection close and
> they are saying as below-
> 
> There are no properties restricting how long SNOW will take to respond. 
> Response time restrictions are usually placed on
> the calling application, not the receiving application.
> 

If the operation is running into Ansible's timeout, it would be a different 
message. "Something like The read operation
timed out".

In my opinion this is a local problem and pretty much offtopic now.

Regards
 Racke

> 
> On Tuesday, 31 March 2020 16:06:27 UTC+5:30, Stefan Hornburg (Racke) wrote:
> 
> On 3/31/20 12:25 PM, Diyawary wrote:
> > I am sending  some 4500 lines data from Ansible to snow table via uri 
> module. however 4100 records updated to snow
> table
> > rest of the data did not updated this job runs around 122 or 123 sec 
> and throw below  error. less amount of data is
> > updated properly .
> > *
> > *
> > *Status code was -1 and not [200]: Connection failure: connection was 
> closed before a valid response was received:
> ''*
> >
> > In my code  I have already increased the timeout value- to 500 sec
> >        url: 
> >         method: POST
> >         user: "{{ snow_username }}"
> >         password: "{{ snow_password }}"
> >         body: '{"List":{{list_item}}, "Region": X - DEV " }'
> >         body_format: json
> >         force_basic_auth: yes
> >         status_code: 200
> >         timeout: 500
> > Please suggest how can resolved this issue asap. 
> > Appriciate your help in adavance
> 
> My interpretation of the error message would be that the URL endpoint 
> closed the connection, so increasing the
> timeout on Ansible's side doesn't help.
> 
> It is likely that the URL endpoint ran into a timeout. Maybe you could 
> breakdown the data in several batches.
> 
> 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/388ee9c3-f95d-42ad-9efc-a5feff13f7cc%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/9f06b73a-15b5-4a7e-903e-a3ccb108e914%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/fafc3c56-6cd8-1a0c-e7fe-679524ac9498%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


Re: [ansible-project] Passing bulk data from ansible uri module to service and gettings status code -1 error

2020-03-31 Thread Diyawary
Thanks For Reply Racke, I have checked with the snow guy and there side has 
no time limtiation for connection close and they are saying as below-

There are no properties restricting how long SNOW will take to respond. 
Response time restrictions are usually placed on the calling application, 
not the receiving application.


On Tuesday, 31 March 2020 16:06:27 UTC+5:30, Stefan Hornburg (Racke) wrote:
>
> On 3/31/20 12:25 PM, Diyawary wrote: 
> > I am sending  some 4500 lines data from Ansible to snow table via uri 
> module. however 4100 records updated to snow table 
> > rest of the data did not updated this job runs around 122 or 123 sec and 
> throw below  error. less amount of data is 
> > updated properly . 
> > * 
> > * 
> > *Status code was -1 and not [200]: Connection failure: connection was 
> closed before a valid response was received: ''* 
> > 
> > In my code  I have already increased the timeout value- to 500 sec 
> >url:  
> > method: POST 
> > user: "{{ snow_username }}" 
> > password: "{{ snow_password }}" 
> > body: '{"List":{{list_item}}, "Region": X - DEV " }' 
> > body_format: json 
> > force_basic_auth: yes 
> > status_code: 200 
> > timeout: 500 
> > Please suggest how can resolved this issue asap.  
> > Appriciate your help in adavance 
>
> My interpretation of the error message would be that the URL endpoint 
> closed the connection, so increasing the 
> timeout on Ansible's side doesn't help. 
>
> It is likely that the URL endpoint ran into a timeout. Maybe you could 
> breakdown the data in several batches. 
>
> 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/388ee9c3-f95d-42ad-9efc-a5feff13f7cc%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/388ee9c3-f95d-42ad-9efc-a5feff13f7cc%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/9f06b73a-15b5-4a7e-903e-a3ccb108e914%40googlegroups.com.


[ansible-project] Ansible with Windows Shared Folder

2020-03-31 Thread Jordan Borean
You are probably hitting the double hop issue over The WinRM. See 
https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html#limitations
 for some workarounds.

-- 
You received this message because you are subscribed to the Google Groups 
"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/fc595e89-2f76-4b8f-86d3-c0aa96c615b1%40googlegroups.com.


Re: [ansible-project] Passing bulk data from ansible uri module to service and gettings status code -1 error

2020-03-31 Thread Stefan Hornburg (Racke)
On 3/31/20 12:25 PM, Diyawary wrote:
> I am sending  some 4500 lines data from Ansible to snow table via uri module. 
> however 4100 records updated to snow table
> rest of the data did not updated this job runs around 122 or 123 sec and 
> throw below  error. less amount of data is
> updated properly .
> *
> *
> *Status code was -1 and not [200]: Connection failure: connection was closed 
> before a valid response was received: ''*
> 
> In my code  I have already increased the timeout value- to 500 sec
>        url: 
>         method: POST
>         user: "{{ snow_username }}"
>         password: "{{ snow_password }}"
>         body: '{"List":{{list_item}}, "Region": X - DEV " }'
>         body_format: json
>         force_basic_auth: yes
>         status_code: 200
>         timeout: 500
> Please suggest how can resolved this issue asap. 
> Appriciate your help in adavance

My interpretation of the error message would be that the URL endpoint closed 
the connection, so increasing the
timeout on Ansible's side doesn't help.

It is likely that the URL endpoint ran into a timeout. Maybe you could 
breakdown the data in several batches.

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/388ee9c3-f95d-42ad-9efc-a5feff13f7cc%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/7279d023-c2f3-d19f-584a-b113b1b9e513%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Ansible with Windows Shared Folder

2020-03-31 Thread David Foley
Hi,

I'm trying to roll out Microsoft DSC Using the following Playbook to 
install the application

---
- name: 
  hosts: win
  gather_facts: false
  #connection: win
  tasks:
  - name: Install DSC
win_shell: 'Set-DscLocalConfigurationManager -Path \\\DSCSource\AA-DSC\DscMetaConfigs\Approved -Verbose -Force'


  - name: Run Pooling
win_shell: 'Update-DscConfiguration -Wait -Verbose'


  - name: Get DSC
win_shell: 'Get-DscConfigurationStatus -All'



I'm getting the following Error:: When i run it 

fatal: []: FAILED! => {"changed": true, "cmd": "powershell.exe 
-ExecutionPolicy Unrestricted Set-DscLocalConfigurationManager -Path 
\\DSCSource\\AA-DSC\\DscMetaConfigs\\Approved -Verbose 
-Force", "delta": "0:00:02.843573", "end": "2020-03-31 10:21:53.598630", 
"msg": "non-zero return code", "rc": 1, "start": "2020-03-31 
10:21:50.755056", "stderr": "Set-DscLocalConfigurationManager : \\\DSCSource\\AA-DSC\\DscMetaConfigs\\Approved is not a valid 
\r\ndirectory.\r\nAt line:1 char:1\r\n+ Set-DscLocalConfigurationManager 
-Path \\\DSC ...\r\n+ 
~\r\n   
 + CategoryInfo  : NotSpecified: (:) 
[Set-DscLocalConfigurationManager], ArgumentException\r\n+ 
FullyQualifiedErrorId : 
System.ArgumentException,Microsoft.PowerShell.DesiredStateConfiguration.Commands.SetDscL
 
\r\n   ocalConfigurationManagerCommand", "stderr_lines": 
["Set-DscLocalConfigurationManager 
: \\\DSCSource\\AA-DSC\\DscMetaConfigs\\Approved is not a 
valid ", "directory.", "At line:1 char:1", "+ 
Set-DscLocalConfigurationManager -Path \\\DSC ...", "+ 
~", "   
 + CategoryInfo  : NotSpecified: (:) 
[Set-DscLocalConfigurationManager], ArgumentException", "+ 
FullyQualifiedErrorId : 
System.ArgumentException,Microsoft.PowerShell.DesiredStateConfiguration.Commands.SetDscL
 
", "   ocalConfigurationManagerCommand"], "stdout": "", "stdout_lines": []}


-- 
You received this message because you are subscribed to the Google Groups 
"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/e944b06a-2b67-453a-83d8-2b17001a05e0%40googlegroups.com.


[ansible-project] Passing bulk data from ansible uri module to service and gettings status code -1 error

2020-03-31 Thread Diyawary
I am sending  some 4500 lines data from Ansible to snow table via uri 
module. however 4100 records updated to snow table rest of the data did not 
updated this job runs around 122 or 123 sec and throw below  error. less 
amount of data is updated properly .

*Status code was -1 and not [200]: Connection failure: connection was 
closed before a valid response was received: ''*

In my code  I have already increased the timeout value- to 500 sec
   url: 
method: POST
user: "{{ snow_username }}"
password: "{{ snow_password }}"
body: '{"List":{{list_item}}, "Region": X - DEV " }'
body_format: json
force_basic_auth: yes
status_code: 200
timeout: 500
Please suggest how can resolved this issue asap. 
Appriciate your help in adavance

-- 
You received this message because you are subscribed to the Google Groups 
"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/388ee9c3-f95d-42ad-9efc-a5feff13f7cc%40googlegroups.com.


Re: [ansible-project] AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_fqdn'

2020-03-31 Thread Rajesh
Thanks for your help. There was an issue in one of the hosts in the 
inventory. Once I removed that host from the inventory it worked fine. 

I created a custom facts in one of the hosts as below. Not sure what the 
issue is but it is not working.

- name: Create a custom facts file
  hosts: database
  become: true
  become_user: root
  gather_facts: true
  tasks:
- name: Create a custom facts directory
  file:
path: /etc/ansible/facts.d
state: directory

- name: Create a custom facts
  template:
src: templates/custom.fact.j2
dest: /etc/ansible/facts.d/custom.fact

- name: Print ansible_local
  debug: var=ansible_local
- name: Print the custom facts value
  debug:
msg: "{{ ansible_local.custom.sample_exam }}"

[automation@workstation plays]$ cat templates/custom.fact.j2 
[sample_exam]
server_role=mysql
[automation@workstation plays]$ 

[automation@workstation plays]$ ansible-playbook facts.yml 

PLAY [Create a custom facts file] 
**

TASK [Gathering Facts] 
*
fatal: [ansible5]: FAILED! => {"ansible_facts": {}, "changed": false, 
"failed_modules": {"setup": {"ansible_facts": 
{"discovered_interpreter_python": "/usr/libexec/platform-python"}, "cmd": 
"/etc/ansible/facts.d/custom.fact", "failed": true, "invocation": 
{"module_args": {"fact_path": "/etc/ansible/facts.d", "filter": "*", 
"gather_subset": ["all"], "gather_timeout": 10}}, "msg": "[Errno 8] Exec 
format error: b'/etc/ansible/facts.d/custom.fact'", "rc": 8}}, "msg": "The 
following modules failed to execute: setup\n"}

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

[automation@workstation plays]$ 


Thanks,
Rajesh





On Tuesday, March 31, 2020 at 5:22:07 PM UTC+11, Vladimir Botka wrote:
>
> On Mon, 30 Mar 2020 19:28:13 -0700 (PDT) 
> Rajesh > wrote: 
>
> > - hosts: all 
> > [...] 
> >   template: 
> >   src: templates/server_list.j2 
> >   dest: /etc/server_list.txt 
> >   owner: automation 
> >   mode: '0600' 
> >   setype: net_conf_t 
> >   when: ansible_fqdn in groups['proxy'] 
> > 
> > [automation@workstation plays]$ cat templates/server_list.j2 
> > {% for host in groups['all'] %} 
> > {{ hostvars[host]['ansible_fqdn'] }} 
> > {% endfor %} 
> > [...] 
> > fatal: [ansible2.example.com]: FAILED! => {"changed": false, "msg": 
> > "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' 
> has 
> > no attribute 'ansible_fqdn'"} 
>
> Your playbook works for me. The problem is missing variable "ansible_fqdn" 
> at 
> some host. You might want to find the host and see what's the problem. Try 
>
>   - hosts: all 
> tasks: 
>   - debug: 
>   var: ansible_fqdn 
>
> Why do you use "ansible_fqdn" in the "when" condition instead of 
> "inventory_hostname"? This implicates that you're mixing "ansible_fqdn" 
> and 
> "inventory_hostname" in the inventory. 
>
> HTH, 
>
> -vlado 
>

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


[ansible-project] Re: set_fact moudle error ansible

2020-03-31 Thread Sandy Hung
thank  your help
I have problem mount efs  volume show msg   "msg": "Error mounting 
/home/ec2-user/test_efs: mount.nfs4: Connection timed out\n"
I have add to hosts 


On Tuesday, March 31, 2020 at 11:55:10 AM UTC+8, Sandy Hung wrote:
>
> Hi 
>
> error msg
> fatal: [localhost]: FAILED! => {
> "msg": "The task includes an option with an undefined variable. The 
> error was: 'dict object' has no attribute 'ansible_facts'\n\nThe error 
> appears to be in '/home/ldap/createefs.yml': line 37, column 8, but may\nbe 
> elsewhere in the file depending on the exact syntax problem.\n\nThe 
> offending line appears to be:\n\n\n - set_fact:\n   ^ here\n"
> }
>
>  - hosts: localhost
>connection: local
>gather_facts: no
>
>vars_files:
>  - ec2key.yml
>vars:
>  efs_vol_name: "test_efs"
>
>
>tasks:
>
>  - name: Create EFS fileserver
>efs:
> state: present
> region: "ap-southeast-1"
> name: "test_efs"
> tags:
>   Name: "test_efstag"
> targets:
>   - subnet_id: "subnet-46817120"
> security_groups: [ "sg-073c16c36bea62794" ]
> performance_mode: general_purpose
> encrypt: yes
>
> # - name: efs mount to ec2
> #   vars:
> # efs_vol_name: "test_efs"
>
>  - local_action:
>  module: efs_info
>  name: "{{ efs_vol_name }}"
>run_once: true
>register: _efs_fact
>
>  - set_fact:
>  _efs_fact_id: "{{ efs_fact.ansible_facts.efs[0].file_system_id }}"
>
>  - name: install efs libs
>apt:
>  name: "{{ item }}"
>  state: present
>become: yes
>with_items:
>  - nfs-common
>  - name: Create data store directory for efs mount
>file:
>  dest: "/home/ec2-user/{{ efs_vol_name }}"
>  state: directory
>
>  - name: mount efs volume
>mount:
>  path: "/home/ec2-user/{{ efs_vol_name }}"
>  src: "{{ _efs_fact_id }}.efs.ap-southeast-1.amazonaws.com:/"
>  fstype: "nfs4"
>  opts: 
> "nfssevers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport"
>  state: mounted
>become: yes
>
>
>

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


[ansible-project] Re: Ansible and Terraform use cases.

2020-03-31 Thread Kobi Rosenstein


Ansible VS Terraform



IDEOLOGY: 

Two separate platforms, two separate goals.

Minor overlap.


Ansible is a CM (configuration management) tool. It is great at tracelessly 
executing commands (in the form of modules, but on the remote host just 
commands) on a specified group of servers as defined in the inventory file. 
Little to no configuration is required to get an ansible instance up and 
running.

It is extraordinarily versatile and capable of doing nearly anything, like 
orchestration, but some things naturally lend themselves better to 
Ansible’s “vision of the world”. Just because you CAN do something with 
ansible doesn’t mean you should.

Idempotency is the name of the game here, and good ansible scripts can be 
run again and again without changing prior runs.

BUT. 

Ansible is stateless.Ansible modules that are idempotent check “state” of 
very specific things, (such as “file exists”)but ansible itself is not 
aware of anything before a module is run. Ansible does not remember what it 
has done. In this respect, one may consider Ansible to be merely a smarter, 
more powerful scripting language than bash. Logging, history, job execution 
and job run results are all the responsibility of the user to store 
somewhere, or else they simply do not exist after the session that ran them 
has been closed. 

Changing configurations for existing servers gets harder and harder as time 
goes on, because any ansible playbook can be run and you will have no 
knowledge of it having happened, thus leading to many possible errors in 
your configuration.


Terraform, on the other hand, is a stateful orchestration tool. We provide 
state declarations, where we define what we want our infrastructure to look 
like, and then Terraform goes out and actually does it for us. 

A major result of this difference between Ansible and Terraform is after 
the first setup has been completed. Let’s say we have a cluster of 5 nodes, 
which we want to scale out to 10. With ansible, you don’t have any way of 
knowing how many nodes exist. Even if we still have the original parameters 
used to create the cluster, we don’t know for sure that the cluster still 
actually reflects the original configuration. So we have to either trust in 
our own brains and the brains of our team, and former team members, that 
every change and ansible run was always logged, and that everything is well 
documented, or actually manually figure out what nodes exist. 

Let’s say that we live in a perfect world, and we know for a fact that the 
cluster has not changed since creation, and that we still have the original 
parameter file. 

In order r\to scale out our cluster to reach 10, we need to manually tell 
Ansible how many new servers to add in order to reach our new desired 
state. In our example, we need to tell ansible to add another five nodes. 
With Terraform, however, we simply declare that we want 10 nodes, and 
Terraform figures out how many to add based on what actually exists. 

The same goes for deletion.


Such an approach naturally means that Terraform likely does a much better 
job at orchestration, while Ansible should be used for adhoc, often 
unrepeatable tasks. A good example of a time when Ansible does better than 
Terraform is configuring a database instance. 

The Terraform solution for such things is to simply deploy all clusters 
with packer, or docker. Then all configuration is done manually in one 
image, and deployments should be very simple. (Another benefit of this is 
eliminating configuration drift) This seems to require that we maintain a 
multitude of images as templates. 

However, this cannot answer every need, and when, for example, you want to 
update the ~/.bash_aliases file across 500 nodes, Ansible seems to be the 
clear tool for the job.Disclaimer- I have only used ansible. My terraform 
knowledge is only from minor experimenting and research.



USE:

Ansible files are written in YAML. Terraform files are written in HCL 
(Hashi Config Language). Both are human readable.


Ansible files are run sequentially. TF rearranges its code files to run the 
right, logical way.


TF graph manages EVERYTHING - variables, resources, dependencies,etc 
required to launch instances.


SUMMARY:

Ansible and HashiCorp (the company behind Terraform) suggest using both 
tools together 
 
using both tools together to reach the perfect solution. I tend to agree, 
based on everything I’ve seen in my research on this topic.

On Monday, March 30, 2020 at 8:44:44 PM UTC+3, Kaushal Shriyan wrote:
>
> Hi,
>
> I have read about Ansible suited best for configuration management and 
> Terraform which is best suited for Provisioning. Is there a way to invoke 
> terraform scripts using ansible and Is there a way to invoke Ansible 
> playbook using Terraform?
>
> Any use cases which will help me understand better to choose the right 
> tool for the job? On what 

Re: [ansible-project] set_fact moudle error ansible

2020-03-31 Thread Vladimir Botka
On Mon, 30 Mar 2020 20:55:10 -0700 (PDT)
Sandy Hung  wrote:

> fatal: [localhost]: FAILED! => {
> "msg": "The task includes an option with an undefined variable. The 
> error was: 'dict object' has no attribute 'ansible_facts'
> [...]
>  - local_action:
>  module: efs_info
>  name: "{{ efs_vol_name }}"
>run_once: true
>register: _efs_fact
> 
>  - set_fact:
>  _efs_fact_id: "{{ efs_fact.ansible_facts.efs[0].file_system_id }}"

There are 2 problems.

1) "efs_info" says: "Note that the efs_info module no longer returns
ansible_facts!"
https://docs.ansible.com/ansible/latest/modules/efs_info_module.html#synopsis

2) The underscore "_" is missing in front of the variable "_efs_fact". Correct

  - set_fact:
  _efs_fact_id: "{{ _efs_fact. ... }}"

   But, first you might want to take a look at the content of the registered
   variable and see what is available

  - debug:
  var: _efs_fact

HTH,

-vlado

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


pgpdLgfPmk8T4.pgp
Description: OpenPGP digital signature


Re: [ansible-project] AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_fqdn'

2020-03-31 Thread Vladimir Botka
On Mon, 30 Mar 2020 19:28:13 -0700 (PDT)
Rajesh  wrote:

> - hosts: all
> [...]
>   template:
>   src: templates/server_list.j2
>   dest: /etc/server_list.txt
>   owner: automation
>   mode: '0600'
>   setype: net_conf_t
>   when: ansible_fqdn in groups['proxy']
> 
> [automation@workstation plays]$ cat templates/server_list.j2 
> {% for host in groups['all'] %}
> {{ hostvars[host]['ansible_fqdn'] }}
> {% endfor %}
> [...]
> fatal: [ansible2.example.com]: FAILED! => {"changed": false, "msg": 
> "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' has 
> no attribute 'ansible_fqdn'"}

Your playbook works for me. The problem is missing variable "ansible_fqdn" at
some host. You might want to find the host and see what's the problem. Try

  - hosts: all
tasks:
  - debug:
  var: ansible_fqdn

Why do you use "ansible_fqdn" in the "when" condition instead of
"inventory_hostname"? This implicates that you're mixing "ansible_fqdn" and
"inventory_hostname" in the inventory.

HTH,

-vlado

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


pgpT9CtwXdnrz.pgp
Description: OpenPGP digital signature