[ansible-project] Re: Install package for point release

2016-12-29 Thread Kevin Csuka
Any epic guru's?

-- 
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/dca57364-4262-401a-97da-e3a4de37a1ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible stdout_lines writes as list syntax [u'text1',u'text2'] instead of multiline?

2016-12-29 Thread burns498
Hello Jon - Thanks for the help!

The change you suggested did help clean it up a bit. It changed it from a 
list output to one line string separated by literal '\n'. Something like 
"2a3\n> echo hi". This was a step in the right direction.

I did some more digging around and found an answer using Jinja2 whitespace 
control . 
Uses a for loop to parse the list output via jinja2 filters.
*Updated Code Snippet:*
- name: Log diff changes
  blockinfile:
dest: "{{ log_dir }}/{{ pb_diff_logname }}"
content: |
  {{ app_log_header }}
  Command: 'diff {{ deployed_copy_output.dest }} {{ 
deployed_copy_output.backup_file }}'
  {% for item in diff_output.stdout_lines %}
  {{ item }}
  {% endfor %}
  {{ app_log_footer }}
create: yes
insertafter: EOF
marker: "{{ app_log_marker }}"

The output is then quite clean in the log file.

> **
> Command: 'diff /opt/wmspt/.profile 
> /opt/wmspt/.profile.2016-12-29@08:57:50~'
> 2a3
> > echo hi
> **


Thanks!

On Thursday, December 29, 2016 at 1:14:04 AM UTC-6, J Hawkesworth wrote:
>
> Try using join, like this
>
> {{ results.stdout_lines | join ('\n') }}
>
> Not tried, but hope it helps,
>
> Jon 
>
>

-- 
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/5fd8619c-d23c-4bd5-ba1d-10a9ed69fe53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Iterate through user input data

2016-12-29 Thread Kai Stian Olstad

On 24. des. 2016 22:37, Ahmed Jaad wrote:

Im a newbie to ansible, and im trying to write an ansible script which
would continuously prompt user to insert data and use the data to perform
some tasks until the user decides to end the loop, a shell script serving
the same purpose would look like this.

read -s -p "Create new directory? y/n: " response while [[ "$response" == "y" ]] do read -s -p "Enter 
the name of direcory: " name mkdir $name if [ $? -ne 0 ] then echo "Failed to create new directory $name" exit 1 fi read -s 
-p "Create another new directory? y/n: " response done

so how do i go about this?


It's not possible with Ansible, Ansible have prompts
https://docs.ansible.com/ansible/playbooks_prompts.html
But this is question you will have to ask and answer upfront before 
playbook the rest of the playbook get executed.


--
Kai Stian Olstad

--
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/64296fe5-6f49-de5a-fe86-e46228df2ef1%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to use ignore_errors with include statement ?

2016-12-29 Thread Kai Stian Olstad

On 28. des. 2016 03:38, Cann wrote:

I am not sure what is not clear about my question. As title indicates: "How
to use ignore_errors with include statement ?"


In your subject you have one thing, but in the mail you are talking 
about undefined variables, and in the example you av including a file 
that doesn't exist.




I want ansible to ignore this error. I use "ignore_errors: yes" but it
fails anyways.


ignore_errors only work on task that return a exit code, include is just 
a directive to include tasks.
Ignore_error will be applied to every task in the include file, but it 
will not work on include when you are including a file that doesn't exist.



--
Kai Stian Olstad

--
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/ddf5820d-dc8b-14ec-aeb6-fdec591727b2%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Automatically connecting as different user on later runs after 'root' is disabled

2016-12-29 Thread Greg Bell
Hi,

One of my tasks disables root over ssh.
Another creates an 'app' user that has sudo powers.

That means that the way to connect to the host changes after the first run.

Is there a smarter way to easily adjust to this new state than manually 
adding --become and --user command-line options to ansible-playbook on 
subsequent 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/b36131d5-a1f5-4ed5-949e-55d5cc0ec9ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Delegate with template with source file on remote

2016-12-29 Thread Mehdi B
After checking the archive:
https://groups.google.com/forum/#!topic/ansible-project/HqCymjQoVjc

Seem the point here as we need jinja2 on remote server too and python. So 
best is festching it once using 

http://docs.ansible.com/ansible/fetch_module.html

Then pushing back the file.

If anyone have better idea you are welcome.

Mehdi B

On Thursday, December 29, 2016 at 11:47:06 AM UTC+1, Mehdi B wrote:
>
> Hi,
>
> I have a project where I wanted to use templates but instead of having 
> them on ansible server, I wanted to use a remote file and deploy it.
>
> Why? As I'm cloning site project on remote front servers, and the template 
> is in the project so dev's could update it. 
>
> So I have server 1 ( ansible controller )
>
> Server 2 ( target ) with template.php.dist file on /home
>
> I created a role with main task:
>
>
>   - name: Create conf config/template.php
> template: >
>  src="/home/template.php.dist"
>  dest="/home/licom.php"
> delegate_to: "{{ item }}"
> with_items:
>  - "{{ inventory_hostname }}"
>
> So I delegate the task to execute on server 2 here but seem that the 
> template will always check for server 1 as source. Is there a way to 
> changer the source server? So I won't need to clone the entire project on 
> server 1?
>
> Thanks
> Mehdi B
>

-- 
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/a66108cc-e4f0-444f-84e3-1cafc6c10731%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Delegate with template with source file on remote

2016-12-29 Thread Mehdi B
Hi,

I have a project where I wanted to use templates but instead of having them 
on ansible server, I wanted to use a remote file and deploy it.

Why? As I'm cloning site project on remote front servers, and the template 
is in the project so dev's could update it. 

So I have server 1 ( ansible controller )

Server 2 ( target ) with template.php.dist file on /home

I created a role with main task:


  - name: Create conf config/template.php
template: >
 src="/home/template.php.dist"
 dest="/home/licom.php"
delegate_to: "{{ item }}"
with_items:
 - "{{ inventory_hostname }}"

So I delegate the task to execute on server 2 here but seem that the 
template will always check for server 1 as source. Is there a way to 
changer the source server? So I won't need to clone the entire project on 
server 1?

Thanks
Mehdi B

-- 
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/f5b1e13c-657a-4cd3-9c17-0bde74609188%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible to output which host a task is running on

2016-12-29 Thread Kevin Csuka
Callback plugin is used after a play is finished.
Good question tho. Don't know how.

On Saturday, December 24, 2016 at 9:24:34 PM UTC+1, Mumshad Mannambeth 
wrote:
>
> Ansible prints information whenever a task starts, but doesn't print 
> information on which host it is running currently. is there a way to make 
> it print this information. may be with modification to Callback plugins? I 
> looked at v2_playbook_on_task_start call but was not able to get host 
> information for which a task is running. Appreciate any information around 
> here.
>
> Thanks
> Mumshad
>

-- 
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/a96dfaf4-7f86-4073-9663-8f434885ae74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Install package for point release

2016-12-29 Thread Kevin Csuka


Actual package name in the repo is package-2.6.12-3.el7.x86_64.

The goal is to install a package with Ansible, to:

   - * Ensure the point release is installed, such as package-2.2
   - * Doesn't install major releases, such as package-3.0
   - * Updates for minor releases, such as package-2.6.13-4

The repo can update packages from time to time, but I don't know when.

My thought was to install a package like this;

- name: Install package
  yum:
name: package-2.6
state: present

But the task fails, because package-2.6 is not in the repo. Whereas simply 
package works, but it not future proof.

How do I achieve this?

-- 
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/75d93386-1686-4db8-9378-c31f5f3ed913%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.