[ansible-project] Re: Convert an XML to JSON using ansible

2018-05-08 Thread Vince Skahan
On Tuesday, May 8, 2018 at 4:43:52 AM UTC-7, Madushan Chathuranga wrote:
>
> Is there a filter or any work around to convert an XML to JSON using 
> ansible?
>
>
Why would you possibly want to use 'ansible' to do that ?

There are a zillion ways to do it in various languages if you do a little 
google searching.

Try seaching for "convert xml to json python" for some examples

-- 
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/69e6a482-74a3-433e-b781-5744f28d630b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Unable to upgrade to Ansible 2.2 on Mac

2016-12-24 Thread Vince Skahan
On Friday, December 23, 2016 at 9:45:20 PM UTC-8, Santhosh Gowda wrote:
>
>
> I get the same error even with sudo pip install --upgrade ansible.
>
>
>
I've had zero success trying to upgrade ansible on mac.  I do 'pip 
uninstall' then a 'pip install' which gets the new 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/23c0b729-8537-45fc-9ce7-0de473b8f43f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] ansible using versioned playbooks ala r10k

2016-12-08 Thread Vince Skahan
Working in a puppet shop, I have to admit r10k is pretty cool. It lets us 
set up 'versioned' environment definitions that we can apply to the right 
target computers, ala "use the development version of the puppet code 
(profile) that  configures package XYZ".All those profiles are in git, 
with versioning done via either branches (give me branch-XYZ latest) or via 
tags (give me tag v1.2.3). 

One discussion on serverfault was 
at 
http://serverfault.com/questions/788930/what-is-the-equivalent-of-r10k-in-ansible
 
- the preferred answer has a very good example of what a r10k Puppetfile 
looks like, and what the ansible-galaxy equivalent would be.  The question 
of course is how to do that in vanilla ansible 'without' galaxy.

Bottom line - we don't always use 'latest greatest version' of our 
automation code (puppet roles/profiles or for ansible 
roles/tasks/handlers/etc.), nor should we.  We're using the right version 
of our automation code and vars to get us the desired end state.

So, we want to be able to define our environments to say configuration-ABC 
is:

   - these variable=values definitions (from a tag or branch of a git repo)
   - these roles/tasks/handlers (from a tag or branch of a git repo, likely 
   one per thingy we're trying to install+configure)

All without ansible-galaxy, using just ansible.  How might we make that 
happen ?

Again, the link above has a great definition of how Puppet/r10k work, and 
what the galaxy equivalent would be.  I just can't afford/use galaxy at 
all.  Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/990b647e-0614-4e1d-9d0f-98b6973839ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Using ansible for software deployments – are we doing it right?

2016-11-02 Thread Vince Skahan
On Wednesday, November 2, 2016 at 8:52:54 AM UTC-7, fredsted wrote:

> The whole process when deploying new code takes around 10 minutes, which 
> my coworkers think is really *slow*. (obviously, on each node, it pulls 
> down code from git, installs all the dependencies every time as well as 
> composer, php-fpm, supervisor, virtual hosts, etc).
>
>
>
Does it 'install' everything every time, or 'verify' that the dependencies 
are there, and only install something if it needs to ? 

-- 
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/1dc89dd4-753d-4690-950a-e9c6b959e556%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: ansible 2.1.1, yum install and disabled respositories

2016-09-29 Thread Vince Skahan
On Wednesday, September 28, 2016 at 9:59:55 AM UTC-7, Stefan Klatt wrote:

> I use ansible 2.1.1 and have a problem with "yum install" if the used 
> repository is disabled. 
>
>
>
Sounds like it's doing the correct thing.

Perhaps add the "enablerepo" option to your playbook ?
 http://docs.ansible.com/ansible/yum_module.html

-- 
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/b2ed268c-f07a-47cd-b3e6-919e24c587e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Generating a config from a running vm

2016-01-12 Thread Vince Skahan
On Monday, January 11, 2016 at 5:41:02 AM UTC-8, Robert Haskins wrote:
>
> I am new to Ansible and trying to learn how it might work in my 
> environment. I was wondering if there was a mechanism whereby one could 
> generate an Ansible config for an already running machine that was not 
> built under Ansible? In other words, I would like to convert my existing 
> non-Ansible managed infrastructure to be managed by Ansible. A sane 
> starting place would seem to be some method to convert my existing vm's to 
> Ansible without a bunch of "manual" work.
>
>
>
How in heaven's name would any tool know what you built, how you built it, 
and how to recreate it ?   That's just fantasy-land.   There are an 
infinite number of ways of getting a system setup from rpms or tgz or git 
pulls or hand-configuring etc.

You can easily convert a hand-built system to a ansible-configured one, but 
you need to do the heavy lifting at least once. 

-- 
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/f957434f-93c0-4c05-9b40-c164eb831e8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: help: install/upgrade a list of RPMs

2015-12-15 Thread Vince Skahan
Perhaps you could do a little test to verify the original answer you got 
worked (or did not).

Install an old rpm manually
Install a current rpm manually
Write a playbook using ensure=latest referencing both
You should see it updated the old one to current, and left the already 
current one alone


-- 
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/7a42810a-e7cf-4c17-8b82-3552e479bc83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] indempotence best practices questions and playbook example

