Re: [ansible-project] Variable resolution issue, bug or feature?

2019-09-13 Thread Vladimir Botka
Hi,

On Mon, 9 Sep 2019 09:33:06 -0700 (PDT)
Michael Cronenworth  wrote:

> I have a role that when it runs is only partially resolving variables.
> 
> Variable_A: defined in defaults - string
> Variable_B: defined in defaults - hostvars reference to Variable_C that 
> will be loaded through include_vars
> Variable_C: defined in file and loaded through include_vars - string to 
> reference Variable_A
> 
> The role task is to use Variable_B. When the role runs the task ends up 
> being set to "{{ Variable _A }}" instead of the string like Ansible stopped 
> resolving variables.
> 
> If I switch the role to use a Variable_A loaded through include_vars 
> instead Ansible resolves the variable completely.
> 
> Is this expected or is it a bug?

You should post at least the declaration of the variables. "Variable_A" and
"Variable_C" is clear. But what do you mean with "defined in defaults -
hostvar reference" ?

  "Variable_B: defined in defaults - hostvars reference to Variable_C"

It would be just guessing without complete, minimal, reproducible example.

Cheers,

-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/20190914061555.4511fb76%40gmail.com.


pgpdXrlpG5xue.pgp
Description: OpenPGP digital signature


[ansible-project] Re: Variable resolution issue, bug or feature?

2019-09-13 Thread Michael Cronenworth
On Monday, September 9, 2019 at 11:33:06 AM UTC-5, Michael Cronenworth 
wrote:
>
>
> Is this expected or is it a bug?
>
>
Anyone? I'm going to file a bug next week if there is no other comment. 

-- 
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/7b15490e-0783-43a9-802e-b28e671aba7b%40googlegroups.com.


Re: [ansible-project] Re: gcp_compute_instance module not attaching persistent disk to VM

2019-09-13 Thread Rafael Soutelino
Hello Dimitar,

Nope, not yet, I haven't revisited the issue in a while now.

Regards,
Rafael

On Sat, 14 Sep 2019 at 00:23, Dimitar Savov  wrote:

> Hello Rafael,
>
> Did you find a fix for this issue? I think I am experiencing the same
> problem.
>
> Best regards,
> Dimitar
>
> On Thursday, August 1, 2019 at 3:04:50 AM UTC+3, Rafael Soutelino wrote:
>>
>> Hi All,
>>
>> I’m working on a playbook that creates a new persistent disk in google
>> cloud, attaches to an existing VM, formats, mounts and sets it up.
>> Everything seems to be working fine except the step where the disk gets
>> attached, it seems ansible is ignoring that VM state change.
>>
>> I tried to simply call the existing VM again with the new disk, which
>> didn’t work. Then I thought it could be a problem with the fact that the
>> other existing disks were not declared. So I wrote some tasks to gather the
>> disks, create dictionaries that capture the disk properties as they are
>> required by the “disks” parameter of the gcp_compute_instance module, which
>> is how the below playbook is currently set up. But that didn’t work either.
>>
>> I’ve also tried to create tasks before and after the attempt to attach
>> the disk by setting the VM status to TERMINATED and RUNNING, to rule out
>> the possibility of google cloud not accepting attachments with the machine
>> running (although this is OK doing in the console).
>>
>> Anything I might be missing here?
>>
>> I noticed the azure_rm_managed_disk has a parameter called managed_by.
>> Maybe the GCP modules are yet to implement such functionality?
>>
>> Playbook: scratch.yml
>>
>> ---
>> - name: Add a scratch disk to an existing VM
>>   hosts: localhost
>>   gather_facts: no
>>   connection: local
>>
>>   vars_files:
>> - vars/gcp_vm
>>
>>   tasks:
>>   - name: Provision scratch and attach to VM
>> when: destroy == "no"
>>
>> block:
>>   - name: Getting facts from VM
>> gcp_compute_instance_facts:
>>   zone: "{{ zone }}"
>>   filters:
>>   - name = {{ instance_name }}
>>   project: "{{ gcp_project }}"
>>   auth_kind: "{{ gcp_cred_kind }}"
>>   service_account_file: "{{ gcp_cred_file }}"
>> register: vm
>>
>>   - name: Gathering VMs existing disks
>> set_fact:
>>   disks: "{{ vm['items'][0]['disks'] }}"
>>
>>   - name: Create scratch disk
>> gcp_compute_disk:
>>   name: "{{ scratch_disk_name }}"
>>   type: "{{ scratch_disk_type }}"
>>   zone: "{{ zone }}"
>>   project: "{{ gcp_project }}"
>>   auth_kind: "{{ gcp_cred_kind }}"
>>   service_account_file: "{{ gcp_cred_file }}"
>>   state: present
>> register: scratch
>>
>>   - name: Convert new disk to format expected by 
>> gcp_compute_instance_facts
>> vars:
>>   newdisk: []
>> set_fact:
>>   newdisk: "{{ newdisk + [ {'auto_delete': false, 'boot': false, 
>> 'source': item[1]} ] }}"
>> with_indexed_items: "{{ [ scratch ] }}"
>>
>>   - name: Create list of currently attached disks
>> vars:
>>   alldisks: []
>> set_fact:
>>   alldisks: "{{ alldisks + [ {'auto_delete': item['autoDelete'], 
>> 'boot': item['boot'], 'source': item} ] }}"
>> with_items: "{{ disks }}"
>>
>>   - name: Append new disk
>> set_fact:
>>   alldisks: "{{ alldisks + [ newdisk[0] ] }}"
>>
>>   - name: Attach disk to VM
>> gcp_compute_instance:
>>   state: present
>>   name: "{{ instance_name }}"
>>   disks: "{{ alldisks }}"
>>   zone: "{{ zone }}"
>>   project: "{{ gcp_project }}"
>>   auth_kind: "{{ gcp_cred_kind }}"
>>   service_account_file: "{{ gcp_cred_file }}"
>>
>>   - name: Get IP address from instance
>> gcp_compute_address:
>>   name: "{{ instance_name }}"
>>   region: "{{ region }}"
>>   project: "{{ gcp_project }}"
>>   auth_kind: "{{ gcp_cred_kind }}"
>>   service_account_file: "{{ gcp_cred_file }}"
>>   state: present
>> register: address
>>
>>   - name: Wait for SSH to come up
>> wait_for: host={{ address.address }} port=22 delay=10 timeout=60
>>
>>   - name: Add host to groupname
>> add_host: hostname={{ address.address }} groupname=vm
>>
>>
>> - name: Format and mount scratch disk
>>   hosts: vm
>>   connection: ssh
>>   become: True
>>   vars_files:
>> - vars/consultancy
>>   roles:
>> - scratch
>>
>> - name: Destroy scratch
>>   hosts: localhost
>>   gather_facts: no
>>   connection: local
>>
>>   vars_files:
>> - vars/gcp_vm
>>
>>   tasks:
>> - name: Destroy disk
>>   when: destroy == "yes"
>>   gcp_compute_disk:
>> name: "{{ scratch_disk_name }}"
>> zone: "{{ zone }}"
>> project: "{{ gcp_project }}"
>> auth_kind: "{{ gcp_cred_kind }}"
>> service_account_file:

[ansible-project] mysql_user cannot find an installed package

2019-09-13 Thread Mauricio Tavares
Trying to add a user to a mysql DB. Some relevant lines from playbook are:

mysql_packagelist:
  - python2-PyMySQL
[...]
- name: Install db prereqs
  package: name="{{mysql_packagelist}}" state=latest
[...]
- name: Create a db user
  mysql_user:
name: "{{ db_user }}"
password: "{{ db_password }}"
host: localhost
priv: '*.*:ALL'
state: present

When I run it, I get
[...]
TASK [db : Install db prereqs] *
changed: [server]

TASK [db : Install db] *
ok: [server]

TASK [db : create mysql-files] *
ok: [server]

TASK [db : Install db] *
skipping: [server]

TASK [db : Create a db user] ***
task path: /home/raub/dev/ansible/roles/db/tasks/main.yml:43
 ESTABLISH SSH CONNECTION FOR USER: root
 SSH: EXEC ssh -C -o ControlMaster=auto -o
ControlPersist=60s -o Port=2027 -o
'IdentityFile="/home/raub/.ssh/docker-test"' -o KbdInteractiveAuth
entication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,p
ublickey -o PasswordAuthentication=no -o 'User="root"' -o
ConnectTimeout=10 -o Con
trolPath=/home/raub/.ansible/cp/b6a1389d8c box.in.example.com '/bin/sh
-c '"'"'ech
o ~root && sleep 0'"'"''
 (0, '/root\n', '')
 ESTABLISH SSH CONNECTION FOR USER: root
 SSH: EXEC ssh -C -o ControlMaster=auto -o
