[ansible-project] Re: help on loop over list of dicts

2015-12-10 Thread Mgsz
Thank you Mike for the reply!
One of my co-worker helped me out. Basically, I was using nested with_items 
in two playbook.
I have playbook1 running with_items to include playbook2 with tasks which 
also trying to use with_items, so it failed in the 2nd playbook which the 
with_items are not looping using new value, still using the items in 
playbook1.

Ansible team, is what I described correct? I think I may need to redo the 
playbook with with_nested see if I can make it work. 


On Thursday, December 10, 2015 at 8:16:05 AM UTC-8, Mike Biancaniello wrote:

> Not sure what you're doing wrong. Maybe it's the way you define 
> dev_interfaces (yeah, it makes no sense why it would work in debug, but not 
> in with_items, but sometimes that happens).
>
> This worked for me:
> ---
> - name: stuff
>   connection: local
>   gather_facts: no
>   hosts: localhost
>
>   vars:
> dev_interfaces:
>   - subnet: 10.0.0.0/31
> peer_addr: 10.0.0.1
> name: Ethernet0
> mask: 255.255.255.254
> prefixlen: 31
> addr: 10.0.0.0
>
>   tasks:
> - debug: msg="{{ dev_interfaces[0].name }}"
>
> - name: debug message interface name
>   debug: msg="{{item.name}}"
>   with_items: "{{ dev_interfaces }}"
>
>
> output:
> PLAY [stuff] 
> ** 
>
> TASK: [debug msg="{{ dev_interfaces[0].name }}"] 
> ** 
> ok: [localhost] => {
> "msg": "Ethernet0"
> }
>
> TASK: [debug message interface name] 
> ** 
> ok: [localhost] => (item={'subnet': '10.0.0.0/31', 'peer_addr': '10.0.0.1'
> , 'name': 'Ethernet0', 'prefixlen': 31, 'mask': '255.255.255.254', 'addr': 
> '10.0.0.0'}) => {
> "item": {
> "addr": "10.0.0.0", 
> "mask": "255.255.255.254", 
> "name": "Ethernet0", 
> "peer_addr": "10.0.0.1", 
> "prefixlen": 31, 
> "subnet": "10.0.0.0/31"
> }, 
> "msg": "Ethernet0"
> }
>
> PLAY RECAP 
>  
> localhost  : ok=2changed=0unreachable=0failed=
> 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 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/ce5f9a1b-d805-4bdf-9330-57f36b76e784%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: core.cloud.openstack Error Fetching Image List

2015-12-10 Thread Hugh Ma
This is from the inventory script. Everything is fine until it hits glance 
to pull the image object.

Couldn't construct image object
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/shade/openstackcloud.py", 
line 254, in _get_client
**kwargs)
  File 
"/usr/local/lib/python2.7/dist-packages/os_client_config/cloud_config.py", 
line 300, in get_legacy_client
return client_class(*constructor_args, **constructor_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/glanceclient/client.py", 
line 59, in Client
module = utils.import_versioned_module(int(version), 'client')
  File 
"/usr/local/lib/python2.7/dist-packages/glanceclient/common/utils.py", line 
281, in import_versioned_module
return importutils.import_module(module)
  File "/usr/local/lib/python2.7/dist-packages/oslo_utils/importutils.py", 
line 73, in import_module
__import__(import_str)
  File 
"/usr/local/lib/python2.7/dist-packages/glanceclient/v2/__init__.py", line 
15, in 
from glanceclient.v2.client import Client  # noqa
  File "/usr/local/lib/python2.7/dist-packages/glanceclient/v2/client.py", 
line 17, in 
from glanceclient.common import http
  File 
"/usr/local/lib/python2.7/dist-packages/glanceclient/common/http.py", line 
26, in 
ProtocolError = requests.packages.urllib3.exceptions.ProtocolError
AttributeError: 'module' object has no attribute 'packages'
Error fetching image list: 'module' object has no attribute 'packages'

-- 
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/de24017f-6717-45c7-b4e0-3821b4b2ede6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Access ansible list in python script.

2015-12-10 Thread anoop . kolari
Hi Mike,

Thank you for your response. 

I resolved this by following steps.

1. I quoted the arguments passed with the command like python 
/home/vagrant/setup/configs/update_installed_app.py "*['django-allauth', 
'test']*"
2. In python script I can access it as a string. Then using python 'ast' 
module i'm converted it into python list.

