Re: [ansible-project] change root password - ned help

2020-10-27 Thread Sebastian Meyer
Hi Tony,

On Montag, 26. Oktober 2020 18:34:50 CET Tony Wong wrote:
> answer file
> 
> esxi_hostname: '{{ inventory_hostname }}'

^ you are setting esxi_hostname to inventory_hostname.

> esxi_root_user: 'root'
> esxi_root_pass: 'xxx'
> new_esx_local_root_user: 'root'
> new_esx_local_root_pass: 'yyy'
> 
> -
> 
> playbook file
> 
> ---
> - name: "change the root password"
>   hosts: localhost

^ you connect to localhost, so inventory_hostname = localhost

Ansible does not care which hosts are in your inventory, inventory_hostname is 
always the host the task is run on/for.

>   tasks:
> - name: "change root pass"
>   community.vmware.vmware_local_user_manager:
>hostname: " {{ esxi_hostname }}"
>username: " {{ esxi_root_user }}"
>password: " {{ esxi_root_pass }}"
>local_user_name: "{{ new_esx_local_root_user }}"
>local_user_password: "{{ new_esx_local_root_pass }}"
>state: present
>validate_certs: no
> 
> - name: print results
>   debug: msg=" {{ result }}"
>   vars_files:
> - answerfile.yml

try something like:

- hosts: esx
  tasks:
- name: foo
  bar:
baz: blah
  delegate_to: localhost

Then the task should be run once for each host, but always on localhost.

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
´Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4038612.pfi5OA7P3o%40kamino.meyer.b1-systems.de.


signature.asc
Description: This is a digitally signed message part.


Re: [ansible-project] shell

2019-09-09 Thread Sebastian Meyer
On 09.09.19 13:13, Manish Kumar wrote:
> Hi,
> 
> Please help me with this error which I am getting below :
> 
> play-book:
> 
> ---
> - name: Directory creation with current date
>   hosts: local
>   user: manish
>   sudo: yes
> 
>   tasks:
> 
>   - name: Ansible fact - ansible_date_time
>  shell: date.sh
>  args:
>chdir: /home/manish/mk/ansible/linux/
> 
> Error: 
> 
> ERROR! Syntax Error while loading YAML.
>   mapping values are not allowed in this context

Your indentation is incorrect. The last three lines need 2 spaces less
indentation each.

Sebastian

> 
> The error appears to be in '/home/manish/mk/ansible/linux/main.yml': line 
> 10, column 11, but may
> be elsewhere in the file depending on the exact syntax problem.
> 
> The offending line appears to be:
> 
>   - name: Ansible fact - ansible_date_time
>  shell: date.sh
>   ^ here
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6b621bf6-ae5a-d4f0-209a-46d1e3b77b0c%40b1-systems.de.


Re: [ansible-project] if win_chocolatey can install Visual studio community?

2019-08-13 Thread Sebastian Meyer
On 14.08.19 04:49, 舒何伟 wrote:
> " See the log for details 
> (C:\ProgramData\chocolatey\logs\chocolatey.log).",

What does the log say?

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d09632c6-f0e0-822f-6fac-d514616e3d0b%40b1-systems.de.


Re: [ansible-project] I have setup an ansible user that can login with a ssh-key and sudo su - with no password but this appears not to work.

2019-08-13 Thread Sebastian Meyer
Hi Steven,

On 13.08.19 22:34, Steven Mething wrote:
> How do I fault find such an issue?
> 

Ansible doesn't do sudo su -. It does sudo python
/ANSIBLETMP/CURRENTTASK.py or something like that.

Can you show us your sudoers config?

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c49a1a72-c40d-4019-6fba-9989901a88bd%40b1-systems.de.


Re: [ansible-project] using variable from another file

2019-08-06 Thread Sebastian Meyer
On 06.08.19 16:42, Noctis Geek wrote:
> 
> Hello, I would like to know the syntax that would allow me to retrieve the 
> contents of a file and use it to make a variable in a new file in my 
> example I have my YAML configuration file and I have a VARIABLE file and I 
> do not know how to get my first line and make it a variable in my 1st file
> 

See:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#defining-variables-in-files

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4cf0f22f-b2a6-f1b9-229c-f3dca14d79f2%40b1-systems.de.


Re: [ansible-project] Help for variable defination

2019-08-06 Thread Sebastian Meyer
Hi Rahul,

On 01.08.19 14:24, Rahul Kumar wrote:
> HI Ansible Gurus,
> I have a specific snippet of code which i defined in default/main.yaml of a
> role xyz.
> 
> sw_yum_repositories:
>   - name: sw
> description: Dangerous sw
> file: sw-gw
> baseurl: ""
> enabled: no
> gpgcheck: "{{gpgcheckall | default('yes')}}"
> gpgkey: "{{sw_repository_gpgkey | default(gpgkeys) | default('')}}"
> 
> Now I override this variable sw_yum_repostories in my group_vars/all.yml
> in inventory configuration files.  Problem here is : i want to take default
> value of gpgkey attribute here from default/main.yml and other attributes i
> am overriding in group_vars/all.yml .

https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-hash-behaviour

This could work for you. Otherwise you might want to look at setting a
different variable and merge them using set_fact and the combine jinja
filter.

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c055b047-81ad-001f-ec17-ca55df3dde9c%40b1-systems.de.


Re: [ansible-project] Ansible any_errors_fatal does not work as expected. Need Fix

2019-08-06 Thread Sebastian Meyer
Hi,

On 06.08.19 05:29, Mohtashim S wrote:
> So, if I understand you correctly there is no feature to abort the entire 
> playbook run incase of a single error encountered?

There is afaik no feature immediatly aborting the current task for all
hosts, when an error is encountered on a single host. any_errors_fatal
will, as I said and the docs say, stop any further tasks from being
executed on any host.

The way Ansible works here, is for each task:

Send a python script and the data specified to the remote node and
execute it there. The data contains your full loop, it's not transferred
for each item of the loop.

That's done in parallel for X hosts. So Ansible has no reliable way to
stop a task that is already running.

As you can see from my example, in the first playbook, the second task
is not executed for any host, because host abc fails the first task.

If you want your loop to skip all remaining items on that task on that
host once an error has occured you can use my second example. If you add
any_errors_fatal all hosts won't execute any other tasks.

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/64073185-9c7a-28df-f66a-9a5e9d16af7a%40b1-systems.de.


Re: [ansible-project] import_tasks: vs include: when using when: conditional

2019-08-05 Thread Sebastian Meyer
Hi Bob,

On 05.08.19 23:21, Bob Tanner wrote:
> Simple tasks, where I want the "Remote git configuration" task to only be 
> run when  apache2_configuration == 'git'
> 
> I do not understand why import_tasks: or include: is importing/including 
> remote-git.yml when apache2_configuration is not equal to git.
> 
> Any help?
> 

So for me the following happens:

When the when condition is false import_tasks still imports the tasks
file, but skips all tasks in it. include_tasks on the other hand is
skipped as a task itself.

