Re: [ansible-project] Templating error with Ansible 2.9 or higher

2020-02-21 Thread Hugo Gonzalez



On 2/19/20 8:02 AM, harry devine wrote:
I'm using the Satellite6 Content Views role found here: 
https://galaxy.ansible.com/ahuffman/satellite6_manage_content_views. 
It works on Ansible up to 2.8.6, but any version after that gives the 
following error:


TASK [satellite6_manage_content_views : Set content view remove list] 

fatal: [test-server]: FAILED! => {"msg": "Unexpected templating type 
error occurred on ({{ cv_ver_names | difference(cv_keep_list) }}): 
coercing to Unicode: need string or buffer, dict found"}


I filed an issue on the author's Github repo in October when Ansible 
2.9 rc5 was automatically installed on my system, but nothing has been 
done with it since I filed it.  I'd like to try and fix it myself, but 
I don't understand what the error means or is doing.  Here's the YAML 
code that's being executed when it fails:



All the debug statements you put in the code will set you see if the 
lists you're trying to get the differences of are actually lists. Can 
you post your output for those?



Hugo

--
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/97c41ac4-a61f-e435-b56b-f6703f218e2b%40redhat.com.


Re: [ansible-project] Re: How to source a file which contains environment variables in a linux

2020-02-21 Thread Hugo Gonzalez


On 2/20/20 3:53 AM, Sivaraman P wrote:
Gopi Krishna, Did you got any solution for this? Now I was in the same 
situation.


I can expect that any statements executed within the same shell task 
will have access to the variables, but nowhere else in the system.


What happens if you do the following?:

 - name: "source then env file"
   shell: |
     source  /home/myfiles/setup.env
     echo $ip_net
 echo $home_net

I'm guessing you should get the values you expect.

If you want to configure shell variables to be available system wide for 
interactive use, look into modifying .bashrc or .bash_profile


Hugo G.



On Wednesday, 21 February 2018 12:27:16 UTC+5:30, Gopi Krishna wrote:

Hi All,

 - name: "source then env file"
   shell: . /home/myfiles/setup.env

I used . & source to source the env file, but its was not
happening the way that works in linux environement

my setup.env:
export ip_net=xx.xx.xx
export home_net=xx.xx.xx


expected:
g...@xx.xx.xx.xx> . /home/myfiles/setup.env
g...@xx.xx.xx.xx> echo $ip_net
xx.xx.xx.xx
g...@xx.xx.xx.xx>


Actual:
g...@xx.xx.xx.xx> echo $ip_net

g...@xx.xx.xx.xx>

its throwing empty for the variable ip_net, how to achieve this

--
You received this message because you are subscribed to the Google 
Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to ansible-project+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cd73a095-3a89-4f01-b774-352c79d967f3%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/073649d7-d9fe-7399-10f2-dba363d5a4ae%40redhat.com.


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

2020-02-12 Thread Hugo Gonzalez



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

I got to the bottom of this eventually :)

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



Whoa! careful there! :)

Hugo G.

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


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

2020-02-11 Thread Hugo Gonzalez
Without knowing anything about how you got those values, it would be {{ 
query_result.msg | join(' ') }}


Hugo G.





If I do
    - local_action:
        copy content={{query_result.msg}}
dest=/home/ansible/Playbooks/{{sname}}/sql/revoke.sql