On Thursday, December 10, 2015 at 12:00:49 PM UTC+5:30, 
anoop@tarams.com wrote:
>
> Hi,
>
> I'm calling a python script by passing an ansible list as an argument.
>
> command: "python /home/vagrant/setup/configs/update_installed_app.py 
> ['django-allauth', 'test']"
>
>
> But when i print this list in my python script its printing with misplaced 
> quotes, so i couldnt process it with python.
>
> ['[django-allauth,', 'test]']
>
>
>
> "rc": 0, 
> "start": "2015-12-10 06:22:12.327672", 
> "stderr": "", 
> "stdout": "['[django-allauth,', 'test]']", 
> "stdout_lines": [
> "['[django-allauth,', 'test]']"
>
> Could someone please help me out here.
>

-- 
 =
DISCLAIMER: The information in this message is confidential and may be 
legally privileged. It is intended solely for the addressee. Access to this 
message by anyone else is unauthorized. If you are not the intended 
recipient, any disclosure, copying, or distribution of the message, or any 
action or omission taken by you in reliance on it, is prohibited and may be 
unlawful. Please immediately contact the sender if you have received this 
message in error. Further, this e-mail may contain viruses and all 
reasonable precaution to minimize the risk arising there from is taken by 
Tarams. Tarams is not liable for any damage sustained by you as a result of 
any virus in this e-mail. All applicable virus checks should be carried out 
by you before opening this e-mail or any attachment thereto.
Thank you - Tarams Software Technologies Pvt.Ltd.
=

-- 
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/97cf7c88-d751-4e75-9e1e-b03cc33cafcb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] variables messed up when using including tasks

2015-12-10 Thread Igor Cicimov
Strange, because I'm sure every time I call a tasks file from another role I 
have to explicitly include that role's defaults|vars file via vars_files to be 
able to use its variables. So you are saying you are seeing this happen without 
this linking. Do you mind showing us the whole main playbook?

-- 
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/daa01dcf-1ba9-4e56-879e-1a5626dbde30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] variables messed up when using including tasks

2015-12-10 Thread silverdr

> On 2015-12-10, at 23:13, Igor Cicimov  wrote:
> 
> Strange, because I'm sure every time I call a tasks file from another role I 
> have to explicitly include that role's defaults|vars file via vars_files to 
> be able to use its variables.

Actually I stay within one role. The problem is that when I include other tasks 
from the same role, the role's defaults change into values from another role, 
which defaults have variables named the same as in the current one.

-- 
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/FE7F7831-48A7-47D2-A3D7-AAC41886ADE3%40srebrnysen.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Raw module and interactive commands

2015-12-10 Thread theyuseus
Is there a tutorial anywhere about how to get started using the expect 
module?  I've installed pexpect but when I try to use it in a playbook it 
fails with this message:

ERROR: expect is not a legal parameter in an Ansible task or handler

Based on what I've found (I could only find 2-3 examples, there doesn't 
seem to be any documentation other than 
https://docs.ansible.com/ansible/expect_module.html, which doesn't 
adequately explain how to use it), the playbook should look something like 
this.

  tasks:
  - expect:
command: save primary
responses:
  Do you want to save configuration to primary.cfg and overwrite it\? 
\(y/N\): "Y"

Am I missing something?  This page says that the extra's modules is shipped 
with ansible, is that still accurate? 
 https://docs.ansible.com/ansible/modules_extra.html

James

On Tuesday, December 1, 2015 at 5:53:52 PM UTC-7, Brian Coca wrote:
>
> No, its completely batch, you can try the expect module for interactive 
> prompts.
>

-- 
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/525f1c99-cddc-48f5-a2b5-7f42af4ea4c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Raw module and interactive commands

