[ansible-project] Global name 'module" is not defined after upgrading to Ansible 2.0

2016-03-19 Thread Samnang Sen
Works fine w/ Ansible 1.9.4 I won't paste the whole file because it's not getting past the setup stage. With gather_facts turned off I can get past the setup phase but it obvioulsy fails once it gets to the pre_tasks block. Error: TASK [setup] *

[ansible-project] Passing environment variable set in group_vars to lookup pluging

2016-03-18 Thread Samnang Sen
I export ANSIBLE_CONSUL_URL in order for the Consul lookup pluging to search against a remote server. I'm not able to set this environment variable within my playbook. It still defaults to localhost. Is it not possible? # group_vars/all consul_url_env: ANSIBLE_CONSUL_URL: http://MY_REMOTE_I

[ansible-project] Include the correct var file depending on the hostname

2015-10-02 Thread Samnang Sen
I have three sets of servers. Depending on the hostname, I want the client to grab the correct file. I tested the playbook on a server with the word "batch" but it picks up both files (group_vars/perl and group_vars/perl). pre_tasks: - include_vars: group_vars/web when: "'web' in ansible_h

Re: [ansible-project] Re: Nagios module and not being able to write to nagios.cmd

2015-09-18 Thread Samnang Sen
Thought I included that in my original post but I didn't. Yes the user I am logging in as is in the "nagios" group. On Friday, September 18, 2015 at 12:48:05 PM UTC-4, Brian Coca wrote: > > So the user you login to the nagios server needs to be in the nagios > group to write to the file. > > >

[ansible-project] Re: Nagios module and not being able to write to nagios.cmd

2015-09-16 Thread Samnang Sen
In addition can someone clarify something. Shouldn't the "cmdfile" file be the .cmd file? I peeked at the Nagios module and there's a list of files but they all point to the nagios.cfg file. On Wednesday, September 16, 2015 at 4:59:04 PM UTC-4, Samnang Sen wrote: &g

[ansible-project] Nagios module and not being able to write to nagios.cmd

2015-09-16 Thread Samnang Sen
I keep getting the following error when I attempt to disable alerts for a particular host. Not sure what the heck is going on! failed: [127.0.0.1 -> nagios.xyz.net] => {"cmdfile": "/var/spool/nagios/cmd/nagios.cmd", "failed": true} msg: unable to write to nagios command file Permissions to fil

Re: [ansible-project] Conditional loop messes up the following task that does a with_item

2015-09-02 Thread Samnang Sen
The error is within my original msg. I was using the when to build my deploy list. -- 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.

[ansible-project] Conditional loop messes up the following task that does a with_item

2015-09-02 Thread Samnang Sen
I store the modules I need to deploy within Consul. It consist of both Perl and PHP modules so on our web servers I only want to install the modules associated with PHP. The following playbook works as long as there are TWO matching modules. In my test case I have two keys with one of them being

Re: [ansible-project] Passing token to Consul via lookup plugin

2015-08-21 Thread Samnang Sen
I've tried that as well. I don't think it works because I used the following and it did not throw an error. Notice, I used "token123" and it didn't error out at all. {{ lookup('consul_kv', item, token123="mysecretoken") }} On Friday, August 21, 2015 at 4:16:53 PM UTC-4, Matt Martz wrote: >

Re: [ansible-project] Passing token to Consul via lookup plugin