I am getting
[["Revoke EXECUTE on UTL_FILE from TESTACC1;"], ["Revoke EXECUTE on 
UTL_FILE from TESTACC2;"]]


I need to get this
Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE 
from TESTACC2;


--
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/2a69d90d-3ea8-4615-8f63-ace11f83c622%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/757a99a8-4b95-b3d2-d432-02335c18b7c7%40redhat.com.


Re: [ansible-project] When var1 == "yes" and var2 == "no"

2020-02-11 Thread Hugo Gonzalez



On 2/11/20 11:44 AM, Jesse Lyon wrote:

So,

I'm having fits with when conditionals matching strings
No matter what I do, it applies each conditional, the combination of 
the variables doesn't seem to count for ... anything.


what the heck am I doing wrong? additionally, is there a better way to 
do this?



Are you actually comparing the strings "yes" and "no" to the variables? 
If they're actual booleans, you will be better off by doing:


when: share_fim_managed and not share_azure_managed

when: not share_fim_managed and share_azure_managed

when: share_fim_managed and share_azure_managed


All nonempty strings are true, even if they contain the strings "false" 
or "true", you should be careful when comparing truth values. See here:



---
- hosts: localhost
  vars:
    truestringvar: "true"
    falsestringvar: "false"
    trueboolvar: true
    falseboolvar: false

  tasks:
    - debug:
    msg: Since booleans matter, this message is not shown.
  when: trueboolvar == 'true'
    - debug:
    msg: boolean values DO matter (this string is shown)
  when: trueboolvar
    - debug:
    msg: The string that says false is not false, this message will 
not be shown

  when: not falsestringvar





--
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/0ebabe47-8b80-60e3-3eb3-87d301627c0b%40redhat.com.


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

2020-02-10 Thread Hugo Gonzalez


On 2/10/20 3:49 AM, 'deewon' via Ansible Project wrote:

Hi all,

I'm pretty certain someone has figured this out so any hints will be 
appreciated


I've attached an  azure managed disk to a linux vm  but noticed it 
doesn't have any disk label  i.e.



The disk label is the partition table, and will not be recognized for an 
unpartitioned disk. There is a parameter in the module called "label" 
with a default of "msdos" as the table format.


https://docs.ansible.com/ansible/latest/modules/parted_module.html#parameter-label

So I guess you can pass it along your partition definitions. Just make 
sure it works idempotently, I haven't tested it.


Hugo G.






Consequently, the ansible parted module returns the below error when 
attempting to create a partition


TASK [role_azure_disk : Partition Azure Disk] 
***

task path: /etc/ansible/roles/role_azure_disk/tasks/main.yml:7
fatal: [labserver]: FAILED! => {"changed": false, "err": "Error: Could 
not stat device /dev/sdc - No such file or directory.\n", "msg": 
"Error while getting device information with parted script: 
'/sbin/parted -s -m /dev/sdc -- unit 'KiB' print'", "out": "", "rc": 1}


To achieve idempotence when re-running playbooks , I'm trying to avoid 
using fdisk passed to the shell module i.e. (echo n; echo p; echo 1; 
echo ; echo ; echo w) | sudo fdisk /dev/sdc


Will appreciate any ideas on how to get around this

Thanks

--
You received this message because you are subscribed to the Google 
Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to ansible-project+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/49c9a80b-1302-4463-a6ee-0e1a2e049e8b%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/fddc5b5c-becc-cb23-74e1-dd70ca0dc0a9%40redhat.com.


Re: [ansible-project] assert vs fail

2019-07-12 Thread Hugo Gonzalez

Hi,

On 7/12/19 10:12 AM, S C Rigler wrote:
Is there any advantage to using the assert module vs the fail module 
to bail out of a play if an expected condition isn't met?


I don think there's a technical advantage, but the concepts are different:

* use assert for checking against abnormal conditions, like a malformed 
or missing input, missing file, that should never happen in the normal 
flow of your playbook.


 * use fail for aborting the playbook on operations that can 
meaningfully fail and that you have an idea what's happening




--
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/CAFbiokc40fUQbzJ1J-5XKtWDZenCmYK35mWwBeUaW6OZ0qObvQ%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.

--

Hugo F. González

Senior Automation Consultant

Red Hat LATAM 

hgonz...@redhat.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 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/89982417-356c-d6db-b8a7-ae31918bd461%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect Module in Ansible

2019-02-27 Thread Hugo Gonzalez

Hello Deepak,

On 2/27/19 7:43 AM, Deepak Sharma wrote:




I am using expect   module to install one TIBCO products ,

- name: Start Streambase installation
  expect:
    echo: yes
    chdir: /opt/tibco//{{ env }}/install
    command: ./TIB_sb-cep_{{ tib_streambase_version
}}_linux_x86_64.archive-bin
    responses:
      (.*)Extract files to which directory (.*): /opt/tibco/{{ env
}}/streambase/sb-cep/10.3
      (.*)Do you accept this license (.*): "yes"


But we are getting below error .

(1, '\r\n{"msg": "The pexpect python module is required",
"failed": true, "exception": "WARNING: The below traceback may
*not* be related to the actual failure.\\n File
\\"/tmp/ansible_expect_payload_vjbqxk/__main__.py\\", line 98, in
\\n import pexpect\\n", "invocation": {"module_args":
{"chdir": "/opt/tibco//SIT/install", "responses": {"(.*)Do you
accept this license (.*)": "yes", "(.*)Extract files to which
directory (.*)": "/opt/tibco/SIT/streambase/sb-cep/10.3"},
"removes": null, "echo": true, "creates": null, "command":
"./TIB_sb-cep_10.3.0_linux_x86_64.archive-bin", "timeout":
30}}}\r\n', 'OpenSSH_7.2p2 Ubuntu-4ubuntu2.7, OpenSSL 1.0.2g 1 Mar
2016\r\ndebug1: Reading configuration data
/opt/jenkins/.ssh/config\r\ndebug1: /opt/jenkins/.ssh/config line
1: Applying options for *\r\ndebug1: Reading configuration data
/etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19:
Applying options for *\r\ndebug1: auto-mux: Trying existing
master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2:
mux_client_hello_exchange: master version 4\r\ndebug3:
mux_client_forwards: request forwardings: 0 local, 0
remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3:
mux_client_request_alive: entering\r\ndebug3:
mux_client_request_alive: done pid = 8282\r\ndebug3:
mux_client_request_session: session request sent\r\ndebug1:
mux_client_request_session: master session id: 2\r\ndebug3:
mux_client_read_packet: read header failed: Broken pipe\r\ndebug2:
Received exit status from master 1
we have also added pexpect python module, but issue still the same .

Did you install the module using pip on the *managed node*? Also, a 
pretty new version is required, if you installed with the managed node's 
package manager, the version may be too old.


Hugo G.


Kindly guide us and your help is appreciate .
Regards,
Deepak
-- 
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/74360946-3b87-4ce2-b769-65218514d946%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/CA%2BCJ-ubGUuXG_Bmom-8sWm6bMVYW%2Bk%2BaKsm3gE3oWFO7s%2B9-7w%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.

--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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/7ff07154-4055-82dc-2b1c-2de6d0fcade6%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] select one and two caracter of variable

2019-02-13 Thread Hugo Gonzalez


On 2/13/19 3:26 AM, ryad9200...@gmail.com wrote:

Hi all,

I don't now why this task not works:

- set_fact:
      my_variable: "{{ ansible_user[0 and 1] + 'gis' if 
ansible_user!='wildfly' else 'wildfly' }}"