2015-12-10 Thread theyuseus
I've uninstalled and reinstalled version 1.9.4 and it isn't with it.  I 
downloaded it from github and added "library = 
/path/to/ansible/modules:/path/to/extras" to the ansible.cfg file, had to 
fix my command to the following text

  - expect:
  command: save primary
  responses:
Do you want to save configuration to primary.cfg and overwrite it\? 
\(y/N\): "Y"
 
but I still get an error.  It looks like ansible is still trying to copy a 
file to the switch.  The switches don't allow files to be copied to them. 
 I'm guessing I can't use the expect module after all.

fatal: [sw_s1-6] => Authentication or permission failure.  In some cases, 
you may have been able to authenticate and did not have permissions on the 
remote directory. Consider changing the remote temp path in ansible.cfg to 
a path rooted in "/tmp". Failed command was: mkdir -p 
$HOME/.ansible/tmp/ansible-tmp-1449790332.18-49609163795878 && chmod a+rx 
$HOME/.ansible/tmp/ansible-tmp-1449790332.18-49609163795878 && echo 
$HOME/.ansible/tmp/ansible-tmp-1449790332.18-49609163795878, exited with 
result -1: %% Unrecognized command:  "/bin/sh -c 'mkdir -p 
$HOME/.ansible/tmp/ansible-tmp-1449790332.18-49609163795878 && chmod a+rx 
$HOME/.ansible/tmp/ansible-tmp-1449790332.18-49609163795878 && echo 
$HOME/.ansible/tmp/ansible-tmp-1449790332.18-49609163795878'"



-- 
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/3f8a7ed1-8c9d-40d4-a910-17eba8b54f61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Raw module and interactive commands

2015-12-10 Thread Matt Martz
The Ansible expect module will be shipped with 2.0. The current released
version is 1.9.4.

On Thursday, December 10, 2015,  wrote:

> On investigation it appears that I do not have the expect module.  I
> thought I installed ansible with pip install ansible, but I earlier tried
> homebrew but it didn't work.  Maybe something got messed up.  I guess I'll
> try to figure out how to fix my installation.
>
> --
> 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/67fee4a6-d49a-46d7-b250-6ebb787455b4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v8ER7X1JwL1Zb2_AaV0%3DWFQcq7rCtF7%2BiFRga3_4PejyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] variables messed up when using including tasks

2015-12-10 Thread silverdr

> On 2015-12-10, at 23:13, Igor Cicimov  wrote:
> 
> Strange, because I'm sure every time I call a tasks file from another role I 
> have to explicitly include that role's defaults|vars file via vars_files to 
> be able to use its variables. So you are saying you are seeing this happen 
> without this linking. Do you mind showing us the whole main playbook?

FYI: I - kind of - worked the problem around by moving the variables from 
"defaults" to "vars" but this causes other inconveniences when I actually want 
to overwrite them.