2015-04-16 Thread Vince Skahan

I'm a little confused about best practices for indempotence in Ansible.   
 Here's a quick playbook that does the following:

   - installs mysql-server on a minimal debian system, preseeding the 
   questions (ugh) the package asks to set the mysql password
   - installs zoneminder
   - conditionally copies in a gzipped dumpfile of a pre-configured 
   zoneminder setup, unzips it, restores it
   - and links the zoneminder stuff into the apache2 web configuration


Where I'm confused is the convoluted gymnastics needed to do things 
conditionally, only if there was something done above.   The playbook below 
works fine, but it sure seems like a lot of work to do to make each step 
indempotent.  Am I missing something in best practices or syntax ?

Note - yes I set a db password to 'root' in this example, and I'm keying 
off stuff stashed in /tmp existing or not.  Don't sweat that part, it's 
just an example.  I'm interested in better understanding best practices re: 
how to do the playbook structure and logic/flow.  Thanks.

 

---

 ### unfortunately, this one always comes up as changed

- name: mysql | set debconf values
  debconf: name='mysql-server-5.5' question={{ item.question}} value={{ 
item.value }} vtype={{ item.vtype }}
  with_items:
 - { question: 'mysql-server/root_password',   value: 'root', 
vtype: 'password' }
 - { question: 'mysql-server/root_password_again', value: 'root', 
vtype: 'password' }

- name: Install Mysql
  apt: package={{ item }} state=present
  with_items:

  - mysql-server
 

- name: install zoneminder
  apt: package={{ item }} state=present
  with_items:
 - zoneminder

### check to see if we ran before by looking for the extracted db dump 

- name: check for previous database dumpfile
  stat: path=/tmp/zm.dump
  register: dumpfile

### if the extracted file isn't there, we need to copy the gzipped file in 

- name: copy db dump into place
  copy: src=zm.dump.gz dest=/tmp
  when: dumpfile.stat.exists == False
  register: zipped_dumpfile


### if we took action in the previous step, we need to unzip what we copied 
in

- name: unzip db dump
  command: gunzip -f /tmp/zm.dump.gz
  when: zipped_dumpfile.changed == True
  register: dumpfile_unzipped

 

### and that also means we need to restore the db dump to put it into place
- name: restore configured database
  shell: mysql -uroot -proot zm < /tmp/zm.dump
  when: dumpfile_unzipped.changed == True
  notify: restart zoneminder

### similarly, we link zoneminder into the apache web and restart apache, 
only if needed 

- stat: path=/etc/apache2/sites-enabled/001-zm
  register: apache_zm_site

- name: symlink zoneminder into web
  file: src=/etc/zm/apache.conf dest=/etc/apache2/sites-enabled/001-zm 
state=link
  when: apache_zm_site.stat.exists == False
  notify: restart apache


-- 
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/b63af770-6277-4f2e-846b-69b1178591ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] lineinfile when two lines are the same

2015-03-28 Thread Vince Skahan
I'm installing a piece of software that requires me to edit a user=xyz line 
into a monolithic config file that is .ini like in format.

[function-x]

# user=myuserhere

 

[function-y]
# other stuff here
# more stuff here

 

[function-z]
# user=myuserhere



So suppose I have a config that requires me to uncomment the line in 
[function-Z] and substitute in the right value for the username.

