Re: [ansible-devel] Re: Playbook help - syntax

2016-05-25 Thread Kai Stian Olstad

On 25.05.2016 07:23, 'jhawkesworth' via Ansible Development wrote:
Single line ansible module calls can use the key=value key=value 
syntax,
but when you are using the multi-line yaml style syntax it needs to be 
key:

value


This statement is not correct.


yamllint.com or a yaml-aware text editor can be a help when you are 
getting

used to writing playbooks.


Code like this work
- name: Update the Apache config
  copy: >
src=httpd.conf
dest=/etc/httpd/httpd.conf

Even dropping the bigger than and it works, also yamllint.com says it is 
valid.


More about multiline here
https://support.ansible.com/hc/en-us/articles/201957837-How-do-I-split-an-action-into-a-multi-line-format-

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Re: When statements with Jinja2 templating delimiters

2017-05-26 Thread Kai Stian Olstad

On 26. mai 2017 14:54, Jörg Kastning wrote:

I found this discussion in the githup issue mentined above. In my case I
need to run a play only when a certain string was found an the output of
another command. Example main.yml from one of my roles:
---
   - name: Install Red Hat Security Advisory (RHSA)
 command: yum -y update-minimal --advisory {{ rhsa_to_install }}
 register: yum_output
   - debug: var=yum_output

   - name: Reboot Host if any packages were updated
 shell: sleep 2 && shutdown -r now "Ansible updates triggered"
 async: 1
 poll: 0
 ignore_errors: true
 when: ("Complete!" in "{{ yum_output.stdout_lines[-1] }}") or
   ("Komplett!" in "{{ yum_output.stdout_lines[-1] }}")

  Since Ansible 2.3 I got the warnings described in detail in
https://github.com/ansible/ansible/issues/22397.

I would like to get back the behaviour from Ansible <2.3. While I'm new to
Ansible I may simply not know how to work around this warnings by declaring
the when statement in a different way. Could someone give me a hand here?


In your case you need to do what the warning says, remove the "{{ and 
the }}" and the warning will be gone.


  when: ("Complete!" in yum_output.stdout_lines[-1]) or
("Komplett!" in yum_output.stdout_lines[-1])

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Re: When statements with Jinja2 templating delimiters

2017-05-27 Thread Kai Stian Olstad

On 27. mai 2017 13:40, Jörg Kastning wrote:

Am Freitag, 26. Mai 2017 18:12:43 UTC+2 schrieb Kai Stian Olstad:

In your case you need to do what the warning says, remove the "{{ and
the }}" and the warning will be gone.

when: ("Complete!" in yum_output.stdout_lines[-1]) or
  ("Komplett!" in yum_output.stdout_lines[-1])



Thanks for helping me Kai. I appreciate it.


You're welcome.



Brian wrote:


There are just 2 contexts, normal (you require them) and conditionals
(anything with when:) which don't. It is consistent, juts not uniform.



I do not understand the need for two different contexts here? Why could it
not kept the way like it was in Ansible <2.3.


In some other context that way did cause errors.

If the Jinja template context was removed from when your way of writing 
it would fail. The reason for this is that "string" in a.variable is a 
Jinja expression

http://jinja.pocoo.org/docs/dev/templates/#other-operators

If removed you would have to add the {{ at the beginning and }} at the 
end like every time like so.


  when: "{{ ("Complete!" in yum_output.stdout_lines[-1]) or
        ("Komplett!" in yum_output.stdout_lines[-1]) }}"

--
Kai Stian Olstad

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Restoring an ansible backup file

2018-08-16 Thread Kai Stian Olstad
On Thursday, 16 August 2018 00.56.06 CEST Tony Owens wrote:
> I'm trying to copy a file out with backup option which works fine.  I'm 
> pretty sure I am overlooking over something simple here.  Any help is 
> appreciated.