Example playbook ({{destination}} value changes after the first -include:

---
- hosts: api
  remote_user: teamcity
  sudo: yes
  gather_facts: no

  pre_tasks:

  roles:
- { role: "api" }

  tasks:

  post_tasks:


roles/api/tasks/main.yml:

# Prerequisities / system dependencies
- name: install dependencies
  apt: name={{item}} state=present
  with_items:
- python-httplib2
- supervisor

# Configuring PHP
- include: php.yml

# Getting and preparing / installing the code

- name: if exists - remove previously cloned repository
  file:
path: "{{destination}}"
state: absent
  when: clear_destination is defined
  tags:
- api

- name: clone repository
  git:
repo: "{{repository}}"
dest: "{{destination}}"
accept_hostkey: yes
  tags:
- api_debug

- name: copy default env file # TODO - process the env file out of env.dist
  template: src=env.ini.j2 dest={{destination}}/api/.env
  tags: env_file

- name: install using composer
  composer: command=install working_dir={{destination}}/api/ no_dev=no

- name: change ownership of the cloned repository
  file: dest={{destination}} owner={{owneruser}} group={{ownergroup}} 
state=directory recurse=yes

# Configuring database
- name: stop supervisor service
  supervisorctl: name='api:' state=stopped
  tags: api_database

- include: database.yml

- name: run migrations
  sudo_user: "{{owneruser}}"
  command: php artisan migrate chdir={{destination}}/api/

- name: seed the database
  sudo_user: "{{owneruser}}"
  command: php artisan db:seed chdir={{destination}}/api/

# Cleaning elastic index
- name: cleanup elastic index
  uri: url=http://{{elastic_hostname}}:{{elastic_port}}/{{listing_index}} 
method=DELETE status_code=200,404
  when: clean_elastic_index is defined
  tags:
- clean_elastic_index

# Run artisan queue daemon with supervisord
- name: copy queue daemon configuration
  template: src=supervisord.conf.j2 dest=/etc/supervisor/conf.d/api.conf
  tags: queue

- name: add new service
  supervisorctl: name='api:' state=started
  tags: queue

- name: start added service
  supervisorctl: name='api:' state=restarted
  tags: queue

# Configuring network
- include: network.yml

# Configuring httpd
- include: httpd.yml

# Generating apidocs
- include: apidocs.yml

**
roles/api/tasks/php.yml:

---
- name: install php5 extensions
  apt: name={{item}} state=present
  with_items:
- php5-mcrypt
- php5-json
- php5-pgsql
- php5-xsl
- php5-gmp

- name: enable php5-mcrypt extension
  command: php5enmod mcrypt
  args:
creates: /etc/php5/apache2/conf.d/20-mcrypt.ini

# when installing xdebug make sure that xdebug.max_nesting_level = 250
# is also set in the php's php.ini configuration file
- name: install php5 xdebug extension
  apt: name={{item}} state=present
- php5-xdebug
  when: xdebug is defined

- name: set php5 xdebug configuration param
  lineinfile:
dest: "{{php_ini_path}}"
backup: true
backrefs: true
state: present
regexp: "{{item.regexp}}"
line: "{{item.line}}"
  with_items:
- {regexp: '^xdebug.max_nesting_level', line: 'xdebug.max_nesting_level = 
250'}
  notify: restart httpd
  when: xdebug is defined

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


Re: [ansible-project] Raw module and interactive commands

2015-12-10 Thread theyuseus
On investigation it appears that I do not have the expect module.  I 
thought I installed ansible with pip install ansible, but I earlier tried 
homebrew but it didn't work.  Maybe something got messed up.  I guess I'll 
try to figure out how to fix my installation.

-- 
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/67fee4a6-d49a-46d7-b250-6ebb787455b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] variables messed up when using including tasks

2015-12-10 Thread patrycjusz . logiewa

> On 2015-12-09, at 22:35, Igor Cicimov  wrote:
> 
> Do you by any chance have some of those vars also defined in the 
> group_vars/all file? In that case they overide the ones in the roles default 
> file causing unexpected results for people unaware of this fact.

No, that would actually explain - Definitely there is no "destination" for 
example in any group_vars/, host_vars/, etc. In group_vars/all, there is only a 
vaulted set of "sensitive" variables like passwords, keys, etc.

-- 
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/59523AC1-B688-4027-9B11-BEE31F28EBE2%40srebrnysen.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] core.cloud.openstack Error Fetching Image List

2015-12-10 Thread Hugh Ma
Running into an issue on 2.0 rc2 and latest dev version (2.1)