2015-08-21 Thread Samnang Sen
Well according to this file (is this the right one?) I see paramters for token. /usr/lib/python2.7/site-packages/ansible/runner/lookup_plugins/consul_kv.py results = consul_api.kv.get(params['key'], token=params['token'],

[ansible-project] Passing token to Consul via lookup plugin

2015-08-21 Thread Samnang Sen
How do I pass the token to Consul? This doesn't appear to work, I'm not getting the value. However, if i set Consul to allow anonymous queries, it works fine. {{ lookup('consul_kv',item,"token=mysecretoken") }} -- You received this message because you are subscribed to the Google Groups "Ansi

[ansible-project] Replace variable w/ jinja2

2015-08-21 Thread Samnang Sen
I need to replace a variable that has the extra argument passed to it via CLI. ./deploy.yml -e 'jira_ticket=REL-78' I can't get it to strip out 'deploylist/REL-78' because I'm passing in 'jira_ticket' If i hardcode the varible it works perfectly. - name: Set fact set_fact: deploy_list"{{ ite

[ansible-project] Using consul to lookup group vars

2015-08-04 Thread Samnang Sen
We deploy RPMs by modifying a file within group_vars as follows. Is there a way to store the list of RPMs in consul and do a lookup and perform the installation? I want to get away from having to modify the file manually. # group_vars/deploy_list_php php: - { module: api, svn_tag: '20150731r1_6

Re: [ansible-project] Error with Hipchat callback library

2015-07-30 Thread Samnang Sen
Ugh, just caught there. thx Any idea when v2 will become stable? On Thursday, July 30, 2015 at 11:56:09 AM UTC-4, Brian Coca wrote: > > you are running the callback plugin from devel, which is incompatible > with previous versions. > > On Thu, Jul 30, 2015 at 11:41 AM, Samna

[ansible-project] Error with Hipchat callback library

2015-07-30 Thread Samnang Sen
Running Ansible v1.9.2 File "/usr/share/ansible_plugins/callback_plugins/hipchat.py", line 28, in from ansible.plugins.callback import CallbackBase ImportError: No module named plugins.callback -- You received this message because you are subscribed to the Google Groups "Ansible Proje

[ansible-project] Running Ansible from RPM

2015-07-24 Thread Samnang Sen
When I run Ansible from source by sourcing the env-setup file under the hacking folder, I'm able to run Ansible just fine. So now I want to run it via an RPM that i built for my RH5 hosts. When I run "ansible --version" I get the following ... # ansible --version ansible 1.9.2 configured modu

[ansible-project] ssl issues with hipchat module?

2015-07-24 Thread Samnang Sen
So here's what I did. If I run it from source (source ansible/hacking/env-setup) it seems to work. However, I created an RPM for my RH5 boxes (don't ask) and installed it across our web servers. I dont know if this means anything but I am getting the following message when running "ansible --ve

Re: [ansible-project] Skip task if variable isn't set?

2015-06-26 Thread Samnang Sen
h_items, so you cannot use it to avoid > undefined with_items, but you can do this: > > with_dict: deploy_modules_php|default({}) > > which will return an empty dict, which will also skip the loops > > On Fri, Jun 26, 2015 at 11:49 AM, Samnang Sen > wrote: > &g

[ansible-project] Skip task if variable isn't set?

2015-06-26 Thread Samnang Sen
I have a task that installs PHP and Perl modules against a group of servers. Servers w/ the word "batch" in their hostname run both Perl and PHP tasks (remove Perl tasks for simplicity). It seems the "Set PHP status success" task runs against machines w/ the word "batch" in them. ANy way I can

Re: [ansible-project] Conditional handlers from a task

2015-06-23 Thread Samnang Sen
re > hipchat: ... > color: red > when: yum_install|failed > > https://docs.ansible.com/playbooks_conditionals.html > > There maybe other ways to do it though. > > On 23 June 2015 at 07:46, Samnang Sen > > wrote: > >> FYI, I'm running my A

[ansible-project] Conditional handlers from a task

2015-06-23 Thread Samnang Sen
FYI, I'm running my Ansible playbook in "pull-mode" not push mode. Therefore, my nodes will publish the results of their task via Hipchat. With that said, I have a task that installs RPMs. When the installs are successful, the nodes notify via Hipchat that the task was successfully run. Now, in

[ansible-project] Broken notification with msg notification

