[ansible-project] Template not updated with correct values from group_vars file

2014-10-16 Thread Subramanian Olagappan
Hi All,

I have a playbook which copy application.proprties with db.username and
db.password.

I have qa env and qa1 is a cluster with app and ui server. The hosts file (
hosts.qa) is as per the best practises mentioned in docs.ansible.com site.
I have similar hosts file for dev ( hosts.dev )

I have group_vars file for qa and qa1 with db.usernamd and db.password
values. Same for dev and dev1 groups

>ansible-playbook  -i inventory/hosts.qa  --limit qa1 site.yml

When I run the playbook, with --limit qa1, the application properties
template is not updated with qa1 group_vars file values, instead it has
"qa" as db_username and db_password. The same works fine for --limit dev1
Has anyone faced this problem ?

Thanks,
Olga

ansible 1.7.2
Centos 6.5


*site.yml*

---
- hosts: appservers
  remote_user: '{{ remote_user }}'
  sudo: True
  tasks:
  - name: configure application properties
template: src=templates/application.properties.j2
dest=/tmp/application.properties
  owner=root group=root mode=744



*templates/application.properties*

# {{ ansible_managed }}
#Database Configuration
db.username={{ db_username }}
db.password={{ db_password }}



*inventory/hosts.dev*

[dev1-appserver]
xyz.com

[dev1-uiserver]
abc.com

[appservers:children]
dev1-appserver

[dev1:children]
dev1-appserver
dev1-uiserver
[dev:children]
dev1-appserver
dev1-uiserver

[uiservers:children]
dev1-uiserver



*inventory/hosts.qa *

[qa1-uiserver]
123.com

[qa1-appserver]
567.com

[qa:children]
qa1-appserver
qa1-uiserver

[appservers:children]
qa1-appserver

[qa1:children]
qa1-appserver
qa1-uiserver

[uiservers:children]
qa1-uiserver


*group_vars/qa*

# variables related to the qa environment
db_username: qa
db_password: qa

*group_vars/qa1*

# variables related to the qa environment
db_username: qa1
db_password: qa1
*group_vars/dev*

# variables related to the dev environment
db_username: dev
db_password: dev

*group_vars/dev1*

# variables related to the dev1 environment
db_username: dev1
db_password: dev1

-- 
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/CAKQjojSfDDBN-F4kj7__qOYZwv8LpQM7PVBD6ytxbEjAkNLwKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] syntax error in vars bubstution [ shell module ]

2014-10-15 Thread Subramanian Olagappan
Hi Michael,

---
- hosts: service
  vars:
app_service_port: 8080
tomcat_home: /opt/apache-tomcat-8.0.9
  remote_user: deploy
  tasks:
  - name: stop tomcat
shell: "{{ tomcat_home }}"/bin/shutdown.sh
  - name: start tomcat
shell: "{{ tomcat_home }}"/bin/startup.sh

olga@olga-vbox:~$ ansible-playbook test.yml
ERROR: Syntax Error while loading YAML script, test.yml
Note: The error may actually appear before this position: line 7, column 31
  - name: stop tomcat
shell: "{{ tomcat_home }}"/bin/shutdown.sh
^
We could be wrong, but this one looks like it might be an issue with
missing quotes.  Always quote template expression brackets when they
start a value. For instance:
with_items:
  - {{ foo }}
Should be written as:
with_items:
  - "{{ foo }}"

Thanks,
Olga

On Tue, Oct 14, 2014 at 2:20 AM, Michael DeHaan  wrote:

> "Quoting also did not work. I added "sh" before the {{ and it worked."
>
> Please show me what you tried and what the output was?
>
> Thanks!
>
>
> On Fri, Oct 10, 2014 at 5:24 AM, olga  wrote:
>
>> Hi Michael,
>>
>> Quoting also did not work. I added "sh" before the {{ and it worked.
>>
>>   tasks:
>>   - name: stop tomcat
>> shell: sh {{ tomcat_home }}/bin/shutdown.sh
>>   - name: start tomcat
>> shell: sh {{ tomcat_home }}/bin/startup.sh
>>
>> Thanks for the link.
>>
>> Regards,
>> Olga
>>
>> On Thursday, October 9, 2014 1:33:15 AM UTC+5:30, Michael Peters wrote:
>>>
>>> Try quoting the templated part. The {{ }} syntax markers mess up the
>>> yaml parsing - http://docs.ansible.com/YAMLSyntax.html#gotchas
>>>
>>> On Wed, Oct 8, 2014 at 3:41 PM, olga  wrote:
>>> > Hi,
>>> >
>>> > ---
>>> > - hosts: service
>>> >   vars:
>>> > app_service_port: 8080
>>> > tomcat_home: /opt/apache-tomcat-8.0.9
>>> >   remote_user: deploy
>>> >   tasks:
>>> >   - name: stop tomcat
>>> > shell: {{ tomcat_home }}/bin/shutdown.sh
>>> >   - name: start tomcat
>>> > shell: {{ tomcat_home }}/bin/startup.sh
>>> >
>>> > When i run this play, i get
>>> >
>>> > ERROR: Syntax Error while loading YAML script, test.yml
>>> > Note: The error may actually appear before this position: line 8,
>>> column 28
>>> >
>>> >   tasks:
>>> >   - shell: {{ tomcat_home}}/bin/shutdown.sh
>>> >
>>> > is variable substitution not allowed in shell module.
>>> >
>>> > These are custom installed tomcat dir, so i have to use shell command
>>> to
>>> > start and stop the tomcat. Also, has anyone verified if the java
>>> process got
>>> > killed. I have seen some times that after shutdown, the java process
>>> still
>>> > run. OR is there any easy method in ansible to do this.
>>> >
>>> > Thanks,
>>> > olaga
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Ansible Project" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> an
>>> > email to ansible-proje...@googlegroups.com.
>>> > To post to this group, send email to ansible...@googlegroups.com.
>>> > To view this discussion on the web visit
>>> > https://groups.google.com/d/msgid/ansible-project/
>>> 72a6af6d-d972-4747-bb6f-21eb0c63350b%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/7cc0daa5-8d6e-46d8-ba2b-1f35ff8acdc8%40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/n5jvt2qOI9I/unsubscribe.
> To unsubscribe from this group and all its topics, 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%2BnsWgyu79FsM7xmxVjRThbhtzJiQaBuCJhBMni0m9JAwxjOyg%40mail.gmail.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 ansib

Re: [ansible-project] ansible-playbook and jenkins

2014-10-12 Thread Subramanian Olagappan
Thanks Jeroen. This worked.


On Mon, Oct 13, 2014 at 11:07 AM, Jeroen Hoekx 
wrote:

> On 12 October 2014 07:21, olga  wrote:
>
> > I'm running ansible-playbook command in Jenkins, when ansible-playbook
> > command is executed, the output is buffered and I see the
> ansible-playbook
> > command output only after it finished.
> >
> > Is there any option to see the output as we see in command prompt
>
> Yes, there is. Run them as
> /usr/bin/python2 -u /usr/bin/ansible-playbook
>
> That works for us.
>
> Greetings,
>
> Jeroen
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/DeTzrq4W1G8/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAAAQQmB-SaXN4_oNvtjeKEMSbaMZBAbbo0jOkhs-YPOm9P9vBw%40mail.gmail.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/CAKQjojSzGrVR3PZy6KiLjiHeq-%3DEmOZQinqf1YvGdgGmeKJ44Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: chown failed in file module

2014-10-02 Thread Subramanian Olagappan
Hi Mark,

I'm using ubuntu 12.04 LTS and I can ssh as "root" in localhost and enabled
PermitRootLogin in ssh_config file

olga@ubuntu:~/ansible/try/02$ ansible localhost -u root -k -m file -a
'path=/tmp/test11 state=directory mode=0700 owner=root' -vvv
SSH password:
 REMOTE_MODULE file path=/tmp/test11 state=directory mode=0700
owner=root
 EXEC ['/bin/sh', '-c', 'mkdir -p
$HOME/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070 && echo
$HOME/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070']
 PUT /tmp/tmptdYxcv TO
/home/olga/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070/file
 EXEC ['/bin/sh', '-c', u'LANG=C LC_CTYPE=C /usr/bin/python
/home/olga/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070/file; rm
-rf /home/olga/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070/
>/dev/null 2>&1']
localhost | FAILED >> {
"failed": true,
"gid": 1001,
"group": "olga",
"mode": "0775",
"msg": "chown failed",
"owner": "olga",
"path": "/tmp/test11",
"size": 4096,
"state": "directory",
"uid": 1001
}

root@ubuntu:/tmp# ls -ld /tmp
drwxrwxrwt 12 root root 4096 Oct  2 16:23 /tmp
root@ubuntu:/tmp#

I tried with a wrong "ssh" password for root ( -k option ) , it created the
dir in /tmp and the error was same. I was not expecting this and the
command should not have created the dir.

Regards,
Olga

On Thu, Oct 2, 2014 at 12:46 PM, Mark  wrote:

> So doing this on a bare install of ubuntu 14.04 LTS makes it work.
>
> mark@ans:~$ ansible localhost -u root -k -m file -a 'path=/tmp/test6
> state=directory mode=0700 owner=root'
> SSH password:
> sudo password [defaults to SSH password]:
> localhost | success >> {
> "changed": false,
> "gid": 0,
> "group": "root",
> "mode": "0700",
> "owner": "root",
> "path": "/tmp/test6",
> "size": 4096,
> "state": "directory",
> "uid": 0
> }
>
>
>
>
> Doing this on my CentOS will fail in the same way you see it fail.
> [markh@sen-ansible-int ~]$ ansible localhost -u root -k -m file -a
> 'path=/tmp/test6 state=direct
> SSH password:
> sudo password [defaults to SSH password]:
> localhost | FAILED >> {
> "failed": true,
> "gid": 60007,
> "group": "senuser",
> "mode": "0755",
> "msg": "chown failed",
> "owner": "markh",
> "path": "//tmp/test6",
> "size": 4096,
> "state": "directory",
> "uid": 60018
>
>
>
> Ofcourse there are a lot of settings that diff between these 2 systems,
> but one is not, and those are the filerights on /tmp which are exactly the
> same...
> does running it in - gives you any more details?
>
>
>
> Op woensdag 1 oktober 2014 14:21:12 UTC+2 schreef Michael DeHaan:
>>
>> "You are SSHing as root, is permitremoterootlogin enabled?"
>>
>> If that were the case the error would appear further up.
>>
>> Also sudo isn't being used because of the "-u root"
>>
>> Is there anything unusual about /tmp we might need to know?
>>
>>
>>
>> On Wed, Oct 1, 2014 at 7:40 AM, Mark  wrote:
>>
>>>
>>> You are SSHing as root, is permitremoterootlogin enabled?
>>> Op woensdag 1 oktober 2014 13:36:16 UTC+2 schreef olga:

 Hi,

 I am using ansible 1.7.2 and see the chown is not working

 olga@ubuntu:~/ansible/try/02$ ansible localhost -u root -k -m file -a
 'path=/tmp/test6 state=directory mode=0700 owner=root'
 SSH password:
 localhost | FAILED >> {
 "failed": true,
 "gid": 1001,
 "group": "olga",
 "mode": "0775",
 "msg": "chown failed",
 "owner": "olga",
 "path": "//tmp/test6",
 "size": 4096,
 "state": "directory",
 "uid": 1001
 }

 What is the right command option to create dir owned by the sudo user ?

 Thanks,
 olga

>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible-proje...@googlegroups.com.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/ansible-project/9c489288-8085-47b4-844a-
>>> 14712fb51ac2%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/tNgiPM1Tt0E/unsubscribe.
> To unsubscribe from this group and all its topics, 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
> 

Re: [ansible-project] How do i specify vars file per env during deploy

2014-09-26 Thread Subramanian Olagappan
Thanks Igor

Regards

On Fri, Sep 26, 2014 at 12:02 PM, Igor Homyakov  wrote:

> Hi Olga,
>
> There are two options:
>
> * Using vars_files
> http://docs.ansible.com/playbooks_variables.html#variable-file-separation
>
> - hosts: all
>   vars_files:
>  - "{{ deployment_env}}.yml"
>
> * You can keep environment specific variables separately
>
> http://docs.ansible.com/intro_inventory.html#splitting-out-host-and-group-specific-data
>
> inventory
> ├── production
> │   ├── group_vars
> │   │   ├── all
> │   │   │   ├── common.yml <- variables for all productions servers
> │   │   │   └── secret.yml <- secrets for production
> │   │   └── db
> │   │   ├── common.yml <- variables for static-ip group
> │   │   └── secret.yml <- secrets for static-ip group in
> production env
> │   └── hosts  <- inventory file production
> ├── staging
> │   ├── group_vars
> │   │   └── all
> │   │   └── common.yml
> │   └── hosts <- inventory file for staging
> └── development
> └── hosts
>
> Please have a look at awesome presentations
> https://speakerdeck.com/slok/ansible-all-the-things pages 120-127
> specifically
>
>
> -- Best, Igor
>
>
>
> On Thu, Sep 25, 2014 at 10:58 PM, olga  wrote:
> > Hi,
> >
> > I have a play book to deploy the DB scripts. I also have multiple env
> like
> > dev,qa & prod. The deployment has a template with few variables like
> > db_user_name and password. I have created the vars file for each env and
> > inventory hosts per env. How do I specify the vars file based on the env
> I'm
> > deploying. Do we have option to specify the vars file in command line
> > option.
> >
> > Sorry, if this is a silly question.
> >
> > Thanks,
> > olga
> >
> > --
> > 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/4075c459-f2f7-4424-96d8-c53cc66f2489%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/CAGuansoqG%2B2ew15YtjPGOsfC2-%3DkzcRkYX%2B_Ov%3DYNNeZJg3sBA%40mail.gmail.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/CAKQjojRmSfjNdrXyuvgxnfJugovEU3zQ1z10a-A_O0U05yN7ag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.