ControlPersist=60s
-o Port=2027 -o 'IdentityFile="/home/raub/.ssh/docker-test"' -o
KbdInteractiveAuth
entication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,p
ublickey -o PasswordAuthentication=no -o 'User="root"' -o
ConnectTimeout=10 -o Con
trolPath=/home/raub/.ansible/cp/b6a1389d8c box.in.example.com '/bin/sh
-c '"'"'( u
mask 77 && mkdir -p "` echo
/root/.ansible/tmp/ansible-tmp-1568390316.23-256200089
709623 `" && echo ansible-tmp-1568390316.23-256200089709623="` echo
/root/.ansible
/tmp/ansible-tmp-1568390316.23-256200089709623 `" ) && sleep 0'"'"''
 (0,
'ansible-tmp-1568390316.23-256200089709623=/root/.ansible
/tmp/ansible-tmp-1568390316.23-256200089709623\n', '')
Using module file
/usr/lib/python2.7/dist-packages/ansible/modules/database/mysql/
mysql_user.py
 PUT
/home/raub/.ansible/tmp/ansible-local-115939mceb1/tmpQXP2
Mp TO 
/root/.ansible/tmp/ansible-tmp-1568390316.23-256200089709623/AnsiballZ_mysql
_user.py
 SSH: EXEC sftp -b - -C -o ControlMaster=auto -o
ControlPersis
t=60s -o Port=2027 -o 'IdentityFile="/home/raub/.ssh/docker-test"' -o
KbdInteracti
veAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostb
ased,publickey -o PasswordAuthentication=no -o 'User="root"' -o
ConnectTimeout=10
-o ControlPath=/home/raub/.ansible/cp/b6a1389d8c '[box.in.example.com]'
 (0, 'sftp> put
/home/raub/.ansible/tmp/ansible-local-115939mc
eb1/tmpQXP2Mp 
/root/.ansible/tmp/ansible-tmp-1568390316.23-256200089709623/Ansibal
lZ_mysql_user.py\n', '')
 ESTABLISH SSH CONNECTION FOR USER: root
 SSH: EXEC ssh -C -o ControlMaster=auto -o
ControlPersist=60s
-o Port=2027 -o 'IdentityFile="/home/raub/.ssh/docker-test"' -o
KbdInteractiveAuth
entication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,p
ublickey -o PasswordAuthentication=no -o 'User="root"' -o
ConnectTimeout=10 -o Con
trolPath=/home/raub/.ansible/cp/b6a1389d8c box.in.example.com '/bin/sh
-c '"'"'chmod u+x
/root/.ansible/tmp/ansible-tmp-1568390316.23-256200089709623/
/root/.ansibl
e/tmp/ansible-tmp-1568390316.23-256200089709623/AnsiballZ_mysql_user.py
&& sleep 0
'"'"''
 (0, '', '')
 ESTABLISH SSH CONNECTION FOR USER: root
 SSH: EXEC ssh -C -o ControlMaster=auto -o
ControlPersist=60s
-o Port=2027 -o 'IdentityFile="/home/raub/.ssh/docker-test"' -o
KbdInteractiveAuth
entication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,p
ublickey -o PasswordAuthentication=no -o 'User="root"' -o
ConnectTimeout=10 -o Con
trolPath=/home/raub/.ansible/cp/b6a1389d8c -tt box.in.example.com
'/bin/sh -c '"'"
'/usr/bin/python
/root/.ansible/tmp/ansible-tmp-1568390316.23-256200089709623/Ansi
ballZ_mysql_user.py && sleep 0'"'"''
 (1, '\r\n{"msg": "The PyMySQL (Python 2.7 and
Python 3.X) or
MySQL-python (Python 2.X) module is required.", "failed": true,
"invocation": {"mo
dule_args": {"update_password": "always", "login_user": null,
"host_all": false, "
priv": "*.*:ALL", "sql_log_bin": true, "state": "present",
"encrypted": false, "cl
ient_key": null, "connect_timeout": 30, "config_file":
"/root/.my.cnf", "ca_cert":
 null, "login_host": "localhost", "append_privs": false,
"login_unix_socket": null
, "host": "localhost", "user": "safeuser", "login_password": null,
"check_implicit
_admin": false, "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"login_port": 3
306, "name": "safeuser", "client_cert": null}}}\r\n', 'Shared
connection to box.in
.example.com closed.\r\n')
 Failed to connect to the host via ssh: Shared
connection to b
ox.in.

[ansible-project] Problem when attempting to create database with ansible

2019-09-13 Thread William Muriithi
Hello,

Have anyone attempted to use ansible to create database on mariaDB system
recently. I am having a problem and would appreaciate advice.

I have two tasks:

- name: create nextcloud database schema
  mysql_db: name={{database_name}} encoding=utf8mb4
collation=utf8mb4_bin  state=present  login_user=root
login_password="{{root_db_password}}"

- name: add nextcloud database user
  mysql_user: name={{mysql_username}} password={{mysql_password}}
priv='{{database_name}}.*:SELECT,INSERT,UPDATE,DELETE,DROP,CREATE,ALTER,INDEX,REFERENCES'
state=present check_implicit_admin=yes

They run fine if I am using mysql but are broken when the database is
Maria.  They fails with this error:

TASK [nextcloud : create nextcloud database schema]
***
fatal: [nextcloud.eng.perasotech.com]: FAILED! => {"changed": false, "msg":
"unable to connect to database, check login_user and login_password are
correct or /root/.my.cnf has the credentials. Exception message: (1045,
\"Access denied for user 'root'@'localhost' (using password: YES)\")"}

The thing is, I do have /root/.my.cnf and infact can login to mysql without
password.  There is a slight difference when I login manually though and I
suspect its what is causing me the pain.  See below at the differences, the
first being mysql and the other two sessions being MariaDB

Would you know what happening here by any chance?  Would really appreaciate
your help.


[root@oxygen ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 87077
Server version: 5.7.26-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

mysql> exit
Bye
[root@oxygen ~]# exit

[root@nextcloud ~]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: YES)
[root@nextcloud ~]#

[root@nextcloud ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.11-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

MariaDB [(none)]>

Regards,
William

-- 
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/CAE9rU%2B7PfTFh1yhF4KvqmnOre7_nHyYBYah%2BWViEXr74Lhwskw%40mail.gmail.com.


[ansible-project] end_host not working as expected

2019-09-13 Thread Damon Powell
Both end_host and end_play seem to both cause the job to skip all hosts. I 
know that only one host meets the condition so it should execute on 1 but 
exits for both. Am I missing something? I thought end_host would only end 
the play for the host that meets the when condition.


  tasks:
- name: Pre java-1.8.*-openjdk package check
  raw: rpm -qa java-1.8.*-openjdk | wc -l
  register: package_precheck

- block:
- name: "end play for host host if nothing to upgrade"
  debug:
msg: "nothing to upgrade, ending play for host"

- meta: end_host
  when: package_precheck.stdout > 0


-- 
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/0be19bde-4f16-4ff9-814b-e093f3ab2ccc%40googlegroups.com.


[ansible-project] Re: How to work around PERSISTENT_COMMAND_TIMEOUT

2019-09-13 Thread jean-christophe manciot
I have just found a mini workaround with *ansible_command_timeout *which 
can be used per command (instead of modifying the global 
PERSISTENT_COMMAND_TIMEOUT for all commands):
  vars:
ansible_connection: network_cli
ansible_network_os: nxos
ansible_password: "{{ connections.ssh.password }}"
ansible_user: "{{ connections.ssh.username }}"
*ansible_command_timeout*: "{{ firmware.transfer_timeout }}"
  net_get:
...


However, if there is a real issue during the transfer so that the target 
does not answer any more, we have to wait until *ansible_command_timeout *times 
out before moving on, although the transfer issue may have happened at the 
beginning of the transfer. 

-- 
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/7f4d2dfe-db66-4946-bcb4-af50d0a4021f%40googlegroups.com.


[ansible-project] How to work around PERSISTENT_COMMAND_TIMEOUT

2019-09-13 Thread jean-christophe manciot
Hi there, 

Every ansible network command has a PERSISTENT_COMMAND_TIMEOUT which 
"controls the amount of time to wait for response from remote device before 
timing out persistent connection". 

Actually, when using the *net_get* module with a very large file, the 
command times out during the transfer, even though both sides are still 
exchanging SCP messages, meaning the transfer is still underway & active. 

Shouldn't it time out **only** when there is no more communication between 
both nodes for the PERSISTENT_COMMAND_TIMEOUT period of time?

- Either we are supposed to guess how long each transfer is going to last, 
depending on the size of the file, the network load, the CPU load on both 
sides & in between and so on and adjust  PERSISTENT_COMMAND_TIMEOUT 
accordingly
- or there is way to avoid the command to timeout during the transfer, 
while still timing out when the target does not answer anymore after some 
time

Any suggestion?

-- 
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/1e71120f-c928-4d7f-a469-ce3c63251050%40googlegroups.com.


[ansible-project] Re: Chocolatey and installing GIT

2019-09-13 Thread Simon-Pierre Diamond
Hi Jordan,

Just for your information,

I guess I did not read the documentation properly, the winrm memory fix helped 
to run the everything through.

Although, it does not seem to work as expected. In the log I can see "  
Software installed to 'C:\\Program Files\\Git\\'"

This is when I run ansible-playbook  with verbose.

When I go and look on the server, the files are not present. which gets me 
wondering.

Also if I run the uninstall manually, it looks like git was not installed.

Anyway, I will probably just run win_command instead. But I figured I should 
state the issue here.

-Simon



From: ansible-project@googlegroups.com  on 
behalf of Simon-Pierre Diamond 
Sent: September 13, 2019 7:57 AM
To: Ansible Project 
Subject: Re: [EXTERNAL] [ansible-project] Re: Chocolatey and installing GIT

You are right Jordan, I could use win_command instead.

As of now, Git is the only software I need, and wanted it in an automated way, 
chocolatey was the easiest until that happens...

I will look into all that stuff, thank you, that should give me enough to look 
at.

Thank you!

-Simon

From: ansible-project@googlegroups.com  on 
behalf of Jordan Borean 
Sent: September 12, 2019 9:12 PM
To: Ansible Project 
Subject: [EXTERNAL] [ansible-project] Re: Chocolatey and installing GIT

This could be a result of a few things, what I would try is;


  *   Use win_command to run 'choco install git --yes --no-progress'
 *   If this fails then the error probably lies within the WinRM memory 
limits placed on a process
 *   If it doesn't fail then something might be up with the module
  *   Check if you can install any other chocolatey packages can be installed
 *   If not, then something is up with your Chocolatey install
  *   Try running with async, this should escape the WinRM memory limits I 
mentioned above
  *   Have a look on the server when running your win_chocolatey task and see 
what is taking up all the memory (powershell.exe, choco.exe, or some other exe)

Thanks

Jordan

--
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a522f223-58a0-49aa-9ed6-e4c70dfaf005%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/YT1PR01MB341836AFC5297F656692F8A1B6B30%40YT1PR01MB3418.CANPRD01.PROD.OUTLOOK.COM.

This message has been sent on behalf of a company that is part of the Harris 
Operating Group of Constellation Software Inc. These companies are listed 
here.
If you prefer not to be contacted by Harris Operating Group please notify 
us.

This message is intended exclusively for the individual or entity to which it 
is addressed. This communication may contain information that is proprietary, 
privileged or confidential or otherwise legally exempt from disclosure. If you 
are not the named addressee, you are not authorized to read, print, retain, 
copy or disseminate this message or any part of it. If you have received this 
message in error, please notify the sender immediately by e-mail and delete all 
copies of the message.

-- 
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/YT1PR01MB3418B54227A5AE8D4F85C987B6B30%40YT1PR01MB3418.CANPRD01.PROD.OUTLOOK.COM.


[ansible-project] vmware_guest runonce is waiting at welcome screen to click OK

2019-09-13 Thread phani akkina


Hi All,


 

We are trying to deploy the vms in vcenter and trying to execute some 
commands using runonce option. But runonce is waiting at welcome screen of 
the vm to manually click OK on a welcome message from the domain.




[image: Welcome_screen.PNG] 

















Thanks,

Phani Akkina

 

-- 
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/2c64636a-3fbe-4df4-94e3-e66e7898af23%40googlegroups.com.


Re: [ansible-project] Problem with "when" statement

2019-09-13 Thread MKPhil

>
> I'm not sure, but it sounds a bit as if the things you are comparing do 
> not contain the values you think they do


That was the problem!  Even though both variables looked like ints when 
displayed with debug one or other of them wasn't.  I explicitly converted 
them to int and it now works

when: item.unit_number|int == disk_unit|int



On Friday, 13 September 2019 12:58:10 UTC+1, Karl Auer wrote:
>
> What does "no longer works" mean? What did you expect, what did you get?
>
> The warning is correct - you should not use the braces in a when statement.
>
> I'm not sure, but it sounds a bit as if the things you are comparing do 
> not contain the values you think they do
>
> Regards, K.
>
>
> On Fri, Sep 13, 2019 at 7:42 PM MKPhil > 
> wrote:
>
>>
>> I'm trying to compare two variables in a "when" statement - when x = y do 
>> something.
>>
>> This code works:
>>
>> when: unit_number == {{ disk_unit }}
>>
>>
>> BUT I get a warning:
>>
>>  [WARNING]: conditional statements should not include jinja2 templating 
>> delimiters such as {{ }} or {% %}. Found: unit_number == {{ disk_unit }}
>>
>>
>> If I remove the {{ }} the statement no longer works.  How should I write 
>> the statement so it works and doesn't give the warning?  I've tried various 
>> combinations of double and single quotes and round brackets.
>>
>>
>> -- 
>> 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/92770bd7-d206-4a8c-83a8-0c949313557d%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Karl Auer
>
> Email  : ka...@2pisoftware.com 
> Website: http://2pisoftware.com
>
> GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
> Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>

-- 
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/b9b0d0d4-a868-4255-9b4b-3394820a0447%40googlegroups.com.


[ansible-project] Re: gcp_compute_instance module not attaching persistent disk to VM

2019-09-13 Thread Dimitar Savov
Hello Rafael,

Did you find a fix for this issue? I think I am experiencing the same 
problem.

Best regards,
Dimitar

On Thursday, August 1, 2019 at 3:04:50 AM UTC+3, Rafael Soutelino wrote:
>
> Hi All, 
>
> I’m working on a playbook that creates a new persistent disk in google 
> cloud, attaches to an existing VM, formats, mounts and sets it up. 
> Everything seems to be working fine except the step where the disk gets 
> attached, it seems ansible is ignoring that VM state change. 
>
> I tried to simply call the existing VM again with the new disk, which 
> didn’t work. Then I thought it could be a problem with the fact that the 
> other existing disks were not declared. So I wrote some tasks to gather the 
> disks, create dictionaries that capture the disk properties as they are 
> required by the “disks” parameter of the gcp_compute_instance module, which 
> is how the below playbook is currently set up. But that didn’t work either. 
>
> I’ve also tried to create tasks before and after the attempt to attach the 
> disk by setting the VM status to TERMINATED and RUNNING, to rule out the 
> possibility of google cloud not accepting attachments with the machine 
> running (although this is OK doing in the console). 
>
> Anything I might be missing here?
>
> I noticed the azure_rm_managed_disk has a parameter called managed_by. 
> Maybe the GCP modules are yet to implement such functionality?
>
> Playbook: scratch.yml
>
> ---
> - name: Add a scratch disk to an existing VM
>   hosts: localhost
>   gather_facts: no
>   connection: local
>
>   vars_files: 
> - vars/gcp_vm
>
>   tasks:
>   - name: Provision scratch and attach to VM
> when: destroy == "no"
>
> block:
>   - name: Getting facts from VM
> gcp_compute_instance_facts:
>   zone: "{{ zone }}"
>   filters:
>   - name = {{ instance_name }}
>   project: "{{ gcp_project }}"
>   auth_kind: "{{ gcp_cred_kind }}"
>   service_account_file: "{{ gcp_cred_file }}"
> register: vm
>
>   - name: Gathering VMs existing disks
> set_fact:
>   disks: "{{ vm['items'][0]['disks'] }}"
>
>   - name: Create scratch disk
> gcp_compute_disk:
>   name: "{{ scratch_disk_name }}"
>   type: "{{ scratch_disk_type }}"
>   zone: "{{ zone }}"
>   project: "{{ gcp_project }}"
>   auth_kind: "{{ gcp_cred_kind }}"
>   service_account_file: "{{ gcp_cred_file }}"
>   state: present
> register: scratch
>
>   - name: Convert new disk to format expected by 
> gcp_compute_instance_facts
> vars: 
>   newdisk: []
> set_fact:
>   newdisk: "{{ newdisk + [ {'auto_delete': false, 'boot': false, 
> 'source': item[1]} ] }}"
> with_indexed_items: "{{ [ scratch ] }}"
>
>   - name: Create list of currently attached disks
> vars:
>   alldisks: []
> set_fact:
>   alldisks: "{{ alldisks + [ {'auto_delete': item['autoDelete'], 
> 'boot': item['boot'], 'source': item} ] }}"
> with_items: "{{ disks }}"
>
>   - name: Append new disk
> set_fact:
>   alldisks: "{{ alldisks + [ newdisk[0] ] }}"
>
>   - name: Attach disk to VM
> gcp_compute_instance:
>   state: present
>   name: "{{ instance_name }}"
>   disks: "{{ alldisks }}"
>   zone: "{{ zone }}"
>   project: "{{ gcp_project }}"
>   auth_kind: "{{ gcp_cred_kind }}"
>   service_account_file: "{{ gcp_cred_file }}"
>
>   - name: Get IP address from instance
> gcp_compute_address:
>   name: "{{ instance_name }}"
>   region: "{{ region }}"
>   project: "{{ gcp_project }}"
>   auth_kind: "{{ gcp_cred_kind }}"
>   service_account_file: "{{ gcp_cred_file }}"
>   state: present
> register: address
>
>   - name: Wait for SSH to come up
> wait_for: host={{ address.address }} port=22 delay=10 timeout=60
>
>   - name: Add host to groupname
> add_host: hostname={{ address.address }} groupname=vm
>
>
> - name: Format and mount scratch disk
>   hosts: vm
>   connection: ssh
>   become: True
>   vars_files: 
> - vars/consultancy
>   roles: 
> - scratch
>
> - name: Destroy scratch
>   hosts: localhost
>   gather_facts: no
>   connection: local
>
>   vars_files: 
> - vars/gcp_vm
>
>   tasks:
> - name: Destroy disk
>   when: destroy == "yes"
>   gcp_compute_disk:
> name: "{{ scratch_disk_name }}"
> zone: "{{ zone }}"
> project: "{{ gcp_project }}"
> auth_kind: "{{ gcp_cred_kind }}"
> service_account_file: "{{ gcp_cred_file }}"
> state: absent
>
> Playbook call:
>
> ansible-playbook scratch.yml --extra-vars "instance_name=work 
> scratch_disk_name=wave destroy=no scratch_pathname=/data/wave"
>
> Result:
>
> PLAY [Add a scratch disk to an existing VM] 
> 

Re: [ansible-project] Problem with "when" statement

2019-09-13 Thread Karl Auer
What does "no longer works" mean? What did you expect, what did you get?

The warning is correct - you should not use the braces in a when statement.

I'm not sure, but it sounds a bit as if the things you are comparing do not
contain the values you think they do

Regards, K.


On Fri, Sep 13, 2019 at 7:42 PM MKPhil  wrote:

>
> I'm trying to compare two variables in a "when" statement - when x = y do
> something.
>
> This code works:
>
> when: unit_number == {{ disk_unit }}
>
>
> BUT I get a warning:
>
>  [WARNING]: conditional statements should not include jinja2 templating
> delimiters such as {{ }} or {% %}. Found: unit_number == {{ disk_unit }}
>
>
> If I remove the {{ }} the statement no longer works.  How should I write
> the statement so it works and doesn't give the warning?  I've tried various
> combinations of double and single quotes and round brackets.
>
>
> --
> 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/92770bd7-d206-4a8c-83a8-0c949313557d%40googlegroups.com
> 
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

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


Re: [EXTERNAL] [ansible-project] Re: Chocolatey and installing GIT

2019-09-13 Thread Simon-Pierre Diamond
You are right Jordan, I could use win_command instead.

As of now, Git is the only software I need, and wanted it in an automated way, 
chocolatey was the easiest until that happens...

I will look into all that stuff, thank you, that should give me enough to look 
at.

Thank you!

-Simon

From: ansible-project@googlegroups.com  on 
behalf of Jordan Borean 
Sent: September 12, 2019 9:12 PM
To: Ansible Project 
Subject: [EXTERNAL] [ansible-project] Re: Chocolatey and installing GIT

This could be a result of a few things, what I would try is;


  *   Use win_command to run 'choco install git --yes --no-progress'
 *   If this fails then the error probably lies within the WinRM memory 
limits placed on a process
 *   If it doesn't fail then something might be up with the module
  *   Check if you can install any other chocolatey packages can be installed
 *   If not, then something is up with your Chocolatey install
  *   Try running with async, this should escape the WinRM memory limits I 
mentioned above
  *   Have a look on the server when running your win_chocolatey task and see 
what is taking up all the memory (powershell.exe, choco.exe, or some other exe)

Thanks

Jordan

--
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a522f223-58a0-49aa-9ed6-e4c70dfaf005%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/YT1PR01MB341836AFC5297F656692F8A1B6B30%40YT1PR01MB3418.CANPRD01.PROD.OUTLOOK.COM.


[ansible-project] Re: Problem with "when" statement

2019-09-13 Thread Shivharsh Singh
Hey,

This is a genuine warning and was added to the 2.3 release purposefully. 
You don't need to use any special character at all and it will get rid of 
the warning. 

Simply, use the when statement as below:
---
- hosts: localhost
  connection: local
  gather_facts: false
  vars:
unit_number: 10
disk_unit: 10
  tasks:
  - debug:
 msg: "Hola, it works"
when: unit_number == disk_unit

Below is the output:
[root@oss-awx-01 AnsQuery]# ansible-playbook query.yml

PLAY [localhost] 
*

TASK [debug] 
*
ok: [localhost] => {
"msg": "Hola, it works"
}

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

Hope it is helpful !

Thanks,
Shivharsh

On Friday, 13 September 2019 15:12:14 UTC+5:30, MKPhil wrote:
>
>
> I'm trying to compare two variables in a "when" statement - when x = y do 
> something.
>
> This code works:
>
> when: unit_number == {{ disk_unit }}
>
>
> BUT I get a warning:
>
>  [WARNING]: conditional statements should not include jinja2 templating 
> delimiters such as {{ }} or {% %}. Found: unit_number == {{ disk_unit }}
>
>
> If I remove the {{ }} the statement no longer works.  How should I write 
> the statement so it works and doesn't give the warning?  I've tried various 
> combinations of double and single quotes and round brackets.
>
>
>

-- 
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/fe47e444-bf7a-4f73-ae4f-fa09bad89efd%40googlegroups.com.


[ansible-project] Problem with "when" statement

2019-09-13 Thread MKPhil

I'm trying to compare two variables in a "when" statement - when x = y do 
something.

This code works:

when: unit_number == {{ disk_unit }}


BUT I get a warning:

 [WARNING]: conditional statements should not include jinja2 templating 
delimiters such as {{ }} or {% %}. Found: unit_number == {{ disk_unit }}


If I remove the {{ }} the statement no longer works.  How should I write 
the statement so it works and doesn't give the warning?  I've tried various 
combinations of double and single quotes and round brackets.


-- 
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/92770bd7-d206-4a8c-83a8-0c949313557d%40googlegroups.com.


Re: [ansible-project] Re: Privileges for become_user

2019-09-13 Thread Vladimir Botka
On Fri, 13 Sep 2019 01:13:02 -0700 (PDT)
"'Torsten Lorenz' via Ansible Project" 
wrote:

> > > the sudo-configuration in our enviroment is pretty strict, so i´m sure, 
> > > that we couldn´t work with ansible in this cases. "Sudo su" to become   
> > > root isn´t allowed thanks a lot.

> > How are you going to "become" root? Just curious to learn the limitations 
> > of Ansible. 

> Thats how i log in and use sudo-commands manuel on this system:
> -> Login with my personal user (No  Sudo-privileges)
> -> Sudo su - sudouser  
> -> Type sudo /usr/bin/systemctl start filebeat.service  

Well, when you're not allowed to "become" root then you are not allowed to
configure the system and as result you can´t "work with ansible in this
cases".

Cheers,

-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/20190913103604.1b0ae4ee%40gmail.com.


pgpkcBuAgS0J2.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Re: Privileges for become_user

2019-09-13 Thread 'Torsten Lorenz' via Ansible Project
Hi,

ih´ve already seen this page and think that become_exe is what i´m 
searching for. But i´m not able to download this plugin, the github-page is 
not available.

Thats how i log in and use sudo-commands manuel on this system:

-> Login with my personal user (No  Sudo-privileges)
-> Sudo su - sudouser  
-> Type sudo /usr/bin/systemctl start filebeat.service

ansible uses the sudouser directly to execute commands on the remote 
servers

Am Freitag, 13. September 2019 09:58:59 UTC+2 schrieb Vladimir Botka:
>
> On Thu, 12 Sep 2019 23:54:30 -0700 (PDT) 
> "'Torsten Lorenz' via Ansible Project"  > 
> wrote: 
>
> > the sudo-configuration in our enviroment is pretty strict, so i´m sure, 
> > that we couldn´t work with ansible in this cases. "Sudo su" to become 
> root 
> > isn´t allowed. 
> > thanks a lot 
>
> Hi, 
>
> FYI, there are other plugins 
> https://docs.ansible.com/ansible/latest/plugins/become.html#plugin-list 
>
> How are you going to "become" root? Just curious to learn the limitations 
> of 
> Ansible. 
>
> Thank you, 
>
> -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/16631883-6571-4c73-8270-8e88f9eba0db%40googlegroups.com.


Re: [ansible-project] Re: Privileges for become_user

2019-09-13 Thread Vladimir Botka
On Thu, 12 Sep 2019 23:54:30 -0700 (PDT)
"'Torsten Lorenz' via Ansible Project" 
wrote:

> the sudo-configuration in our enviroment is pretty strict, so i´m sure, 
> that we couldn´t work with ansible in this cases. "Sudo su" to become root 
> isn´t allowed. 
> thanks a lot

Hi,

FYI, there are other plugins
https://docs.ansible.com/ansible/latest/plugins/become.html#plugin-list

How are you going to "become" root? Just curious to learn the limitations of
Ansible.

Thank you,

-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/20190913095844.161425ab%40gmail.com.


pgpjsEVZcJYvB.pgp
Description: OpenPGP digital signature