But *ansible_user[0] + ansible_user[1]* works but i want one syntaxe 
shorter, exemple *ansible_user[0 and 1] *but this syntax not works !!



Why would you expect it to work?  'and' is a logical operator. Jinja2 
(which is used for templating a in Ansible) uses python slicing and 
substrings.


Take a look here:

https://www.journaldev.com/23774/python-string-substring


The syntax you're looking for is slicing:   variable[start:end]


--
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/0b9e91bf-4cfe-f17f-f9ea-d3bf81445004%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Ansible - write only specific output

2019-02-13 Thread Hugo Gonzalez

Hello,

I've seen this use case before. It's easier to build the reporting 
directly into the playbook. You can, for exmaple, create a template that 
will print what you want for each managed host, and assemble the pieces 
later:


On 2/13/19 11:55 AM, DM wrote:


The example below is a yaml file to gather data from a Juniper 
Networks Switch device.

How would you do it this?


I've seen this exact same use case. It's better to build the reporting 
directly into the playbook. You can, for exaple, create a template that 
will print what you want for each managed host, and assemble the pieces 
later:




- name: Get Facts
  hosts: 192.168.1.1
  roles:
    - Juniper.junos
  connection: local
  gather_facts: no
  vars_prompt:
    - name: ADMUSER
      prompt: Username
      private: no
    - name: ADMPASS
      prompt: password
      private: yes
  tasks:
    - name: Retrieve LLDP Neighbor Information Using PyEZ-included Table
      juniper_junos_table:
        file: "lldp.yml"
        table: "RouteTable"
        host: '{{ inventory_hostname }}'
        user: '{{ ADMUSER }}'
        passwd: '{{ ADMPASS }}'
        port: 830
      register: response
    - name: Print response
      debug:
        var: response
    - copy: content="{{ your_json_feed }}" dest=/etc/ansible/file-1