How do you specify which of the two identical lines in the file that you 
want to edit ?
Any suggestions ?




-- 
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/b1e62369-aa9d-4ae4-b962-ce7b466d1908%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] -b and password prompting in ansible 1.9

2015-03-28 Thread Vince Skahan
On Thursday, March 26, 2015 at 9:18:17 AM UTC-7, Brian Coca wrote:
>
> I was actually planning to soften the restriction and allow -K to work 
> with -b 
>
>
>
That would be helpful.

The new syntax is unclear to me, and I'm not understanding why you 
deprecated the old clear/concise syntax.

Consider a raspberry pi where you login as user 'pi' and sudo your commends:

old:
 -k -u pi --sudo
new:
-k -u pi -b --become-user=root --become-method=sudo


Or do your defaults mean that the new way would just be:
  -k -u pi -b

(in which case, what value was replacing a nice and clear/concise --sudo 
with a cryptic -b where we need to know the defaults for which user and 
method) ?

-- 
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/554b7429-b81c-48e6-9588-493a9ce75ac4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: conditionally running tasks

2015-03-24 Thread Vince Skahan
On Tuesday, March 24, 2015 at 12:18:29 PM UTC-7, Dag Wieers wrote:
>
> On Tue, 24 Mar 2015, Vince Skahan wrote: 
> > Does ansible do 'include' before 'gather_facts' perhaps ? 
> > If so, that would be a pretty major bug/misfeature to me... 
>
> I haven't tested your example, but what I usually do is something like: 
>
>tasks: 
>- action: group_by key={{ ansible_distribution }}-{{ 
> ansible_distribution_major }} 
>
> and have a a group_vars file for each group: 
>
>group_vars/debian-7 
>group_vars/redhat-6 
>
> This will automatically pull variables from the matching group_vars file. 
>
> In fact, in large/complex environments my inventory script has this kind 
> of functionality included so that it has all the needed variables 
> and groups available for every playbook and play from the very start. 
>
>
Thanks, that helps a lot, I think I'll go that route.

If you have time, see if you can get variable substitution to work in an 
include statement.  It sure 'seems' to try to include the file before doing 
things defined above it (like grabbing the facts) which to me is a design 
flaw.  If we wanted to have calculated filenames based on other things 
defined above it in the sequence, how is that possible currently ?   How do 
we know (or control) the ordering of what ansible is doing ?

Lots of cool stuff here, just a bit undefined and perhaps buggy from what 
I've seen thus far, but I might just not be looking up the right buzzwords 
in their docs.


 

-- 
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/018cb805-31fb-4cbb-901e-bc562b1ecbc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: conditionally running tasks

2015-03-24 Thread Vince Skahan
On Tuesday, March 24, 2015 at 6:46:27 AM UTC-7, Jonathan Davila wrote:
>
> You could try to variablize the values of the module parameters into 
> os-specific vars files and then do conditional include statements based on 
> the os.
> Where you would have files named like debian-7.yml, etc. And within those 
> files you would have serial_regex/replace defined along with any other vars.
> Does that help?
>
>
Notionally yes, but ansible doesn't seem to like variables in - include: 
statements.

Does ansible do 'include' before 'gather_facts' perhaps ?
If so, that would be a pretty major bug/misfeature to me...

Here's an example that shows the problem.

- hosts: all
  gather_facts: yes
  tasks:
- debug: msg="{{ ansible_distribution }}-{{ 
ansible_distribution_version }}.yml"
- include: "{{ ansible_distribution }}-{{ ansible_distribution_version 
}}.yml"


Running that trivial playbook fails:


ERROR: file could not read: /tmp/{{ ansible_distribution }}-{{ 
ansible_distribution_version }}.yml



But if you try to debug only (after commenting out the include: line) the 
fact collection works ok:


PLAY [all] 


GATHERING FACTS 
***
ok: [192.168.0.169]

TASK: [debug msg="{{ ansible_distribution }}-{{ 
ansible_distribution_version }}.yml"] ***
ok: [192.168.0.169] => {
"msg": "Debian-7.8.yml"
}

PLAY RECAP 

192.168.0.169  : ok=2changed=0unreachable=0failed=0



I tried similar things setting variables, custom facts, etc. to no avail. 
 Seems like ansible includes first as it does its runs (???)

 