include without the _tasks (which you shouldn't use anymore) behaves a
lot like import_tasks in this case. If you want it to behave like
include_tasks, you'll have to set the static: no option to the include task.

If you look at the documentation, it's in the examples:

https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/utilities/logic/import_tasks.py#L58
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/utilities/logic/include_tasks.py#L70
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/utilities/logic/include.py#L79

Playbook:

---
- hosts: localhost
  roles:
- foobar

Role:

---
# foobar/tasks/main.yml
- debug:
var: config

- import_tasks: foo.yml
  when: config == 'git'

- include_tasks: foo.yml
  when: config == 'nogit'

- debug:
msg: 'End'

---
# foobar/tasks/foo.yml
- debug:
msg: ABCDE




ansible-playbook test.yml -e config=abc

PLAY [localhost] *

TASK [Gathering Facts] ***
ok: [localhost]

TASK [foobar : debug] 
ok: [localhost] => {
"config": "abc"
}

TASK [foobar : debug] 
skipping: [localhost]

TASK [foobar : include_tasks] 
skipping: [localhost]

TASK [foobar : debug] ****
ok: [localhost] => {
"msg": "End"
}

PLAY RECAP [...]

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/03758fba-ed8d-142a-2403-b52dd77189d5%40b1-systems.de.


Re: [ansible-project] Ansible any_errors_fatal does not work as expected. Need Fix

2019-08-05 Thread Sebastian Meyer
Hi

On 05.08.19 18:58, Mohtashim S wrote:
> Ansible any_errors_fatal module does not work as expected. Below is my 
> ansible playbook which is expected to terminate execution as soon as it 
> encounters the first error.

your expectation is wrong. Ansible would execute any task following on
any host. E.g:

---
- hosts: all
  any_errors_fatal: True
  tasks:
- debug:
msg: 'Pseudo Error'
  failed_when: inventory_hostname == 'abc'

- debug:
msg: 'This runs nowhere'

Execution:

PLAY [all] ***
TASK [Gathering Facts] ***
ok: [abc]
ok: [def]

TASK [debug] *
fatal: [abc]: FAILED! => {
"msg": "Pseudo Error"
}
ok: [def] => {
"msg": "Pseudo Error"
}

NO MORE HOSTS LEFT ***

PLAY RECAP ***
abc : ok=1changed=0unreachable=0failed=1skipped=0
rescued=0ignored=0
def : ok=2changed=0unreachable=0failed=0skipped=0
rescued=0ignored=0

---

You could try something like this:

---
- hosts: localhost
  vars:
dirs:
  - /tmp/foo
  - /tmp/foo/bar
  - /tmp/foo/baz/bar
  - /tmp/foo/bar/baz
  - /tmp/foo/abc

  tasks:
- command: "mkdir {{ item }}"
  args:
warn: no
  register: cmd_result
  with_items:
- "{{ dirs }}"
  when:
- not cmd_result is defined or not cmd_result['failed']

Execution:

PLAY [localhost] *

TASK [Gathering Facts] ***
ok: [localhost]

TASK [command] ***
changed: [localhost] => (item=/tmp/foo)
changed: [localhost] => (item=/tmp/foo/bar)
failed: [localhost] (item=/tmp/foo/baz/bar) => {"ansible_loop_var":
"item", "changed": true, "cmd": ["mkdir", "/tmp/foo/baz/bar"], "delta":
"0:00:00.001926", "end": "2019-08-05 19:30:32.876289", "item":
"/tmp/foo/baz/bar", "msg": "non-zero return code", "rc": 1, "start":
"2019-08-05 19:30:32.874363", "stderr": "mkdir: cannot create directory
‘/tmp/foo/baz/bar’: No such file or directory", "stderr_lines": ["mkdir:
cannot create directory ‘/tmp/foo/baz/bar’: No such file or directory"],
"stdout": "", "stdout_lines": []}
skipping: [localhost] => (item=/tmp/foo/bar/baz)
skipping: [localhost] => (item=/tmp/foo/abc)

PLAY RECAP 
localhost : ok=1changed=0unreachable=0failed=1skipped=0
   rescued=0ignored=0


Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d2dcd344-046f-4920-42fd-63aaaf2de29d%40b1-systems.de.


Re: [ansible-project] Ansible for openstack

2019-08-05 Thread Sebastian Meyer
Hi Rahul,

everything is connected to the instance, no? You can't deprovision sec
groups, network stuff or key_pairs while they are in use.

You'll have to remove the instance first.

Regards
Sebastian

On 05.08.19 09:19, Rahul Kumar wrote:
> Hi All,
> I have provisoned one instance with following order in openstack using
> Ansible:
> 1. Download cloud image
> 2. upload cloud image in Openstack
> 3. created key pair
> 4. created network
> 5. created subnet
> 6. created router
> 7. created security group
> 8. created SG rule
> 9. created instance
> 
> and it went successfully. Now i want to remove the resources what order i
> should follow:
> I tried 1 task and it is success
> 1. delete SG rule
> 
> after that i am getting stuck because anything i try to delete , it has
> association with some other resource.
> 
> Help me
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3c5f570b-09ee-0344-0b26-d9bd0d588bc3%40b1-systems.de.


Re: [ansible-project] Ansible For Openstack

2019-08-01 Thread Sebastian Meyer
Hi Rahul,

On 01.08.19 12:19, Rahul Kumar wrote:
> 1. whatever resources(net,subnet,sg,router etc) are provisioned as part of
> this single instance creation , lets say i want to clear all those
> resources in one shot , how can i do this ?

Each module (os_server, os_network ...) should only create the specified
resource. For deprovisioning set the state to absent. One exception
would be e.g. a floating IP automatically assigned to the instance. That
IP isn't assigned anymore afterwards, but still created.

> 2. Does order of tasks matter in playbook. For example: To create instance
> , we need network , so first we will provision network and then other
> dependent resources.

Order matters, yes. Playbooks are run from top down, so the first task
in the list is executed first. Beware that you need a different order
for creation and destruction, afaik you cant remove a network, if theres
still an instance on it.

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/15c36db1-d2bb-536a-3416-5c62b209b96d%40b1-systems.de.


Re: [ansible-project] Ansible For Openstack

2019-08-01 Thread Sebastian Meyer
Hi Rahul,

On 31.07.19 09:36, Rahul Kumar wrote:
> fatal: [localhost]: FAILED! => {"changed": false, "msg": "Cloud mycloud was
> not found."}.
> Notice clouds.yaml and Main Playbook is in same location.

from the module docs:

> Auth information is driven by openstacksdk, which means that values
can come from a yaml config file in /etc/ansible/openstack.yaml,
/etc/openstack/clouds.yaml or ~/.config/openstack/clouds.yaml

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4f9f7229-b0ce-6e5b-4c13-2508d2a25a5a%40b1-systems.de.


Re: [ansible-project] Best way to organize your playbooks

2019-07-31 Thread Sebastian Meyer
On 01.08.19 07:31, Михаил Политаев wrote:
> I have a several projects which describing installation 2 different 
> applications. Each directory for application:
> 
> app1/roles/common/main.yml
> app2/roles/common/main.yml
> 
> But application have similar between them tasks which described in 
> "main.yml" of role "common"
> 
> What is the best way have only one source to those similar tasks without 
> having 2 or more versions and duplicate them across projects.
You could make use of the roles_path configuration setting [0] and have
a directory structure like this:

ansible/
  common/roles/
  app1/roles/
  app2/roles/

and in the app folders each an ansible.cfg with:

roles_path: ./roles:../common/roles

[0]
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-roles-path

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8f7c5bb5-aaa6-4de2-7031-c0cdd4a538db%40b1-systems.de.


Re: [ansible-project] The destination directory (/sys/module/nvme_core/parameters) is not writable by the current user

2019-07-29 Thread Sebastian Meyer
Hi Joe,

On 29.07.19 22:29, Joe Langdon wrote:
> I am using an Ansible Role to copy a template file. It is not allowing me 
> saying.. "The destination directory (/sys/module/nvme_core/parameters) 
> is not writable by the current user"

> I am not sure how to proceed at this point. I have close to 100 servers 
> with this issue and it is causing some intermittent outages (apparently 
> this is a known issue with AWS NVME) Thanks for your thoughts in advance 

so the problem is, /sys is a virtual file system. You (afaik) can't
remove files from it.

What Ansible does is creating a temporary file with the desired content
and moving it to the destination. And moving implies first removing the
original file. The following won't work either:

echo 40 > /tmp/io_timeout
mv /tmp/io_timeout /sys/module/nvme_core/parameters/io_timeout

The correct solution would be setting the nvme.io_timeout kernel
parameter in /etc/default/grub, regenerating grub config and rebooting.

The easy solution would be something like:

- name: Get nvme.io_timeout value
  command: /bin/cat /sys/module/nvme_core/parameters/io_timeout
  register: nvme_current_timeout
  changed_when: false

- name: Set nvme.io_timeout value
  shell: "echo {{ nvme_target_timeout }} >
/sys/module/nvme_core/parameters/io_timeout"
  when: nvme_current_timeout.stdout|int != nvme_target_timeout|int

Regards,
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/df1aed4f-6cf7-f9c7-3a05-1e5b10b0222e%40b1-systems.de.


Re: [ansible-project] Variable registration is getting skipped in zypper module

2019-06-13 Thread Sebastian Meyer
Hi,

On 13.06.19 23:50, Bobby Hood wrote:
>"cmd": [ 
>"/usr/bin/zypper",  
>"--quiet",  

the ansible zypper module calls zypper with --quiet, as you can check on
the commandline that leads to zypper not writing to stdout, if there's
nothing to do:

# zypper update
Loading repository data...
Reading installed packages...

Nothing to do.
#
# zypper --quiet update
#

As this is hardcoded in the module, there's no easy way around this. It
should give you output once there are packages to update:

# zypper --quiet --non-interactive up

The following 6 NEW packages are going to be installed:
  dbus-1 kbd kmod pinentry pkg-config udev

The following 56 packages are going to be upgraded:
  aaa_base acl bash blog ca-certificates-mozilla cpio file [...]

The following product is going to be reinstalled:
  "openSUSE Leap 42.3"

56 packages to upgrade, 6 new.
Overall download size: 27.8 MiB. Already cached: 0 B. After the operation,
additional 12.4 MiB will be used.
Continue? [y/n/...? shows all options] (y): y

Regards
-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/9b9731f9-f099-7e15-b48a-28ea858eda9f%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible iterate from file and populate template

2019-06-13 Thread Sebastian Meyer
Hi Nicola,

On 13.06.19 15:06, Nicola Contu wrote:
> As I have too many vhosts to be created, I got a file from where I would 
> like to read content, iterate it, populate variables and push the file.
> 
> The file is like this :
> 5;yyy;y
> 70;;zzz
> 
> I can modify the file to include the header, to be , delimited.. whatever. 

Since this is basically a CSV file, you might have a look at the
read_csv module.

https://docs.ansible.com/ansible/latest/modules/read_csv_module.html

This is only available in Ansible 2.8 though, for older versions you
might use the csvfile lookup.

https://docs.ansible.com/ansible/latest/plugins/lookup/csvfile.html

Regards
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/51ca1b5c-84dc-6b52-8d5a-221b44725d1a%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] add list from host variables and group variables

2019-05-27 Thread Sebastian Meyer
Hi Marc,

On 25.05.19 20:42, Marc Haber wrote:
> this is what I have in a YAML formatted inventory
> 
> ---
> all:
>   vars:
> city:
>   - Berlin
>   children:
> g_empty:
>   hosts:
> emptybuster:
> emptysid:
> emptystretch:
>   city:
> - Steglitz
> 
> Is there a more elegant way to do this, or have I reached ansible's
> limits? If so, is there a bug report against ansible where I could read
> up on the situation?

Well, Ansibles variable system isn't as featureful as e.g. hiera and
works mostly with overwrites.

I see two possibilities here:

1. Using the a lookup plugin, not inventory variables, e.g. hiera since
it supports all kinds of merging

https://docs.ansible.com/ansible/latest/plugins/lookup/hiera.html

2. Use a different name for the variables and use set_fact in your
playbook/a role to merge them.

---
all:
  vars:
_city_all:
  - Berlin
  children:
g_empty:
  hosts:
emptystretch:
  city:
- Steglitz


---
- hosts: all
  pre_tasks:
- set_fact:
city: "{{ _city_all + city | default([]) }}"
  tasks:
- debug:
var: city


HTH,
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/bbaa6af3-5406-a10d-0ed4-f1fa9ddd8644%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Default filter issue

2019-05-14 Thread Sebastian Meyer
On 14.05.19 09:23, Daniel Vašek wrote:
> Hello,
> 
> Im trying to use default filter:
> 
> hosts: ["{{ groups['examples'][0] | default('localhost') }}":5045]
> 

You should be able to use: groups.examples.0 | default(...)

This is the one case where dot notation is simpler/better :)

Sebastian

> 
> But it return error:
> 
> 
> FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict 
> object' has no attribute 'examples'"}.
> 
> 
> I read something about default can use only 1 level deep, but I cannot 
> write more levels properly.
> 
> 
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/f4953f3c-b75d-d2d4-09a6-30313f391e4f%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] ERROR! Syntax Error while loading YAML. mapping values are not allowed in this context