Something like adding a template file like:

|{{ inventory_hostname }} : {{ response }} |

​


Then templating it:

|- name: create part of the report for {{ inventory_hostname }} 
template: src: my_template.j2 dest: "{{ inventory_hostname.report }}" |


​


Then you can use the  fetch module to bring it over to the controller 
and the assemble module to generate a full report.



Hope that helps,


Hugo









On Wednesday, February 13, 2019 at 8:45:06 AM UTC-5, DM wrote:

How do you write to a file the output of a yaml?

If possible, how do you only write to a file specific info if?

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/a61598d0-736e-43e2-9b10-a07981c9e3cc%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.

--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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/51742d2b-5715-eb6f-c4cd-e63439534b62%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] problem: changing account password with ansible on aix

2019-02-12 Thread Hugo Gonzalez
The method for salting and hashing the password is probably different in 
AIX, remember you's passing a hashed password and that's platform 
dependent. You will have to find a way to do that for AIX. There's some 
information in the following links


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

https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module


Hugo G.


On 2/12/19 11:48 AM, jzme...@gmail.com wrote:
Hi. i run my playbook to change user account password but this dont 
work , not change the password.

iam using aix 6 and 7.

this same playbook work fine on Linux.

this is my simple playbook to change password on a user acoount .

- name: Change account password
  hosts: "AIXQA"
  remote_user: ext00025
  tasks:
  - name: Changing user account password ext00025
    user: name=ext00025 update_password=always 
password=$1$SysAdm1n$W01N55jxDbwQf0JZsuKNn0


regards.

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

For more options, visit https://groups.google.com/d/optout.

--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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/afad95fb-09ac-b846-8a00-2fd4fdfc9709%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible Inventory file

2019-02-01 Thread Hugo Gonzalez

Hello Deepak,

You're not following the right syntax for a YML inventory. Check the 
following link:


https://docs.ansible.com/ansible/latest/plugins/inventory/yaml.html

I don't know what you're trying to do with the " 2022" string there. 
It's not valid yaml.


According to the docs in the link. You probably have to do something 
like this.


$ cat lala.yml
KafkaNonprodservers:
  hosts:
  abc.abc.com:
  abd.abd.com:
  vars:
  ansible_user: abc

You can always analyze your inventory file with ansible-inventory, like 
this:


$ ansible-inventory  -i lala.yml  --graph --vars
@all:
  |--@KafkaNonprodservers:
  |  |--abc.abc.com
  |  |--abd.abd.com
  |  |--{ansible_user = abc}
  |--@ungrouped:

Hope that helps,


Hugo


On 2/1/19 3:01 AM, Deepak Sharma wrote:


Hi Everyone,

I am new to Ansible , I have created new inventory yml file with below 
details .


KafkaNonprodservers:
  hosts:
      abc.abc.com:2022
      abd.abd.com:2022
   ansible_user : abc

but I am getting below error

+ ansible-inventory -i ./ansible/Hosts.yml --list [WARNING]: Skipping 
unexpected key (ansible_user) in group (KafkaNonprodservers), only 
"vars", "children" and "hosts" are valid

{

Can you please guide me,.

Regards,
Deepak
--
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/fb100f1b-3641-4267-8e35-e187c341631a%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.

--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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/a612ebf2-e9c3-0223-da6f-a924ebf1b755%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Password change automation

2019-01-25 Thread Hugo Gonzalez
The password field must be hashed for all unices. You’re using plaintext 
for that. The ansible docs:


Optionally set the user's password to this crypted value.
On macOS systems, this value has to be cleartext. Beware of security issues.
To create a disabled account or Linux systems, set this to '!' or '*'.
See 
https://docs.ansible.com/ansible/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module
 for details on various ways to generate these password values.

Hugo


Untitled

--
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/a12d21b4-d094-4ce1-6e72-d8bc37e64d7e%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] alternate shadow file?

2019-01-17 Thread Hugo Gonzalez
If there is a complete chroot environment under /mnt/pxe, you could 
configure a new ansible user to always log into a chrooted environment, 
using a sshd_config file and these two lines:


Match User new_ansible_user
ChrootDirectory /mnt/pxe

Then use ansible normally under that special user.

But that seems overkill, it would be easier to script the password 
change locally with mkpassword and some text manipulation.



On 1/16/19 11:00 AM, eric.b.hymowitz via Ansible Project wrote:

Greetings.

I would like to use the "user" module to change my password, but the 
shadow file is not located in /etc/shadow . It's in an alternate 
location, specifically, /mnt/pxe/etc/shadow .  Is there a way to 
accomplish this?


I have a bad feeling that the answer is "only if the underlying passwd 
command allows this option," which it doesn't.


I suppose the "lineinfile" module will accomplish this with a little 
bit of extra effort, but it would be nice if the standard "user" 
module would allow this.


Maybe somebody has a better idea?

Thanks.

--EbH
--
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/e1b08699-09ab-4ae8-b8dc-7ebe3aef0bdb%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.

--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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/1cb5df06-65cc-16a8-fdb6-c4a7365effb5%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Use of Ansible under PowerVC

2019-01-16 Thread Hugo Gonzalez

Hello Bernard,

On 1/16/19 4:19 PM, Bernard Tremblay wrote:

Hi,

We are trying to use ansible in a PowerVC environment.
We have a cluster of Power machines connected to a SAN box, we run 
SLES linux and Windows server to use SAP stuff.
I would like to find any resources/documentation/Playbooks/Roles about 
using ansible in that context.


Anybody knows if it is possible to create VM using the REST API of  
PowerVC and is there any documentation somewhere in this galaxy ?


From 
https://www.ibm.com/support/knowledgecenter/en/SSVSPA_1.3.2/com.ibm.powervc.cloud.help.doc/powervc_pg_kickoff_cloud.html


"You can use several types of interfaces to build solutions on top of 
PowerVC:
Supported OpenStack APIs - These APIs are a subset of the APIs provided 
by OpenStack and can be used with PowerVC without any modifications.
Extended OpenStack APIs - These APIs are a subset of the APIs provided 
by OpenStack, but their functions are extended by PowerVC.
PowerVC APIs - These APIs do not exist in OpenStack and are exclusive to 
PowerVC."



I suggest you start by browsing through the OpenStack modules in Ansible.:

https://docs.openstack.org/openstack-ansible/latest/

https://docs.ansible.com/ansible/latest/modules/list_of_cloud_modules.html#openstack


--
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/913aa7a4-b6c2-3edb-2b1f-20be7f3776ed%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to import/load env/ini file that is located in file on the Remote/Target server?

2019-01-14 Thread Hugo Gonzalez

Hi Chaz,

On 1/14/19 11:02 AM, Chaz_E wrote:

I like the idea of this suggestion.
Is local-facts-facts-d 
 usable 
as Non-Root?


They come up as part of the dictionary returned by the setup module 
as*ansible_local,* so yes.


Can facts be loaded from the user's $HOME/.ansible/ , like 
$HOME/.ansible/facts.d or something like that?

I see for windows there is fact_path does that work for Linux?