TASK [common : launch a compute instance] 
**
task path: 
/home/cluser/automata_ansible/automata_ansible_openstack/openstack/roles/common/tasks/main.yml:2
ESTABLISH LOCAL CONNECTION FOR USER: root
localhost EXEC ( umask 22 && mkdir -p "$( echo 
$HOME/.ansible/tmp/ansible-tmp-1449770098.45-120356728371449 )" && echo "$( 
echo $HOME/.ansible/tmp/ansible-tmp-1449770098.45-120356728371449 )" )
localhost PUT /tmp/tmpCI8UeX TO 
/root/.ansible/tmp/ansible-tmp-1449770098.45-120356728371449/os_server
localhost EXEC LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 
/usr/bin/python 
/root/.ansible/tmp/ansible-tmp-1449770098.45-120356728371449/os_server; rm 
-rf "/root/.ansible/tmp/ansible-tmp-1449770098.45-120356728371449/" > 
/dev/null 2>&1
fatal: [localhost]: FAILED! => {"changed": false, "extra_data": null, 
"failed": true, "invocation": {"module_args": {"auth": {"auth_url": 
"http://172.16.0.6:5000/v2.0/;, "password": "admin", "project_name": 
"admin", "username": "admin"}, "auto_ip": true, "availability_zone": 
"nova", "flavor": 3, "image": "ubuntu_trusty", "key_name": "test", "name": 
"vm2", "nics": [{"net-id": "f4d99c4b-0931-4a3a-b884-2129816b1db1"}], 
"security_groups": "default", "state": "present", "timeout": 200}, 
"module_name": "os_server"}, "msg": "Error fetching image list: 'module' 
object has no attribute 'packages'"}

I put in various checks along os_server.py but it seems the issue is coming 
from cloud.get_image_id() which eventually leads to def list_images() here
https://github.com/openstack-infra/shade/blob/master/shade/openstackcloud.py#L1163-L1165

The old nova_server module works fine, so not sure what the issue is. 

-- 
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/2df7f051-b2da-4f05-9b41-d0695922a9c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Raw module and interactive commands

2015-12-10 Thread Brian Coca
It still won't work with the switch as it is a module, which NEEDS to
be copied to the target and then executed via python, raw is the only
'module' that does not do this, it is really a special case inside
Ansible and not a real module.

In 2.0 we are adding the scaffolding to deal with switches, we will
also be adding modules to manage them that take into account the
quirks they have.

-- 
Brian Coca

-- 
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/CAJ5XC8n8_AnVMCPekX1DE2f0z8kAbg7-CPbw4-snr8LE%2B_ihKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Access ansible list in python script.

2015-12-10 Thread Mike Biancaniello
Instead of passing a python list, can you pass a json string? Then, inside 
the py script, just use json.loads().

-- 
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/0621f6f4-b4e7-426f-a57c-89d2f9fea24e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] variables messed up when using including tasks

2015-12-10 Thread Igor Cicimov
Just out of curiosity, what happens when you supply destination via 
extra_vars and leave everything as it was in defaults file?