2019-05-03 Thread Sebastian Meyer
On 03.05.19 11:38, op...@netexpress.de wrote:
>   -name: postfix - set debconf defaults before postfix install

You are missing a space here between the hyphen and name.

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/5e43ad07-b7a5-d246-61a6-4acf9aa15d1a%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] i can't list hard disk info

2019-05-02 Thread Sebastian Meyer
On 02.05.19 13:14, Jean-Yves LENHOF wrote:
>> and the result is:
>>
>> ok: [host1] => {
>> "msg": {
>> "0": {
>>     "backing_datastore": "datastore1",
[...]
>> },
>> "1": {
>>     "backing_datastore": "datastore1",
[...]
>> }
>>     }
>> }
>>
>> Good, i need second ("1") hard disk info, but when im use variable
>> disk_facts.guest_disk_facts.1 the result is:
>>
>> fatal: [host1]: FAILED! => {"msg": "The task includes an option with
>> an undefined variable. The error was: dict object has no element
>> 1\n\nThe error appears to have been in
>> '/root/playbook/operations/ListVMvalues.yml': line 50, column 7, but
>> may\nbe elsewhere in the file depending on the exact syntax
>> problem.\n\nThe offending line appears to be:\n\n\n    - debug:\n     
>> ^ here\n"}
>>
>> What I do?
> 
> 
> Hi,
> 
> Try with disk_facts.guest_disk_facts[1]instead...

disk_facts.guest_disk_facts.1 and disk_facts.guest_disk_facts[1]

both expect disk_facts.guest_disk_facts to be a list, but it's a dict.

You'll need disk_facts.guest_disk_facts['1']

Notice the ''.

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/83b66866-98db-9691-c4f6-6a917b75e763%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] pip install docker-compose