Reading 
https://docs.ansible.com/ansible/2.4/intro_configuration.html#fact-path 
it has precisely that use case (a user's HOME). I don't see that it 
should not work for Linux. You should try it on a host and see.


Now, back to what you're trying to do. Your variable file is almost an 
INI file, it just needs a section.


I was curious, so I tried something like what you're trying to do:

[root@gladys facts.d]# pwd
*/etc/ansible/facts.d*

[root@gladys facts.d]# ls -l
total 4***-rwxr-xr-x. 1 root root 106 Jan 14 18:47 factfile.fact*

[root@gladys facts.d]# cat factfile.fact
*#!/bin/bash# An ini file must have a sectionecho '[general]'cat 
/home/management/thishasvariables.txt*

[root@gladys facts.d]# ls -l /home/management/thishasvariables.txt***-rw-r--r--. 1 management management 11 Jan 14 18:48 
/home/management/thishasvariables.txt*


[root@gladys facts.d]# cat /home/management/thishasvariables.txt
*spam=eggs*


my_user@mybox:~$ ansible -u management -i 'gladys, ' all -m setup  -a 
"filter=ansible_local"
*gladys | SUCCESS => {"ansible_facts": {"ansible_local": {"factfile": {"general": 
{"spam": "eggs"}}}}, "changed": false}*



This works. Whether it is secure or not, that's a different matter, it does 
take a user-supplied file and present it as facts for the host.
Cheers,

Hugo









--
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/b0d9fb18-f3a0-8460-b792-3610857222f1%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to import/load env/ini file that is located in file on the Remote/Target server?

2019-01-10 Thread Hugo Gonzalez

Hello Chaz,

On 1/10/19 11:00 AM, Chaz_E wrote:
QUESTION: How can we load or import an env/ini file that is located in 
a file on the Remote/Target server?


GOAL:
We have an env/ini file on the remote/target server.
We want to read in that file and use the values as variables for the 
tasks on that machine.
( FYI: Our process does not allow for saving these variables in the 
Inventory - even though that would be nice. )


Here is an example of what our ini/env file looks like:
Path: /devops/properties/Admin.properties
username = FooAdmin
password = bar123XYZ
activate = no
(Basically property format or ini format without any sections)


Can't you link/transform your file to be a local facts file? Take a look at

https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#local-facts-facts-d




--
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/918e7bf6-6598-4e7b-7917-57cbd515b6e8%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Hugo Gonzalez

Can you try removing the "

ignore_errors:yes
"you had before? Maybe something in failing in the facts gathering and, 
naturally, the variables did not get populated.



Here's the full playbook and template I used to test (this does not even 
need to escalate privileges):


---
- hosts: all

  tasks:

    - name: Render the known_hosts file locally
  template:
    src: template.j2
    dest: /tmp/known_hosts
  delegate_to: localhost
  run_once: true

    - name: Copy the rendered file to all the nodes
  copy:
    src: /tmp/known_hosts
    dest: /tmp


Template:

{% for host in groups['all'] %}
{{ hostvars[host]['ansible_ssh_host_key_ecdsa_public'] }}
{% endfor %}





On 1/7/19 10:30 AM, Freddie Eisa wrote:

Same error, can you send full playbook details over you are testing?