For starter you shouldn't use the developer list for user questions
https://docs.ansible.com/ansible/2.6/community/communication.html#mailing-list-information


> ---
> - hosts: all
>   become: true
>   vars:
> push: false
> fallback: false
> jksfile: ''
>   tasks:
>- name: "copy jks"
>  copy:
>src: "/etc/ansible/mydir/install/repo/{{ jksfile }}"
>dest: "/mydir/opt/repo/{{ jksfile }}"
>owner: me
>group: me
>backup: yes
>  when: push == "true"

If you check the return values for the copy module you'll see it return 
backup_file
https://docs.ansible.com/ansible/2.6/modules/copy_module.html#return-values

So add «register: result» then you'll have the filename in {{ 
result.backup_file }}, this might be easier.

 
>- name: "get backup file"
>  find:
>paths: /mydir/opt/repo
>patterns: "*{{ ansible_date_time.date }}*"
>  register: myfile
> 
>- name: "restore file"
>  copy:
>src: "{{myfile.files|map(attribute='path')|list}}"
>dest: "/mydir/opt/repo/{{ jksfile }}"
>owner: me
>group: me
>remote_src: yes
>  when: fallback == "true"

src doesn't take a list so you need to choose one of the element in the list, 
to take the first you need
  src: "{{(myfile.files|map(attribute='path')|list)[0]}}"

But remember, you might have multiple backups on the same day and find will 
return them all so you never now which one is in the first element.


-- 
Kai Stian Olstad


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-devel] Where to put module guides

2018-08-29 Thread Kai Stian Olstad
On the user list the use of the expect module is a topic that keeps 
coming up, so instead of repeating my self I should probably just 
document it somewhere.


A longish guide on the expect module page[1] is probably not a good 
idea.
I see there are some guides here 
https://docs.ansible.com/ansible/latest/scenario_guides/guides.html


Would that be a OK place for a expect module guide?
Or is it more suitable some other place?


[1] https://docs.ansible.com/ansible/latest/modules/expect_module.html

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Re: Where to put module guides

2018-08-30 Thread Kai Stian Olstad
On Wednesday, 29 August 2018 20.18.55 CEST acoz...@redhat.com wrote:
> Thanks for the post and for your interest in making the docs more complete. 
> Depending on the content you want to add, the scenario_guides section might 
> be a great place.
> 
> I'd recommend you open a PR that adds a guide for using expect under 
> scenario_guides - if the content fits better elsewhere, we can discuss 
> moving it once it's written.

Thanks Alicia, I'll start on a PR and we'll see where it end up.

-- 
Kai Stian Olstad


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] new developer: make deb

2018-03-08 Thread Kai Stian Olstad
On Thursday, 8 March 2018 16.14.18 CET Keltik85 wrote:
> first thanks for your answer and sorry again for the next stupid question.
> 
> Ok I installed this stuff here:
> 
> *sudo apt-get install -y asciidoc libxslt1-dev docbook-xsl xsltproc 
> libxml2-utils devscripts*

You need to check the line Build-Depends: in file packaging/debian/control and 
install the requirement listed there.


-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Ansible module to seach aws cloud watch logs

2018-10-17 Thread Kai Stian Olstad
On Wednesday, 17 October 2018 16.55.57 CEST Madushan Chathuranga wrote:
> Is it possible to remove this?

No, since this is a mailing list the mails is already sent to the 2659 
subscribed to the list. 


> On Wednesday, October 17, 2018 at 8:24:36 PM UTC+5:30, Madushan Chathuranga 
> wrote:
> > I'm absolutely sorry about that. My intention was to notify ansible 
> > developers requesting such feature in a future ansible version.

Most project usually write down the process to do this and Ansible is no 
exception
https://docs.ansible.com/ansible/latest/community/index.html

How to request a feature you'll find here
https://docs.ansible.com/ansible/latest/community/reporting_bugs_and_features.html#requesting-a-feature