2019-04-10 Thread Sebastian Meyer
Ah I saw you have docker-py installed globally and installed docker for
your user with pip?

https://github.com/ansible/ansible/issues/37958#issuecomment-376320961

Seems like there's a problem with having both.

Sebastian




On 10.04.19 15:21, Andrew Meyer wrote:
> Any other thoughts?
> 
> On Tuesday, April 9, 2019 at 4:15:09 PM UTC-5, Andrew Meyer wrote:
>>
>> Root is using the same version.  Also I stopped doing that as root.
>>
>> [ameyer@awx01 ~]$ python
>> Python 2.7.5 (default, Oct 30 2018, 23:45:53) 
>> [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> import compose
>>>>> exit()
>> [ameyer@awx01 ~]$ 
>>
>>
>>
>> On Tuesday, April 9, 2019 at 4:09:16 PM UTC-5, Sebastian Meyer wrote:
>>>
>>> On 09.04.19 22:51, Andrew Meyer wrote: 
>>>> [ameyer@awx01 ~]$ pip --version 
>>>> pip 19.0.3 from /usr/lib/python2.7/site-packages/pip (python 2.7) 
>>>> [ameyer@awx01 ~]$ ansible localhost -m setup|grep 
>>> ansible_python_version 
>>>>  [WARNING]: provided hosts list is empty, only localhost is available. 
>>> Note 
>>>> that the implicit localhost does not match 'all' 
>>>> "ansible_python_version": "2.7.5", 
>>>> [ameyer@awx01 ~]$ 
>>> Okay so it seems they are using the same python version. Does executing 
>>> python and importing compose work? 
>>>
>>> $ python 
>>> Python 2.7.14 (default, Oct 12 2017, 15:50:02) [GCC] on linux2 
>>> Type "help", "copyright", "credits" or "license" for more information. 
>>>>>> import compose 
>>>>>>
>>>
>>> I noticed you executed the installer playbook with root. Could you check 
>>> pip and ansible_python_version there too? Just to be sure there's no 
>>> mixup there. 
>>>
>>> Regards 
>>> Sebastian 
>>>
>>> -- 
>>> Sebastian Meyer 
>>> Linux Consultant & Trainer 
>>> Mail: me...@b1-systems.de 
>>>
>>> B1 Systems GmbH 
>>> Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de 
>>> GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 
>>>
>>
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/e539b6a5-4779-232d-ebab-070ed0fd482c%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to capture/filter stdout_lines

2019-04-09 Thread Sebastian Meyer
On 10.04.19 04:38, Saranya N wrote:
> Stdout_lines that I get contains strings , json in different lines.
> 
> I want to capture the last line and copy those contents to a a new Json file.
> 
> How do I capture the last line from the registered variable.
> 
> I tried this and it didn't work.
> 
> "{{ Regvar.stdout_lines | last }}"

Try

{{ regvar.stdout_lines[-1] }}

> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/1fbac0ec-8f58-28f5-6d6f-27e0ac952a39%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] pip install docker-compose

2019-04-09 Thread Sebastian Meyer
On 09.04.19 22:51, Andrew Meyer wrote:
> [ameyer@awx01 ~]$ pip --version
> pip 19.0.3 from /usr/lib/python2.7/site-packages/pip (python 2.7)
> [ameyer@awx01 ~]$ ansible localhost -m setup|grep ansible_python_version
>  [WARNING]: provided hosts list is empty, only localhost is available. Note 
> that the implicit localhost does not match 'all'
> "ansible_python_version": "2.7.5", 
> [ameyer@awx01 ~]$ 
Okay so it seems they are using the same python version. Does executing
python and importing compose work?

$ python
Python 2.7.14 (default, Oct 12 2017, 15:50:02) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import compose
>>>

I noticed you executed the installer playbook with root. Could you check
pip and ansible_python_version there too? Just to be sure there's no
mixup there.

Regards
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/35009569-d264-77f0-beca-b6e39ba4ad6b%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] pip install docker-compose

2019-04-09 Thread Sebastian Meyer
Hi Andrew,

what's the output of

pip --version

and

ansible localhost -m setup | grep ansible_python_version

Regards
Sebastian

On 09.04.19 21:26, Andrew Meyer wrote:
> I seem to be having an issue when trying to run this playbook for building 
> AWX.
> 
> When I go to run the ansible playbook I get the following error:
> 
> "ok: [localhost] => (item=environment.sh)", 
> "ok: [localhost] => (item=credentials.py)", 
> "ok: [localhost] => (item=docker-compose.yml)", 
> "", 
> "TASK [local_docker : Render SECRET_KEY file] 
> ***", 
> "ok: [localhost]", 
> "", 
> "TASK [local_docker : Start the containers] 
> *", 
> "fatal: [localhost]: FAILED! => {\"changed\": false, \"msg\": 
> \"Unable to load docker-compose. Try `pip install docker-compose`. Error: 
> cannot import name ImageNotFound\"}", 
> "\tto retry, use: --limit @/root/awx/installer/install.retry", 
> "", 
> "PLAY RECAP 
> *", 
> "localhost  : ok=8changed=0unreachable=0
> failed=1   "
> ]
> }
> 
> I was getting errors about docker-compose installation prior and tried 
> installing the specific version the playbook calls for:
> pip freeze|grep -i docker
> DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 
> 2020. Please upgrade your Python as Python 2.7 won't be maintained after 
> that date. A future version of pip will drop support for Python 2.7.
> docker-compose==1.22.0
> docker-py==1.10.6
> docker-pycreds==0.4.0
> dockerpty==0.4.1
> 
> 
> I'm not sure why this is not working.  I am running this against the 
> localhost.
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/8860cd05-4f51-6b03-8974-56485718e857%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Execut playbook host after host

2019-04-08 Thread Sebastian Meyer
On 08.04.19 11:40, ryad9200...@gmail.com wrote:
> I want that when i run my task, ansible execute only on my_host_1
> and when ansible fish execut task, he execut in second host of my inventory 
> "my_host_2"
> 
> Someone have an idea please ?

https://docs.ansible.com/ansible/latest/user_guide/playbooks_delegation.html#rolling-update-batch-size

Use `serial: 1`

HTH,
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/c4744dbe-a332-7c6f-fcad-4c0906e94e5e%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] open(module, 'wb') SyntaxError for raw module in ansible-playbook

2019-04-04 Thread Sebastian Meyer
On 04.04.19 17:59, Henry Iracheta wrote:
> Here is an example of the playbook being tested:
> 
> - hosts: servers
>   remote_user: x
>   tasks:
>   - name: simply test to confirm playbook works
> raw: /bin/hostname
> 
> > Any suggestions on how to work around this issue ?