localhost]: FAILED! => {"changed": false, "msg": 
"AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' 
has no attribute 'ansible_ssh_host_key_ecdsa_public'"}


On Jan 4, 2019, at 11:47 AM, Hugo Gonzalez <mailto:hgonz...@redhat.com>> wrote:




--
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/3eaa0eef-e547-f758-5c96-55276770f967%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-04 Thread Hugo Gonzalez



template:

{% for host in groups['all'] %}
{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
{% endfor %}

This template also works for me, and the keys are different. So you 
might want to try it:


{% for host in groups['all'] %}
{{ hostvars[host]['ansible_ssh_host_key_ecdsa_public'] }}
{% endfor %}


--
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/434eb480-74f4-5d68-f97c-fc2c9469b412%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-04 Thread Hugo Gonzalez

Hello Freddie

On 1/3/19 5:23 PM, Freddie Eisa wrote:

What version are you running? The linux host is centos7.6

Ansible is 2.5.1, managed hosts are two Centos 7.6 cloud servers in my 
tests.



I tried the following:

- gather facts (automatic)

- locally render the template *on the controlling node*, once

- push the templated file to the managed hosts.


Curious if this will work for you:


template:

{% for host in groups['all'] %}
{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
{% endfor %}

playbook:

---
- hosts: all

  tasks:
    - name: Render the known_hosts file locally
  template:
    src: template.j2
    dest: /tmp/known_hosts
  delegate_to: localhost
  run_once: true

    - name: Copy the rendered file to all the nodes
  copy:
    src: /tmp/known_hosts
    dest: /tmp


---


Still not getting the error you're getting, except when trying to use 
the variable as *ansible_*ssh_host_key_ecdsa_public and that's not 
consistent, so I may be running into a completely different issue.



--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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/65568060-fa3f-f900-625c-a8f07f63440e%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Hugo Gonzalez

Got to be something else. Are these linux hosts?

I tried this and it works:

playbook:

---
- hosts: all

  tasks:
    - template:
    src: template.j2
    dest: /tmp/knownhosts



template:

{% for host in groups['all'] %}
{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
{% endfor %}

--

I suggest you run the setup module on your managed hosts and see the 
structure of the facts on your hosts then, and see if the host keys are 
there with that name.



Hugo G.


On 1/3/19 4:33 PM, Freddie Eisa wrote:

This is what I’m running

My role
- name: Template Knownhosts
template: src=./ssh_key.j2 dest=/tmp/temp.conf

My template
{% for host in groups['all'] %}
   "{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}"
{% endfor %}

My playbook

---
- name:Centos 7Servers
hosts:servers_all
gather_facts:True
ignore_errors:yes
roles:
   - linux-role


--
HUGO F.GONZALEZ

SENIOR CONSULTANT

Red HatLATAM 



--
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 toansible-project+unsubscr...@googlegroups.com 
.
To post to this group, send email toansible-proj...@googlegroups.com 
.
To view this discussion on the web 
visithttps://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com 
.

For more options, visithttps://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/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com 
.

For more options, visit https://groups.google.com/d/optout.

--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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/8feca239-8c6b-4ef8-8331-4d26489f125c%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Hugo Gonzalez


On 1/3/19 4:26 PM, Freddie Eisa wrote:

I had tried but still receive

fatal: [server]: FAILED! => {"changed": false, "msg": 
"AnsibleUndefinedVariable: 'dict object' has no attribute 
'ssh_host_key_ecdsa_public'"}


Please post the play you're using, or at least the relevant task and 
template.



This works for me and prints the key.---
- hosts: all

  tasks:
    - debug:
    msg: "{% for host in groups['all'] %} {{ 
hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }} {% 
endfor %}"




--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Hugo Gonzalez


On 1/3/19 3:34 PM, Freddie Eisa wrote:
So it depends on the host and how they are named and was really a test 
case. The one I’m really concerned about is this one now



{% for host in groups['servers_production'] %}
{{ hostvars[host]['ssh_host_key_ecdsa_public'] }}
{% endfor %}


I think you mean: 
hostvars[host]*['ansible_facts']*['ssh_host_key_ecdsa_public']


This works for me and prints the key.---
- hosts: all

  tasks:
    - debug:
    msg: "{% for host in groups['all'] %} {{ 
hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }} {% 
endfor %}"



Hugo G.



--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/d10c2a5d-48dd-dd67-d85e-4cd3a29d819d%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Inventory scripts: How to add debug info when run via Ansible?

2019-01-03 Thread Hugo Gonzalez

Hi Jimmy,

On 12/27/18 5:57 AM, Jimmy Htor wrote:

Hey,

The way I see it you either output to STDOUT, which would make debug 
output part of the inventory data, thus corrupt it. Or you output to 
STDERR and Ansible will treat is as actual errors (and show it using 
red color).


Is there another way to cleanly provide debug info during an Ansible 
run besides writing to a file?



JSON doesn't support comments, but you can create a dummy variable 
called _comment and put your debugging messages there, right in the 
JSON. An unused variable won't mess up your inventory data.



Another option is to use the  syslog facility for whatever language 
you're writing the inventory script in.


In bash, it would be :

$ logger "spam and eggs happened"


Cheers,


Hugo



--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 





--
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/ed62e50d-7450-efbc-bd9a-6c0598547d75%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Hugo Gonzalez

Hello Freddie,


On 1/3/19 12:04 PM, Freddie Eisa wrote:


{"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has 
no attribute 'eth0'"}



How do you know what to look for in ansible_facts? Run the setup module 
against your managed hosts and see what the facts look like.


I have this on a node of mine:

  "ansible_facts": {
...,

 "ansible_default_ipv4": {
    "address": "",
    "alias": "eth0",
    "broadcast": "",
    "gateway": "",
    "interface": "eth0",
    "macaddress": "X",
    "mtu": 1500,
    "netmask": "255.255.248.0",
    "network": "XXX",
    "type": "ether"
    },
}


I don't see any hostvars[host]['ansible_facts']['eth0']['ipv4']['address']

Try  $ ansible  -m  setup and examine the output to see how 
you should look for eth0's IP address.



Cheers,


Hugo





--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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/4473f03c-a4f0-f89c-5d92-77b2cf85ba01%40redhat.com.
For more options, visit https://groups.google.com/d/optout.