-- 
Kai Stian Olstad


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] host unreachable

2018-11-14 Thread Kai Stian Olstad
On Wednesday, 14 November 2018 17:19:38 CET Bob Harold wrote:
> On Tue, Nov 13, 2018 at 5:37 PM Brian Coca  wrote:
> 
> > 1 play before your normal play:
> >
> >
> > hosts: hosta,hostb
> > gather_facts: False
> > tasks:
> >- ping:
> >- group_by: key=rechable
> >
> > hosts: reachable
> > 
> >
> > --
> > Brian Coca
> >
> 
> Thanks for mentioning the 'ping' module - that is new to me.  (It checks
> ssh connection and python, not an icmp ping)
> But I don't see "reachable" as a return value in the docs.

It's not a return value.
group_by is a module that will add the host in a group call rechable.


> Looks like that will run it for both hosts, which is not what the requestor
> wanted.  More like:
> 
> hosts: hosta
> gather_facts: False
> tasks:
>- ping:
>  register: pingtest
>- hosts: hostb
>  when: pingtest.failed
> 
> But so far I cannot get it to work.
> 
> I am looking to use the same logic to connect to the internal or external
> IP of an AWS server depending on where I happen to be running Ansible at
> that moment.

This will run on the first host in the list(host2) if it reachable if not it 
will run on the second host(host1)
Not pretty but should work.

---
- hosts:
- host2
- host1
  gather_facts: no
  serial: 1
  ignore_unreachable: true
  tasks:
- ping:
  register: r
- group_by:
key: rechable_hosts
  when: r.unreachable is not defined

- hosts: rechable_hosts[0]
  tasks:
- ping:


-- 
Kai Stian Olstad


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] host unreachable

2018-11-14 Thread Kai Stian Olstad
On Wednesday, 14 November 2018 18:39:28 CET Brian Coca wrote:
> there is no need to register as the host failing the ping will be
> removed from the play.

Yes it's necessary, if not the group_by still runs, just look at this run


PLAY [a2,a1] **

TASK [ping] ***
fatal: [a2]: UNREACHABLE! => {
"changed": false, 
"skip_reason": "Host a2 is unreachable", 
"unreachable": true
}

MSG:

Authentication or permission failure. In some cases, you may have been able to 
authenticate and did not have permissions on the target directory. Consider 
changing the remote tmp path in ansible.cfg to a path rooted in "/tmp". Failed 
command was: ( umask 77 && mkdir -p "` echo 
~/.ansible/tmp/ansible-tmp-1542219116.25-109169561163325 `" && echo 
ansible-tmp-1542219116.25-109169561163325="` echo 
~/.ansible/tmp/ansible-tmp-1542219116.25-109169561163325 `" ), exited with 
result 1


TASK [group_by] ***
ok: [a2] => {
"add_group": "rechable_hosts", 
"changed": false, 
"parent_groups": [
"all"
]
}





-- 
Kai Stian Olstad


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Variable values not being passed to script inside ansible commandline

2018-09-22 Thread Kai Stian Olstad
On Saturday, 22 September 2018 10.09.09 CEST onenessboy wrote:
> 
> Hi Friends,
> 
> Trying to achieve some thing like below with anisble with ansible command 
> line --which will be executed from chatbot
> 
> 
> * ssh into remote box
> * run a script on that remote box using script module with parameters

Why do you spam the developer list with user question?
You have already posted to the user list so this is simply unnecessary 
behaviour.

-- 
Kai Stian Olstad


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Re: shippable failed due to non-replicated code. How can I force re-check ?

2019-07-16 Thread Kai Stian Olstad
On 16.07.2019 20:01, d-little wrote:
> FWIW, I added an 'empty' commit to force the CI.  I'm still wondering if
> there's a better way, but for future explorers that might help.

If you have search the list you would have found this
https://groups.google.com/forum/#!msg/ansible-devel/z3B6Qp3GCag/YCMshG6kAwAJ


-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/f13079b4-491b-2795-9741-b7f98b85de94%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Why is "datacenter" a required parameter for vmware modules?

2019-08-29 Thread Kai Stian Olstad
On 28.08.2019 16:48, MKPhil wrote:
> That's not a datacenter issue - you can have two VMs with the same name in
> the same datacenter but VMWare does not recommend this -
> https://kb.vmware.com/s/article/2108769

I would say it is.
A datacenter is a namespace that makes it possible to have the same name for 
VMs, templates, hosts, clusters, networks and datastores across datacenters. 
But must of them need to be uniq within the datacenter.


> vmware_guest_facts has a "name_match" parameter "If multiple virtual
> machines matching the name, use the first or last found." (see
> https://docs.ansible.com/ansible/latest/modules/vmware_guest_facts_module.html#vmware-guest-facts-module)
> to cater for this but in my opinion (I support over 20,000 vms), you should
> probably really aim to have unique names.

IMHO it's missing the option fail.


-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/5eaa1209-9725-e27c-84f4-c8c1ecbb66a6%40olstad.com.


Re: [ansible-devel] Is changing the default setting of TRANSFORM_INVALID_GROUP_CHARS a good idea?

2019-08-23 Thread Kai Stian Olstad

On 23.08.2019 23:12, Steve Kieu wrote:
Except for the wrong way of using it by dot notation - which is wrong 
in my
opinion as it is not an complex object type (an instance of a class) 
but

simply a dict, there is no reason to use dot notation to access a dict
value.

Python does not allow it, why ansible allows it in the first place.


Ansible uses Jinja, and Jinja allow it
https://jinja.palletsprojects.com/en/2.10.x/templates/#variables


Does it make sense? No, completely not to me. Group name and hostname 
now
is a mess and having different class of specifications, thanks god 
hostname

is still conform with standard to allow hyphen.

Because using hyphen is recommended way for hostname (also DNS)


Hyphen in hostname is not affected by this, just group names since they 
are variables.



--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/df88891d7c18687fe95bbfe81664207f%40olstad.com.


Re: [ansible-devel] Why is "datacenter" a required parameter for vmware modules?

2019-08-27 Thread Kai Stian Olstad
On 27.08.2019 14:38, MKPhil wrote:
> I ask because I've written a module, based on vmware_guest_find, that
> returns the Datacenter for a given VM and VCenter, which I can then feed in
> to the other "official" modules. My module uses the built-in function
> "get_parent_datacenter" (defined in
> https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/vmware.py)
> so I'm not inventing anything particularly new. My point is that if I, an
> amateur Python coder at best, can do this, why can't the official modules
> do it by default?  Is there some reason for the current behaviour that I am
> missing?

If I have two VM both called hostA, one in datacenter-north and one in 
datacenter-south, which one do you choose?


-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/9bf3b8b2-16be-edeb-9535-323d3ac3389f%40olstad.com.


[ansible-devel] Re: [ansible-project] unable to Delete post in GitHub ansible community

2019-09-28 Thread Kai Stian Olstad
On 28.09.2019 20:37, James Cassell wrote:
> On Sat, Sep 28, 2019, at 1:38 PM, Bairava Surya wrote:
>> there are some host names in that post i need to delete it soon am
>> unable to perform any operation on that post
>>
> 
> Here's another example of why locking issues and PRs is annoying.
> 
> (Some companies pay "security" folks to trawl the internet for "internal" 
> information, and then take action against the person who "leaked" it. Been 
> there, experienced that.)
> 
> Hopefully the auto locking can be reconsidered.

If security by obscurity[1] is your last defense, you already lost.
I'm truly are sorry if that is the case, you seriously need to evaluate you 
security model.


[1] https://en.wikipedia.org/wiki/Security_through_obscurity

-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/cfdf9f64-2086-3aae-b770-bdad5362ff41%40olstad.com.