You need to set gather_facts to no. gather_facts uses the setup module,
which is Python.

- hosts: servers
  gather_facts: no
  tasks:
[...]


Sebastian

> 
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/1bc1dd8e-001a-b4aa-dee6-8cac35907ce5%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] how to access debug stdout variable

2019-04-03 Thread Sebastian Meyer
On 03.04.19 16:44, Kunalsing Thakur wrote:
> Hi sebastian,
> when i try to fail the task with this below condition i get the error in 
> task
> 
> *failed_when: pulp.results.0.stdout == "\e[0m"*
> 
> TASK [mobi_ansible_role_pulp : searching the rpm into pulp repo] 
> *
> task path: /etc/ansible/roles/mobi_ansible_role_pulp/tasks/pulp.yaml:4
> Wednesday 03 April 2019  14:40:58 + (0:00:01.856)   0:00:06.231 
> ***
> fatal: [inplp01p2.infra.smf1.mobitv]: FAILED! =>
>   msg: 'The conditional check ''pulp.results.0.stdout == "\e[0m"'' failed. 
> The error was: error while evaluating conditional (pulp.results.0.stdout == 
> "\e[0m"): ''dict object'' has no attribute ''results'''

While you are in the loop you should be able to use just pulp.stdout,
only afterwards the results are merged.

Sebastian

> 
> 
> On Wednesday, April 3, 2019 at 8:01:59 PM UTC+5:30, Sebastian Meyer wrote:
>>
>> On 03.04.19 16:22, Kunalsing Thakur wrote: 
>>> --- 
>>> - name: Logging into pulp 
>>>   shell: pulp-admin login -u admin -p admin 
>>> - name: searching the rpm into pulp repo 
>>>   shell: pulp-admin rpm repo content rpm --repo-id=mobi-snapshots 
>> --match 
>>> 'filename={{ item }}' 
>>>   with_items: "{{ rpmname | default([]) }}" 
>>>   register: pulp 
>>>   when: rpmsearch is defined 
>>
>> You are using register with a loop. That means pulp.results is a list 
>> and there's an element for each item in that list. 
>>
>> You can access the stdout for the first item with pulp.results.0.stdout 
>>
>> Sebastian 
>> -- 
>> Sebastian Meyer 
>> Linux Consultant & Trainer 
>> Mail: me...@b1-systems.de  
>>
>> B1 Systems GmbH 
>> Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de 
>> GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 
>>
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/0749a574-c80b-a765-72c9-928842320e95%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] how to access debug stdout variable

2019-04-03 Thread Sebastian Meyer
On 03.04.19 16:22, Kunalsing Thakur wrote:
> ---
> - name: Logging into pulp
>   shell: pulp-admin login -u admin -p admin
> - name: searching the rpm into pulp repo
>   shell: pulp-admin rpm repo content rpm --repo-id=mobi-snapshots --match 
> 'filename={{ item }}'
>   with_items: "{{ rpmname | default([]) }}"
>   register: pulp
>   when: rpmsearch is defined

You are using register with a loop. That means pulp.results is a list
and there's an element for each item in that list.

You can access the stdout for the first item with pulp.results.0.stdout

Sebastian
-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/d0544de0-7767-8996-9d83-c037b4307869%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Check Number Of Wheel Group Members

2019-04-02 Thread Sebastian Meyer
On 02.04.19 19:50, Jon Adcock wrote:
>that: getent_group.wheel|default(["", "", ""])[2] == ""

You'll need () around the getent and default:

that: (getent_group.wheel|default(["", "", ""]))[2] == ""

The above should work.

Sebastian
-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/750f0cef-9d55-4fab-be0a-2641adf08616%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Edit playbook to work with Packer Ansible Provisioner

2019-04-02 Thread Sebastian Meyer
On 02.04.19 20:10, gigit1...@gmail.com wrote:
> 
> 
> Hello, 
> 
> I’m trying to call a playbook from Packer for the first time. I’m using the 
> Packer Ansible provisioner. The documentation says that Packer will 
> “dynamically create an inventory file to use with the playbook” If this is 
> the case, How should I edit my playbook? As it is now it has a “hosts” 
> entry - should I just remove that? 

Use hosts: all

Packer only makes the one host available in the inventory.

Sebastian

> It looks like:
> 
> - hosts: ec2lin
> 
>   remote_user: ec2-user
> 
>   become: yes
> 
>   become_user: root
> 
>   tasks:
> 
>   - name: run yum update -y using yum module
> 
> yum:
> 
>   name: "*"
> 
>   state: latest
> 
> Thank You much for any help
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/e79621a5-d86e-0f6c-d3a6-69a6035bf593%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Memory error when downloading 3.4GB file

2019-03-28 Thread Sebastian Meyer
Hi,

On 29.03.19 00:55, Sindhuja Koneru wrote:
> '"'"'/usr/bin/python 
> /root/.ansible/tmp/ansible-tmp-1553783711.94-90505061625143/slurp.py && 
> sleep 0'"'"''

Any reason you are using slurp and not fetch?

slurp reads the whole file into memory, afterwards it does base64
encoding still in memory, and then transfers the content.

This is basically what happens in slurp:

---
$ python
Python 2.7.14 (default, Oct 12 2017, 15:50:02) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
>>> import os
>>> with open('/isos/rhel-server-5.11-x86_64-dvd.iso', 'rb') as source:
...   source_content = source.read()
...
>>> data = base64.b64encode(source_content)
>>>
---

My testfile is a 4.2GB and ram usage for that single python process goes
up to 12.5GB before settling at 9.7GB.

So you might not have enough RAM on the system you're slurping the
file from.

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/31cc4d14-b626-8eaf-18ef-5a73dfd9c832%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Run script that requires 'sudo' on remote hosts.

2019-03-28 Thread Sebastian Meyer
Hi,

On 28.03.19 14:49, R-JRI wrote:
> TASK [Gathering Facts] 
> **
> fatal: [host1]: FAILED! => {"changed": false, "module_stderr": "Shared 
> connection to host1 closed.\r\n", "module_stdout": "Sorry, user appsadmin 
> is not allowed to execute '/bin/sh -c echo 
> BECOME-SUCCESS-fxdiujleiigrbgciqkixarzuxhsbngrr; /usr/bin/python 
> /u/appadmin/.ansible/tmp/ansible-tmp-1553780641.69-82349845573466/AnsiballZ_setup.py'
>  
> as root on host1.\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the 
> exact error", "rc": 1}

If the user you use with ansible is only allowed to execute this script
with sudo and not use sudo for ALL, then you are right to use

command: sudo /usr/local/bin/application_stop_start.sh stop

You may want to add

warn: no

See:
https://docs.ansible.com/ansible/latest/modules/command_module.html?highlight=warn

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/989902cd-8f69-d1fd-5ea6-3bc945903289%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Nmcli module static routes

2019-03-28 Thread Sebastian Meyer
On 27.03.19 21:05, anil kumar wrote:
> I mean using nmcli module, I was able do with nmcli command.
> 

It's not possible yet. I opened a PR for that:
https://github.com/ansible/ansible/pull/54491

Sebastian

> On Monday, March 25, 2019 at 6:43:23 PM UTC+1, anil kumar wrote:
>>
>> Hi, 
>>
>> Dont see any documentation regarding adding static routes using nmcli 
>> modules. Is it feasible to add static routes, if yes please let me know and 
>> sample example would help.
>>
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/ede2bc17-d112-f91d-80e6-f48ceeca2346%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Run script that requires 'sudo' on remote hosts.

2019-03-27 Thread Sebastian Meyer
On 27.03.19 21:29, R-JRI wrote:
> I don't need 'become' and 'become_user' at least since the UID is the same. 
> Tried to use 'become_method = sudo' and remove 'sudo' from 'command: 
> /usr/local/bin/application_stop_start.sh stop' and it did not work. Does 
> anyone have any suggestions? 
> Thanks.

You still need `become: true`, since you want to _become_ root executing
this script. Just setting the become_method to sudo won't do anything.

Sebastian

> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/8a47dd0b-ffb3-f60d-bbc7-a7285761e41e%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] yum module gives "AttributeError: 'list' object has no attribute 'strip'" on list of items

2019-03-27 Thread Sebastian Meyer
Hi Robin,

On 27.03.19 17:16, Robin Roevens wrote:
> Hi all
> 
> I'm currently trying to get rid of all deprecation warnings as we upgraded 
> Ansible 2.3 to 2.7.9 (CentOS 7.4)
> And I have this code:
> 
> - name: Install required system packages
>   yum:
> name: "{{ item }}"
> state: 'present'
>   with_items:
> - "{{ base_packages }}"
> - "{{ additional_packages | d(omit) }}"

Assuming base_packages and additional_packages are lists, try:

- name: install pkgs
  yum:
state: present
name: "{{ base_pkgs + additional_pkgs | default([]) }}"

Ansible wants a flat list here. The suggestion in the deprecation
warning thinks both are just normal values and wants you to put them
into a list.

But if you already have lists, merge them with + as in the above code.

HTH,
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/5560e97b-8eae-16b4-c4c7-63377eb6f134%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible modules copy/template errors for Linux 5 hosts using python26 ,python binding libselinux-python needed

2019-03-27 Thread Sebastian Meyer
Hi Prakash,

you have three options here:

1) disable selinux in /etc/selinux/config

Then you don't need libselinux-python at all

2) use ansible <= 2.3 for management of the RHEL 5 systems

Then you still can use python 2.4 provided by RHEL 5

3) build libselinux-python for python2.6 yourself

THIS PROBABLY VOIDS YOUR SUPPORT FROM RED HAT, so I wouldn't recommend this.

This one requires all your RHEL 5 servers to have the same version of
SELinux and you'll probably want to build this in a chroot or on a
dedicated build host.

The steps would be

* enable the source repo
* download and install the source rpm for libselinux
* install the build dependencies (and python26-devel)
* change the spec file so the resulting python package is not called
libselinux-python but libselinux-python26
* link /usr/bin/python to /usr/bin/python26
* build the new rpms

You should be able to only install the libselinux-python26 package (as
you didn't change the version of anything else) alongside the normal
libselinux-python from redhat.

Then ansible with ansible_python_interpreter=/usr/bin/python26 would
pick up the self-built libselinux-python26 and everything else should
still be using the system libselinux-python.

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/d9773068-ef7a-a44d-eddf-e4290541e0bb%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] debug statement not working

2019-03-26 Thread Sebastian Meyer
Hi Jerry,

On 25.03.19 18:12, Jerry Seven wrote:
> ok: [hostname] => {
> "msg": [

^ the [ tells you this is an array. This happens because you call
register on a task with a loop. For each item of the loop, a new dict
gets added to this array.

> {
> "_ansible_ignore_errors": null,
> "_ansible_item_result": true,
> "_ansible_no_log": false,
> "_ansible_parsed": true,
> "changed": true,
> "cmd": "rpm -q TaniumClient",
> "delta": "0:00:00.024756",
> "end": "2019-03-25 13:10:34.751439",
> "failed": false,
> "invocation": {
> "module_args": {
> "_raw_params": "rpm -q TaniumClient",
> "_uses_shell": true,
> "chdir": null,
> "creates": null,
> "executable": null,
> "removes": null,
> "stdin": null,
> "warn": true
> }
> },
> "item": "TaniumClient",
> "rc": 0,
> "start": "2019-03-25 13:10:34.726683",
> "stderr": "",
> "stderr_lines": [],
> "stdout": "TaniumClient-6.0.314.1442-1.rhe7.x86_64",
> "stdout_lines": [
> "TaniumClient-6.0.314.1442-1.rhe7.x86_64"
> ]
> },
> 
> 
> but
> 
> - debug:
> msg: "{{ pkg.results.stdout }}"
> 
> fails.  Seems like I should be able to print that.

You could print {{ pkg.results.0.stdout }} for the first element of the
loop, or {{ pkg.results.1.stdout }} for the second element of the loop.


> I just dont understand why it works:
>
> - debug:
>   msg: "{{ echo.results|map(attribute='stdout_lines')|list
> }}"

What this does is, take the array of dictionaries, and look in each
dictionary for the key stdout_lines. Then take the value of that key and
make a list out of it.

HTH
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/bf837057-c1bc-ce1f-0b8e-a2e24c94044b%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Limiting hosts when including playbooks

2019-03-26 Thread Sebastian Meyer
On 26.03.19 13:01, 'Uffi Schnuffi' via Ansible Project wrote:
> This is no longer working with the new `import_playbook` module.
> 
> Is there a recommended way to achieve this (i.e. limiting hosts for an 
> imported playbook?). I have not found a way as of yet.

---
- import_playbook: test.yaml
  vars:
myhosts: plonk

---
- name: Test playbook
  hosts: all:&{{ myhosts }}
  tasks:
 - name: test var
   debug:
   msg: "GOOO"


works for me.

See:
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.7.html#include-tasks-import-tasks-inline-variables

Sebastian


> 
> 
> On Friday, February 1, 2013 at 5:06:49 PM UTC+1, Lorin Hochstein wrote:
>>
>>
>> On Fri, Feb 1, 2013 at 11:02 AM, Daniel Hokka Zakrisson > > wrote:
>>
>>> Lorin Hochstein wrote:
>>>> That approach works for limiting hosts when calling from the 
>>> command-line,
>>>> but I'd like to do it from inside of a playbook. One of the motivations 
>>> is
>>>> what Michael suggests in that original posting:
>>>>
>>>> "The same as the above example could be used with --limit stage or 
>>> --limit
>>>> production to control inventory.   I really don't recommend this though,
>>>> because leaving off limit would be pretty dangerous."
>>>>
>>>> If I want to limit execution of a playbook to staging servers, I worry
>>>> about somebody forgetting the "--limit" flag. I'd prefer to do have a
>>>> separate playbook, say "update-staging.yaml", that looks like this:
>>>>
>>>> - include: update.yaml hosts=staging
>>>>
>>>> Unfortunately, that doesn't work. Right now I'm using a makefile to 
>>> invoke
>>>> my ansible playbooks to achieve this functionality, but I find that
>>>> un-ansible-ish.
>>>>
>>>> Michael, would you accept merges that implemented this sort of host
>>>> filtering on include statements? Would work the same as --limit on the
>>>> command-line except it would be an argument to include.
>>>
>>> hosts: is already templateable with include arguments, so you could do
>>> hosts: webservers:&$hosts
>>> I think this will also lead to an error if you don't specify hosts, 
>>> instead
>>> of running against all of it.
>>>
>>>
>> Cool, that works. For anybody who hits this via google, here's a complete 
>> example:
>>
>> ping.yaml:
>>
>> - hosts: webservers:&$hosts
>>   tasks:
>>- name: ping the hosts
>>  action: ping
>>
>> pong.yaml:
>>
>> # Just ping the staging server
>> - include: ping.yaml hosts=staging
>>
>>
>>
>> This is a useful pattern, where's a good place to document this? 
>>
>> Lorin
>>
>>
>>  
>>
>>> Daniel
>>>
>>>>  Not sure what to call it (limit, limit-hosts, hosts)?
>>>>
>>>>
>>>> Lorin
>>>>
>>>>
>>>> On Fri, Feb 1, 2013 at 12:55 AM, Yeukhon Wong >> >
>>>> wrote:
>>>>
>>>>> I think you can try this
>>>>>
>>>>>
>>> https://groups.google.com/forum/#!msg/ansible-project/qfoeqytbRE4/SI58rlzeEwMJ
>>>>>
>>>>> If you ever need some exception (all in this group except XX) you can
>>>>> use
>>>>> hosts: group1:!except_this_group
>>>>>
>>>>>
>>>>> On Thursday, January 31, 2013 11:26:22 PM UTC-5, Lorin Hochstein wrote:
>>>>>>
>>>>>> When including a playbook in another playbook, is there any way to
>>>>>> limit
>>>>>> the hosts in the child playbook?
>>>>>>
>>>>>> For example, if I had an existing playbook (e.g.,
>>>>>> "configure-widget.yaml") that had its hosts set to "webservers", and I
>>>>>> wanted to write a playbook that only applied to the staging web 
>>> server,
>>>>>> is
>>>>>> there any way to do something like:
>>>>>>
>>>>>> - include: configure-widget.yaml limit-hosts=staging
>>>>>>
>>>>>>
>>>>>> Lorin
>>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>

Re: [ansible-project] command scp in ansible

2019-03-22 Thread Sebastian Meyer
Hi,

On 22.03.19 18:28, Brian Coca wrote:
> The copy module uses the transfer mechanism from the 'connection
> plugin', which, if using ssh CAN be scp, but it also tries sftp and dd
> by default, but you can control this via configuration (see scp_if_ssh
> setting).

I see that setting, but I'm not sure how it works with the copy module.
The copy module itself seems to only call Pythons shutil.copy* which
works on local paths.

At what point does the src file get transferred to the remote host? If
someone could point me at the file/function doing that, that'd be great.

- Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/2f3c48d7-c397-84e8-88b8-0971ed978a92%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] command scp in ansible

2019-03-22 Thread Sebastian Meyer
On 22.03.19 13:47, ryad9200...@gmail.com wrote:
> Hi all,
> 
> I must use scp in ansible, i know module synchronize, copy but i d'ont find 
> the module scp.
> There is junos_scp but i d'ont know how he works :/
> 
> Is there a way to transfer files or directories by scp as the command linux 
> scp -rp

Not via a module. You'll need to use command for that.

- Sebastian

> 
> Thanks community ansible !! ;)
> 
> Regards,
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Tel.: +49-172-2057471
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/b0633af8-751b-6c6f-5ce6-a83064bc3156%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Using defaults for Ansible user module for for "home", "group" and "groups"

2019-03-22 Thread Sebastian Meyer
On 22.03.19 12:26, Suhail Choudhury wrote:
> Sorry I meant I've tried something like:
> 
> group: "{{ (item.group) | default('[]') }}"
> 

Try default(omit), that'd just not set the parameter if item.group isn't
defined.

- Sebastian

> but no joy as Ansible throws the error that "Group "" does not exist".
> 
> If I try
> 
> group: "{{item.group if item.group is defined else item.username }}"
> 
> then Ansible fails with the group does not exist.
> 
> Whereas the default without specifying is that it creates it as the 
> username.
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/135e0c26-3c4b-6b00-3bfc-4d9da52cf66d%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Need help with how to grab public ip and use it for later part in playbook

2019-03-22 Thread Sebastian Meyer
t; "attachment": {
>> "attach_time": "2019-03-21T18:28:03+00:00", 
>> "attachment_id": "eni-attach-xx", 
>> "delete_on_termination": true, 
>> "device_index": 0, 
>> "status": "attached"
>> }, 
>> "description": "", 
>> "groups": [
>> {
>> "group_id": "sg-xx", 
>> "group_name": "xx"
>> }
>> ], 
>> "ipv6_addresses": [], 
>> "mac_address": "xx:66:xx:77:d4:f4", 
>> "network_interface_id": "eni-xxx", 
>> "owner_id": "xx", 
>> "private_dns_name": 
>> "ip-xxx8.us-east-2.compute.internal", 
>> "private_ip_address": "1xx", 
>> "private_ip_addresses": [
>> {
>> "association": {
>> "ip_owner_id": "amazon", 
>> "public_dns_name": "
>> ec2-xx-xxx-xxx-xx.us-east-2.compute.amazonaws.com", 
>> "public_ip": "18.x.xx.xx
>> }, 
>> "primary": true, 
>> "private_dns_name": 
>> "xx.us-east-2.compute.internal", 
>> "private_ip_address": "xx"
>> }
>> ], 
>> "source_dest_check": true, 
>> "status": "in-use", 
>> "subnet_id": "subnet-", 
>> "vpc_id": "vpc-x"
>> }
>> ], 
>>     "placement": {
>> "availability_zone": "us-east-2c", 
>> "group_name": "", 
>> "tenancy": "default"
>> }, 
>> "private_dns_name": "xxx.us-east-2.compute.internal", 
>> "private_ip_address": "xxx.xx.xx.xx", 
>> "product_codes": [], 
>> "public_dns_name": "
>> xxx.us-east-2.compute.amazonaws.com", 
>> "public_ip_address": "xx.xxx.44.51", 
>> "root_device_name": "/dev/xvda", 
>> "root_device_type": "ebs", 
>> "security_groups": [
>> {
>> "group_id": "sg-", 
>> "group_name": "xx"
>> }
>> ], 
>> "source_dest_check": true, 
>> "state": {
>> "code": 64, 
>> "name": "stopping"
>> }, 
>> "state_reason": {
>> "code": "Client.UserInitiatedShutdown", 
>> "message": "Client.UserInitiatedShutdown: User 
>> initiated shutdown"
>> }, 
>> "state_transition_reason": "User initiated (2019-03-21 
>> 19:33:16 GMT)", 
>> "subnet_id": "subnet-xxx", 
>> "virtualization_type": "hvm", 
>> "vpc_id": "vpc-"
>> }
>> ]
>> }
>> }
>>
>>
>> i want to use debug option in playbook  to print only the public ip 
>>
>> ec2.instances.public_ip is not working 
>>
>>
>>
>>
>> can anyone please help
>>
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/9cf59193-cb49-f77f-2df5-a031b0db903c%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] user_module and ssh key

2019-03-22 Thread Sebastian Meyer
On 22.03.19 07:51, Alexander B. wrote:> Hello.
> There are two hosts. On first I create a user and generate SSH keys.
Now I
> need to transfer private key to second host to connect using it to first
> host without creating a user on second. I haven't found an output of
> parameter ssh_key as analogg to ssh_public_key in module user. In other
> modules related to SSH there is only a possibility to see contents of
> public key. What is the reason for this restriction?
Because the private key should be _private_ and not be transferred
around the network.

If you need to be able to login from host2 to host1, you need to
generate a ssh keypair on host2, (either using the user module or
command module), fetch the contents of the public key, and use the
authorized_key module to put the public key into the authorized_keys
file for the user.

>
> The documentation
> <https://docs.ansible.com/ansible/latest/modules/user_module.html> is
> written about the path to the ssh public key. in the example of a private
> key.
>
> ssh_key_file  Path to generated SSH public key file. *Sample*:
> /home/asmith/.ssh/id_rsa
That one is a bug in the docs, it's fixed in the devel docs:

https://docs.ansible.com/ansible/devel/modules/user_module.html

- Sebastian

>
-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/fcf44d3a-f871-a37e-f9d8-9674d5a48c79%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Need help with how to grab public ip and use it for later part in playbook

2019-03-21 Thread Sebastian Meyer
On 21.03.19 22:48, tinkuchowdar...@gmail.com wrote:> here is the dubug
output ec2-facts
>
> "ec2": {
> "changed": false,
> "failed": false,
> "instances": [
> {
> "ami_launch_index": 0,
> "architecture": "x86_64",
[..]
> "product_codes": [],
> "public_dns_name":
> "xxx.us-east-2.compute.amazonaws.com",
> "public_ip_address": "xx.xxx.44.51",
> "root_device_name": "/dev/xvda",
[...]
> }
> ]
> }
> }
>
>
> i want to use debug option in playbook  to print only the public ip
>
> ec2.instances.public_ip is not working
instances is an array of dicts here.

You'll need a 0 in there to access the first element of that list:

ec2.instances.0.public_ip_address

- Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer

Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/57e822cd-63ff-777b-4f0c-11b3f8169eeb%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] ansible fail to work with ssh

2019-03-19 Thread Sebastian Meyer
On 19.03.19 09:18, tharanga2...@gmail.com wrote:
>ansible_user= host=

Is this the same user you use for normal ssh? When you did the
ssh-copy-id you transferred the public key to the remote node only for a
single user (I'm guessing root, as you were root on the control node and
did not specify a user there). If that user is different from the one
you use for ansible, then the key can't be used.

- Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/3a20f633-7a9d-b011-db1d-400c7929d6d9%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] convert yaml file into jinja

2019-03-19 Thread Sebastian Meyer
On 19.03.19 03:27, federico montaldo wrote:
> Hi Folks:
> 
> I want to know if there is a way to extract from a yaml file the disk 
> information in order to pass it into jinja2 template. I got the following:

You can access ansible_facts in a jinja2 template like you would in a
playbook:

{{ ansible_facts['disks'][0]['size'] }}

- Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/e3a5d440-c187-62ce-e22d-d56e70fd0b6f%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] SSH Access to the Remote servers

2019-03-17 Thread Sebastian Meyer
Hi Guille,

On 17.03.19 11:13, Guillermo Colmena wrote:
> I have been trying to configure the ssh.cfg and ansible.cfg to be able to 
> access using an id_rsa to connect via ssh to the remote servers. The 
> question comes when I try to configure these 2 config files. Any main steps 
> that are needed to take to make it work?
> 
> Files: 
> 
> - ssh.cfg

I guess you are talking about the ssh_config file. Since Ansible uses
the systems ssh client (OpenSSH most likely), the config file for ssh
has to be in a location OpenSSH is looking for it.

On Linux that'd be /etc/ssh/ssh_config for the system-wide config or
$HOME/.ssh/config for a single users config.

The $HOME/.ssh directory has to have 700 or rwx-- permissions.

In there you just specify

Host myhost.example.com
  IdentityFile /path/to/your/private/key

Afterwards the first thing you should check is, if normal ssh works as
expected.

> - ansible.cfg

You should not need to specify anything here. If you need to keep your
ssh_config in a location the systems SSH client wouldn't look for it,
you probably could add a

-F /path/to/your/ssh/config

to the ssh_args parameter.

HTH
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/a5e141dc-1833-d520-393c-31071392bd6d%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] unable to delete line file

2019-03-12 Thread Sebastian Meyer
On 12.03.19 20:00, Deepak Sharma wrote:
> this is my host file.
> 
> #  cat /tmp/node/test.new
> [masters]
> 1234.abc.com
> [nodes]
> 453.abc.com  openshift_node_labels,22,="{'region': 'us_midwest', 
> 'datacenter': 'ctc', 'zone': 'core', 'environment': 'nonprod', 
> 'logging-infra-fluentd': 'true'}"
> 678abc.com  openshift_node_labels,22,="{'region': 'us_midwest', 
> 'datacenter': 'ctc', 'zone': 'core', 'environment': 'nonprod', 
> 'logging-infra-fluentd': 'true'}"
> #
> 
> and i want to delete 453.abc.com whole line from /tmp/node/test.new
> 
> with below syntax but getting error, can some one help me
> 
> 
> lineinfile: dest=/tmp/node/test.new
>   regexp='^{{ansible_hostname}}$'
>   state=absent
> 

'^{{ ansible_hostname }}$' matches a line containing only the name of
the node currently running the task.

If you want to delete a line starting with the name of the node you'll
need '^{{ ansible_hostname }}', without the $ which means line end.

If you are getting an error, providing the error message would help ...

Regards
-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/084012ec-1ac5-6daf-0377-65ee438f2f25%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] conditionals

2019-03-11 Thread Sebastian Meyer
Hi Jeffrey,

On 11.03.19 20:50, Jeffrey Agnitsch wrote:
> - name: vmotion {{ inventory_hostname }}

You'll also need "" here.

- name: "vmotion {{ inventory_hostname }}"

And this will give you only the first hostname as name for the task.

This works for me:

Playbook (without the linebreak in the when: line):

---
- hosts: all
  tasks:
- name: "foobar {{ inventory_hostname }}"
  debug:
  delegate_to: localhost
  when: inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') |
int  > 1


Inventory:

host1
host2

Output:

$ ansible-playbook -i /tmp/hosts /tmp/test.yml

PLAY [all]
***

TASK [Gathering Facts]
***
ok: [host2]
ok: [host1]

TASK [foobar host1]
***
skipping: [host1]
ok: [host2 -> localhost] => {
"msg": "Hello world!"
}

PLAY RECAP
***
host1  : ok=1changed=0unreachable=0failed=0
host2  : ok=1changed=0unreachable=0failed=0


Hope that helps,
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/2db654d8-0af7-97b0-6351-27f58c487b54%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.