2015-06-19 Thread Samnang Sen
I had opened this ticket (https://github.com/ansible/ansible/issues/11322) and a fix was made but I'm still having issues. Now I'm getting this error: NOTIFIED: [restart | announce_hipchat] failed: [server1-> 127.0.0.1] => {"failed": true} msg: failed to

[ansible-project] How to handle dynamic inventories with playbooks

2015-06-04 Thread Samnang Sen
We pull our server inventory from a Netscaler. Servers that are binded to a specific LB group is considered active and we deploy code and/or restart services at when needed. I've written a Python script that outputs the hosts into JSON format for Ansible to work with. This works fine except I'm

[ansible-project] Re-using a pre_task and post_task using roles?

2015-03-12 Thread Samnang Sen
Let's say I need to deploy two sets of applications - PHP vs PERL. I want to be able to re-use the pre_tasks and post_tasks snippet so that i dont have to make changes to multiple scripts if I modify a value for the netscaler module. I guess my question is what's the point of using "pre_tasks"

Re: [ansible-project] Properly wait for apache to run before inserting into load balancer

2015-03-04 Thread Samnang Sen
I'm an idiot, I didn't realize I could have multiple tasks in a post_task. :-D I added a new task to check for the webs and it works. On Wednesday, March 4, 2015 at 3:19:21 PM UTC-5, Serge van Ginderachter wrote: > > > On 4 March 2015 at 21:11, Samnang Sen > > wrot

[ansible-project] Properly wait for apache to run before inserting into load balancer

2015-03-04 Thread Samnang Sen
In my post task I insert the web servers back into the pool. What's a good way to make sure Apache is running prior to running the post task section? post_tasks: - name: enable in the lb netscaler: nsc_host={{nsc_host}} user={{nsc_user}} password={{nsc_pass}} name={{name}} t

[ansible-project] Re: Running playbook in interactive mode breaks upon run

2015-03-04 Thread Samnang Sen
Wednesday, March 4, 2015 at 10:57:03 AM UTC-8, Samnang Sen wrote: >> >> FYI. Ansible version is 1.8.2 and I tried it from the devel branch. >> >> -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe

[ansible-project] Re: Running playbook in interactive mode breaks upon run

2015-03-04 Thread Samnang Sen
FYI. Ansible version is 1.8.2 and I tried it from the devel branch. On Wednesday, March 4, 2015 at 1:53:34 PM UTC-5, Samnang Sen wrote: > > ansible-playbook -i hosts test.yml --step > > Output: > > PLAY [webservers] >

[ansible-project] Running playbook in interactive mode breaks upon run

2015-03-04 Thread Samnang Sen
ansible-playbook -i hosts test.yml --step Output: PLAY [webservers] * Traceback (most recent call last): File "/home/deployment/ansible/bin/ansible-playbook", line 316, in sys.exit(main(sys.argv[1:])) File "/home/deployment/an

Re: [ansible-project] Netscaler module returns "No module named json"

2015-02-17 Thread Samnang Sen
Awesome, works! Thanks a lot. On Tuesday, February 17, 2015 at 1:32:08 PM UTC-5, Brian Coca wrote: > > use connection: local for that task > > > -- > Brian Coca > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this g

Re: [ansible-project] Netscaler module returns "No module named json"

2015-02-17 Thread Samnang Sen
Is it attempting to log into the host? Why would it need to do that if the work is being done on the netscaler? On Tuesday, February 17, 2015 at 1:25:31 PM UTC-5, Brian Coca wrote: > > try just removing the import json from the file (netscaler.py), it > should not need it at all > > > > -- >

Re: [ansible-project] Netscaler module returns "No module named json"

2015-02-17 Thread Samnang Sen
Didn't like that. :-) msg: 'NoneType' object has no attribute 'read' FATAL: all hosts have already failed -- aborting On Tuesday, February 17, 2015 at 1:25:31 PM UTC-5, Brian Coca wrote: > > try just removing the import json from the file (netscaler.py), it > should not need it at all > > >

[ansible-project] Netscaler module returns "No module named json"

2015-02-17 Thread Samnang Sen
I'm running Ansible from a Centos 6 server w/ Python 2.6. My hosts are running RH5 w/ Python 2.4 and I have python-simplejson installed. On the client, "import json" from within the python interpreter doesn't work but "import simplejson" does work. So if I run the shell module ansible all -m s

[ansible-project] How to fetch a file from remote server without creating additional subfolders

2014-10-08 Thread Samnang Sen
This works except it creates additional subdirectories within the destination. I just want to copy into my current working directory where I'm running ansible from. # ansible all -m fetch -a "src=/tmp/pci.{{ inventory_hostname }}.txt dest=pci-{{ inventory_hostname }}.txt" -- You received thi

[ansible-project] How to get a hold of the hostname from inventory file?

2014-10-08 Thread Samnang Sen
I need to fetch a file from all servers in my inventory file. # ansible_hosts.txt server1 server2 server3 # Command I run. I want to substitute with the hostname within ansible_hosts.txt ansible all -m fetch -a "src=/tmp/.txt dest=special" -- You received this message because you are subscri

[ansible-project] How to skip a hash if it's empty

2014-06-30 Thread Samnang Sen
This could probably be done much better so any advice is welcome. I have a file called "deploy_list" inside the "group_vars" folder. It's a list of modules that needs to be deployed. During any given deploy, the deployment person lists the modules he wishes to deploy. The list of modules differs

[ansible-project] Question with group_vars

2014-05-20 Thread Samnang Sen
In my local.yml I'm able to run the playbook and reference variables within group_vars/all however I'm not able to access variables within group_vars/phl-stage. Let's assume the following. ansible-playbook -i phl-stage site.yml I have a variable, let's call it "deploy_path" that's different for

[ansible-project] Re: Display error message if variable isn't set using playbook

2014-05-07 Thread Samnang Sen
uld replace the fail > module with something like debug. > > On Monday, May 5, 2014 7:58:27 AM UTC-7, Samnang Sen wrote: >> >> That last line is supposed to read "revision_no is defined" >> >> On Monday, May 5, 2014 10:53:54 AM UTC-4, Samnang Sen wrote: >

Re: [ansible-project] Checking for multiple conditions using "when"

2014-05-07 Thread Samnang Sen
tem.key == "php" or item.key == "perl"' > > Should instead be: > > when: item.key == "php" or item.key == "perl" > > > I tested with that change and everything works as expected. > > One potential improvement: > > when: item.

Re: [ansible-project] Checking for multiple conditions using "when"

2014-05-07 Thread Samnang Sen
name: Modify ownership shell: chown www:www {{ module_path }} with_dict: deploy_modules when: item.key == "php" or item.key == "perl"' On Wednesday, May 7, 2014 4:39:12 PM UTC-4, Strahinja Kustudić wrote: > > How and where did you define *deploy_modul

Re: [ansible-project] Re: Display error message if variable isn't set using playbook

2014-05-07 Thread Samnang Sen
: msg="Playbook execution failed - 'revision_no' is required!" >> when: not revision_no >> >> If you don't want the play to outright fail, you could replace the fail >> module with something like debug. >> >> On Monday, May 5, 2014 7:58:2

Re: [ansible-project] Checking for multiple conditions using "when"

2014-05-07 Thread Samnang Sen
val1: "this is bam value 1" > val2: "this is bam value 2" > tasks: > - name: do loop over values dictionary > debug: var=item.value.val1 > with_dict: values > when: item.key == 'foo' or item.key == 'bar' > > > &

[ansible-project] Checking for multiple conditions using "when"

2014-05-05 Thread Samnang Sen
I have a list of modules I would like to deploy. With certain modules, I want to run a specific command against it. For example, if the module is a PHP or PERL module, I want to modify the ownership of the folder. If it's anything else, ignore the task. The task below fails - name: Modify own

[ansible-project] Re: Display error message if variable isn't set using playbook

2014-05-05 Thread Samnang Sen
That last line is supposed to read "revision_no is defined" On Monday, May 5, 2014 10:53:54 AM UTC-4, Samnang Sen wrote: > > Let's say I ask for a revision_no from the user. If the user doesn't input > a value, I would like to display a custom message. Right no

Re: [ansible-project] Export code using tags with subversion module

2014-05-05 Thread Samnang Sen
real branches and smarter merging quickly makes up for the learning curve! > > > > > > > > > On Fri, May 2, 2014 at 11:53 AM, Samnang Sen > > wrote: > >> So the doc shows the option to export code by passing a revision number. >> We deploy code by usin

[ansible-project] Display error message if variable isn't set using playbook

2014-05-05 Thread Samnang Sen
Let's say I ask for a revision_no from the user. If the user doesn't input a value, I would like to display a custom message. Right now ansible shows a bunch of "skipping" message, but I know my users would want to know why it skipped. - hosts: webservers user: deployment # serial: 1 var

[ansible-project] Export code using tags with subversion module

2014-05-02 Thread Samnang Sen
So the doc shows the option to export code by passing a revision number. We deploy code by using the tags we create for deployments. Is it possible to use tags instead of "revisions," or am I better off using the command line? -- You received this message because you are subscribed to the Googl