-- 
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/6f20b3bf-ec4f-4bea-a7d3-c75f0c2f34f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] conditionally running tasks

2015-03-23 Thread Vince Skahan
What's the preferred way to conditionally configure something if the 'how' 
changes from os to os, and version to version 'of' any particular os ?

Here's an example - setting up a serial console on a SysVinit system 
(example - debian 7.8):

---
- hosts: all
  gather_facts: yes
  tasks:
- name: set up serial console
  replace:
 dest:/etc/inittab
 regexp:  "^#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100$"
 replace: "T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100"
  notify:
 - telinit_q
  handlers:
   - name: telinit_q
 command: "/sbin/telinit q"


But that only works on debian-7 systems.  I can limit it to debian-7 by 
inserting


   when:
  ansible_distribution == 'Debian' and 
ansible_distribution_version == '7' 


But that doesn't handle centos-5 which has a slightly different 
search/replace neededor centos-7 which uses systemd, and so on.

I guess I'm struggling with how to have a set (tree?) of plays for task-ABC 
that are known good, but only using them when the os/version say to do it 
that way.

Is the preferred way to include .yml files based on distribution/version 
values discovered at runtime ?   Examples ?



-- 
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/cec21a03-fe86-434b-ab8c-c995110cc2aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] complicated replace fails to match

2014-11-10 Thread Vince Skahan
I'm trying to append to a line that has a reasonably complicated snippet of 
python looking code.


defaultStatsSchema= [_tuple for _tuple in defaultArchiveSchema if _tuple[0] 
in stats_types] + [('wind', 'VECTOR')]


to that line, I'm trying to add the following:


+ [('windAv', 'VECTOR')] + [('outTempDay', 'REAL')] + [('outTempNight', 
'REAL')]



The pythonish format of the lines seem to be confusing the replace: module 
in ansible 1.7.2 -  I *think*


- replace: dest=/home/weewx/bin/user/schemas.py regexp="{{ item.orig }}" 
replace="{{ item.new }}"

 with_items:

  - { 

  orig: "defaultStatsSchema= [_tuple for _tuple in 
defaultArchiveSchema if _tuple[0] in stats_types] + [('wind', 'VECTOR')]" ,

   new: "defaultStatsSchema= [_tuple for _tuple in 
defaultArchiveSchema if _tuple[0] in stats_types] + [('wind', 'VECTOR')] + 
[('windAv', 'VECTOR')] + [('outTempDay', 'REAL')] + [('outTempNight', 
'REAL')]

 }


I guess I'm lost what to (or to not) escape in the original line above.   
 The multiple [whatever] words in there seem to confuse the heck out of the 
replace module and either say 'ok' when it isn't actually matching 
anything, or blowing up with an error at runtime.   Clarification/help 
appreciated







-- 
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/74518805-36e8-46d5-903b-62ced4d0b84a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] insert multiple lines at a particular location within a file

2014-11-10 Thread Vince Skahan
I'm looking for a reasonable way to insert a block of lines into a certain 
position within a file hopefully 'without' needing to template the 
destination file.

I have a config file that I need to insert multiple lines into.

[SectionA]
  ... many lines below here ...
[SectionB]
  ... many more lines below here...
[SectionC]
  ... and so on...


What I'm trying to do is insert a block of lines just above the 'SectionB' 
line.


[SectionA]
  ... many lines below here ... 

*  [[subsectionX]]*
* HTML_ROOT = /path/here*
*  [[subsectionY]]*
*HTML_ROOT = /path/here*

 [SectionB]
 ... many more lines below here...
 [SectionC]
   ... and so on...

I tried a 'with_items' approach ala:

- name: insert the lines
  lineinfile: dest=/config/file/path line="{{ item }}" 
insertbefore='[SectionB]'
  with_items:
  - " [[subsectionX]]"
  - "   HTML_ROOT = /path/here"
  - " [[subsectionY]]"
  - "   HTML_ROOT = /path/here"


This struck me as a bit of a kludge, and it failed anyway as ansible only 
adds the first 'HTML_ROOT =" line into the file, and does not add the 
second one (being a little too smart for its own good)

Is there a preferred way to do this kind of stuff ?





-- 
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/8b5da77b-3d2f-45b9-a8b0-a6b4e9ebd2a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.