On Friday, December 11, 2015 at 11:09:30 AM UTC+11, silverdr wrote:
>
>
> > On 2015-12-10, at 23:13, Igor Cicimov  > wrote: 
> > 
> > Strange, because I'm sure every time I call a tasks file from another 
> role I have to explicitly include that role's defaults|vars file via 
> vars_files to be able to use its variables. So you are saying you are 
> seeing this happen without this linking. Do you mind showing us the whole 
> main playbook? 
>
> FYI: I - kind of - worked the problem around by moving the variables from 
> "defaults" to "vars" but this causes other inconveniences when I actually 
> want to overwrite them. 
>
> Example playbook ({{destination}} value changes after the first -include: 
>
> --- 
> - hosts: api 
>   remote_user: teamcity 
>   sudo: yes 
>   gather_facts: no 
>
>   pre_tasks: 
>
>   roles: 
> - { role: "api" } 
>
>   tasks: 
>
>   post_tasks: 
>
>  
> roles/api/tasks/main.yml: 
>
> # Prerequisities / system dependencies 
> - name: install dependencies 
>   apt: name={{item}} state=present 
>   with_items: 
> - python-httplib2 
> - supervisor 
>
> # Configuring PHP 
> - include: php.yml 
>
> # Getting and preparing / installing the code 
>
> - name: if exists - remove previously cloned repository 
>   file: 
> path: "{{destination}}" 
> state: absent 
>   when: clear_destination is defined 
>   tags: 
> - api 
>
> - name: clone repository 
>   git: 
> repo: "{{repository}}" 
> dest: "{{destination}}" 
> accept_hostkey: yes 
>   tags: 
> - api_debug 
>
> - name: copy default env file # TODO - process the env file out of 
> env.dist 
>   template: src=env.ini.j2 dest={{destination}}/api/.env 
>   tags: env_file 
>
> - name: install using composer 
>   composer: command=install working_dir={{destination}}/api/ no_dev=no 
>
> - name: change ownership of the cloned repository 
>   file: dest={{destination}} owner={{owneruser}} group={{ownergroup}} 
> state=directory recurse=yes 
>
> # Configuring database 
> - name: stop supervisor service 
>   supervisorctl: name='api:' state=stopped 
>   tags: api_database 
>
> - include: database.yml 
>
> - name: run migrations 
>   sudo_user: "{{owneruser}}" 
>   command: php artisan migrate chdir={{destination}}/api/ 
>
> - name: seed the database 
>   sudo_user: "{{owneruser}}" 
>   command: php artisan db:seed chdir={{destination}}/api/ 
>
> # Cleaning elastic index 
> - name: cleanup elastic index 
>   uri: url=http://{{elastic_hostname}}:{{elastic_port}}/{{listing_index}} 
> method=DELETE status_code=200,404 
>   when: clean_elastic_index is defined 
>   tags: 
> - clean_elastic_index 
>
> # Run artisan queue daemon with supervisord 
> - name: copy queue daemon configuration 
>   template: src=supervisord.conf.j2 dest=/etc/supervisor/conf.d/api.conf 
>   tags: queue 
>
> - name: add new service 
>   supervisorctl: name='api:' state=started 
>   tags: queue 
>
> - name: start added service 
>   supervisorctl: name='api:' state=restarted 
>   tags: queue 
>
> # Configuring network 
> - include: network.yml 
>
> # Configuring httpd 
> - include: httpd.yml 
>
> # Generating apidocs 
> - include: apidocs.yml 
>
> ** 
> roles/api/tasks/php.yml: 
>
> --- 
> - name: install php5 extensions 
>   apt: name={{item}} state=present 
>   with_items: 
> - php5-mcrypt 
> - php5-json 
> - php5-pgsql 
> - php5-xsl 
> - php5-gmp 
>
> - name: enable php5-mcrypt extension 
>   command: php5enmod mcrypt 
>   args: 
> creates: /etc/php5/apache2/conf.d/20-mcrypt.ini 
>
> # when installing xdebug make sure that xdebug.max_nesting_level = 250 
> # is also set in the php's php.ini configuration file 
> - name: install php5 xdebug extension 
>   apt: name={{item}} state=present 
> - php5-xdebug 
>   when: xdebug is defined 
>
> - name: set php5 xdebug configuration param 
>   lineinfile: 
> dest: "{{php_ini_path}}" 
> backup: true 
> backrefs: true 
> state: present 
> regexp: "{{item.regexp}}" 
> line: "{{item.line}}" 
>   with_items: 
> - {regexp: '^xdebug.max_nesting_level', line: 
> 'xdebug.max_nesting_level = 250'} 
>   notify: restart httpd 
>   when: xdebug is defined 
>
>

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


Re: [ansible-project] variables messed up when using including tasks

2015-12-10 Thread Igor Cicimov
Also if you can put

- debug: var=destination

before and after every include call would be very helpful to see where the 
var actually gets changed.

Just realized that my previous message might not be clear enough, what I 
mean is add:

--extra-vars '{"destination":"some_value_here"}'

to the ansible-playbook command and move back all your vars in their 
respective defaults files as they were before.

On Friday, December 11, 2015 at 3:37:37 PM UTC+11, Igor Cicimov wrote:
>
> Just out of curiosity, what happens when you supply destination via 
> extra_vars and leave everything as it was in defaults file?
>
>
> On Friday, December 11, 2015 at 11:09:30 AM UTC+11, silverdr wrote:
>>
>>
>> > On 2015-12-10, at 23:13, Igor Cicimov  
>> wrote: 
>> > 
>> > Strange, because I'm sure every time I call a tasks file from another 
>> role I have to explicitly include that role's defaults|vars file via 
>> vars_files to be able to use its variables. So you are saying you are 
>> seeing this happen without this linking. Do you mind showing us the whole 
>> main playbook? 
>>
>> FYI: I - kind of - worked the problem around by moving the variables from 
>> "defaults" to "vars" but this causes other inconveniences when I actually 
>> want to overwrite them. 
>>
>> Example playbook ({{destination}} value changes after the first -include: 
>>
>> --- 
>> - hosts: api 
>>   remote_user: teamcity 
>>   sudo: yes 
>>   gather_facts: no 
>>
>>   pre_tasks: 
>>
>>   roles: 
>> - { role: "api" } 
>>
>>   tasks: 
>>
>>   post_tasks: 
>>
>>  
>> roles/api/tasks/main.yml: 
>>
>> # Prerequisities / system dependencies 
>> - name: install dependencies 
>>   apt: name={{item}} state=present 
>>   with_items: 
>> - python-httplib2 
>> - supervisor 
>>
>> # Configuring PHP 
>> - include: php.yml 
>>
>> # Getting and preparing / installing the code 
>>
>> - name: if exists - remove previously cloned repository 
>>   file: 
>> path: "{{destination}}" 
>> state: absent 
>>   when: clear_destination is defined 
>>   tags: 
>> - api 
>>
>> - name: clone repository 
>>   git: 
>> repo: "{{repository}}" 
>> dest: "{{destination}}" 
>> accept_hostkey: yes 
>>   tags: 
>> - api_debug 
>>
>> - name: copy default env file # TODO - process the env file out of 
>> env.dist 
>>   template: src=env.ini.j2 dest={{destination}}/api/.env 
>>   tags: env_file 
>>
>> - name: install using composer 
>>   composer: command=install working_dir={{destination}}/api/ no_dev=no 
>>
>> - name: change ownership of the cloned repository 
>>   file: dest={{destination}} owner={{owneruser}} group={{ownergroup}} 
>> state=directory recurse=yes 
>>
>> # Configuring database 
>> - name: stop supervisor service 
>>   supervisorctl: name='api:' state=stopped 
>>   tags: api_database 
>>
>> - include: database.yml 
>>
>> - name: run migrations 
>>   sudo_user: "{{owneruser}}" 
>>   command: php artisan migrate chdir={{destination}}/api/ 
>>
>> - name: seed the database 
>>   sudo_user: "{{owneruser}}" 
>>   command: php artisan db:seed chdir={{destination}}/api/ 
>>
>> # Cleaning elastic index 
>> - name: cleanup elastic index 
>>   uri: url=http://{{elastic_hostname}}:{{elastic_port}}/{{listing_index}} 
>> method=DELETE status_code=200,404 
>>   when: clean_elastic_index is defined 
>>   tags: 
>> - clean_elastic_index 
>>
>> # Run artisan queue daemon with supervisord 
>> - name: copy queue daemon configuration 
>>   template: src=supervisord.conf.j2 dest=/etc/supervisor/conf.d/api.conf 
>>   tags: queue 
>>
>> - name: add new service 
>>   supervisorctl: name='api:' state=started 
>>   tags: queue 
>>
>> - name: start added service 
>>   supervisorctl: name='api:' state=restarted 
>>   tags: queue 
>>
>> # Configuring network 
>> - include: network.yml 
>>
>> # Configuring httpd 
>> - include: httpd.yml 
>>
>> # Generating apidocs 
>> - include: apidocs.yml 
>>
>> ** 
>> roles/api/tasks/php.yml: 
>>
>> --- 
>> - name: install php5 extensions 
>>   apt: name={{item}} state=present 
>>   with_items: 
>> - php5-mcrypt 
>> - php5-json 
>> - php5-pgsql 
>> - php5-xsl 
>> - php5-gmp 
>>
>> - name: enable php5-mcrypt extension 
>>   command: php5enmod mcrypt 
>>   args: 
>> creates: /etc/php5/apache2/conf.d/20-mcrypt.ini 
>>
>> # when installing xdebug make sure that xdebug.max_nesting_level = 250 
>> # is also set in the php's php.ini configuration file 
>> - name: install php5 xdebug extension 
>>   apt: name={{item}} state=present 
>> - php5-xdebug 
>>   when: xdebug is defined 
>>
>> - name: set php5 xdebug configuration param 
>>   lineinfile: 
>> dest: "{{php_ini_path}}" 
>> backup: true 
>> backrefs: true 
>> state: present 
>> regexp: "{{item.regexp}}" 
>> line: "{{item.line}}" 
>>   with_items: 
>> - {regexp: '^xdebug.max_nesting_level', line: 
>> 

Re: [ansible-project] Re: yum_repository module (has anyone thought of doing it...)

2015-12-10 Thread Cha Donghwi
Is this still not implemented to ansible core? 



2014년 2월 13일 목요일 오후 10시 22분 54초 UTC+9, Johan Söderberg 님의 말:
>
> Hi,
>
> The yum_repository module sounds exactly what I've been looking for. 
> Unfortunately the url doesn't work and I'm unable to find it anywhere. Is 
> it still available somewhere?
>
> Thanks in advance,
>
> /Johan
>
> Den söndagen den 16:e juni 2013 kl. 19:56:59 UTC+2 skrev Matt S:
>>
>> I just happen to have created a yum_repository plugin [1] for Ansible 
>> based on my own needs. In the environment I work with we use a continuous 
>> integration system to generate new rpm repositories throughout the day, so 
>> it's helpful to deal with them this way. It also greatly simplifies the 
>> code for making changes to existing repositories.
>>
>> For instance, if I wanted to disable my Centos updates repository, I 
>> could use something like:
>>
>> ansible all -m yum_repository -a "id=updates state=disabled"
>>
>> I haven't submitted a pull request yet, but will if other people find it 
>> useful.
>>
>> [1] 
>> https://github.com/mspaulding06/ansible/blob/yum_repository_plugin/library/packaging/yum_repository
>>
>> On Tuesday, June 4, 2013 5:43:09 PM UTC-7, Chris Bennett wrote:
>>>
>>> > Haven't used it myself, but have you looked at the 
>>> > ini_file<
>>> http://ansible.cc/docs/modules.html?highlight=replace#ini-file>module? 
>>>
>>> Hmm, no I didn't even think to consider it.  But reading the doco, it 
>>> may do exactly what I want.  Thanks! :) 
>>>
>>> Chris 
>>>
>>

-- 
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/478f2417-9233-4072-9de6-0c9b5d3545c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: help on loop over list of dicts

2015-12-10 Thread Mike Biancaniello
Not sure what you're doing wrong. Maybe it's the way you define 
dev_interfaces (yeah, it makes no sense why it would work in debug, but not 
in with_items, but sometimes that happens).

This worked for me:
---
- name: stuff
  connection: local
  gather_facts: no
  hosts: localhost

  vars:
dev_interfaces:
  - subnet: 10.0.0.0/31
peer_addr: 10.0.0.1
name: Ethernet0
mask: 255.255.255.254
prefixlen: 31
addr: 10.0.0.0

  tasks:
- debug: msg="{{ dev_interfaces[0].name }}"

- name: debug message interface name
  debug: msg="{{item.name}}"
  with_items: "{{ dev_interfaces }}"


output:
PLAY [stuff] 
** 

TASK: [debug msg="{{ dev_interfaces[0].name }}"] 
** 
ok: [localhost] => {
"msg": "Ethernet0"
}

TASK: [debug message interface name] 
** 
ok: [localhost] => (item={'subnet': '10.0.0.0/31', 'peer_addr': '10.0.0.1', 
'name': 'Ethernet0', 'prefixlen': 31, 'mask': '255.255.255.254', 'addr': 
'10.0.0.0'}) => {
"item": {
"addr": "10.0.0.0", 
"mask": "255.255.255.254", 
"name": "Ethernet0", 
"peer_addr": "10.0.0.1", 
"prefixlen": 31, 
"subnet": "10.0.0.0/31"
}, 
"msg": "Ethernet0"
}

PLAY RECAP 
 
localhost  : ok=2changed=0unreachable=0failed=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 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/858a36b5-6dc1-43ee-a6b8-43f8f974e0b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.