Re: [ansible-project] Template module doesn't work with any kind of loop

2023-02-28 Thread Adrian Sebastian Dutu
Seems this is caused by the path in the src. You can't put anything there
except the file name, and it will look in playbooks/templates/filename. If
i try to put a path, it throws that error.
This behavior happens only with loops though.

Without loops, I can put a full or relative path in the src and it works.

On Wed, Mar 1, 2023 at 12:22 AM dutu.a...@gmail.com 
wrote:

> Hello,
>
> I'm having a textbook task (taken straight out from the documentation
> examples) using template and with_filetree:
>
> - name: axis pipeline
>   template:
> src: "{{ item.src }}"
> dest: "{{ logstash_home  }}/{{ item.path | splitext | first }}"
>   with_filetree: ../templates/logstash/pipelines/axis
>
> I get this error:
> AnsibleFilterError: dict2items requires a dictionary, got  'ansible.template.AnsibleUndefined'> instead.
>
> I get the same error with with_fileglob.
>
> I have also tried different types of loops, nothing works. Everything I've
> tried works fine with the copy module.
>
> So what is so special about the template module? It should work similarly
> with copy in terms of copying files, iterating over filesystem paths etc.
> I'm using ansible 2.9.
>
> --
> 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/430f0b89-4f27-486f-90bc-e38332eb2042n%40googlegroups.com
> 
> .
>

-- 
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/CAHd1FN4BYCDBq28ZjHc1SSpwO3HjYVQStrKwueK%2BZ3s1PudFmA%40mail.gmail.com.


[ansible-project] Re: Howto to deploy kerberos (krb5.conf) info during awx operator install?

2022-07-12 Thread 'Sebastian Jaekel' via Ansible Project
Hi,

Even if you get it working, this will not help. The configuration from the 
containers is not related to the pod(s) launched when running a playbook. 
You need to modify the default container group or create a new one. For 
example, goto "Administration" -> "Instance Groups" and edit the "default" 
group.
Change spec to something like this (maybe you need to change the name of 
the configMap in volumes section):

apiVersion: v1
kind: Pod
metadata:
  namespace: awxop
spec:
  serviceAccountName: default
  automountServiceAccountToken: false
  containers:
- image: 'quay.io/ansible/awx-ee:latest'
  name: worker
  args:
- ansible-runner
- worker
- '--private-data-dir=/runner'
  resources:
requests:
  cpu: 250m
  memory: 100Mi
  volumeMounts:
   - name: krb5-conf
 mountPath: /etc/krb5.conf
 subPath: krb5.conf
  volumes:
- name: krb5-conf
  configMap:
name: awx-demo-extra-config


Regards

Sebastian


urs...@gmail.com schrieb am Dienstag, 14. Juni 2022 um 15:16:25 UTC+2:

> OK, I think I have part of an answer but I am not getting the syntax right 
> for a successful Kubernetes deployment it looks like.
>
> Can somebody look this over and help me out in getting the yaml file 
> syntax right, please? 
>
> ###
> # part 1 my ‘kustomization.yaml' file #
> ###
> ---
> apiVersion: kustomize.config.k8s.io/v1beta1
> kind: Kustomization
> resources:
>   # Find the latest tag here: 
> https://github.com/ansible/awx-operator/releases
>   - github.com/ansible/awx-operator/config/default?ref=0.22.0
>   - awx-myorg_awx.yaml
>
> # Set the image tags to match the git version from above
> images:
>   - name: quay.io/ansible/awx-operator
> newTag: 0.22.0
>
> # Specify a custom namespace in which to install AWX
> namespace: awx
>
> ###
> # part 2 my ‘awx-myorg_awx.yaml’ file  #
> ###
> ---
> kind: ConfigMap
> apiVersion: v1
> metadata:
>   name: awx-myorg
>   namespace: awx
> data:
>   krb5.conf: |-
> # To opt out of the system crypto-policies configuration of krb5, 
> remove the
> # symlink at /etc/krb5.conf.d/crypto-policies which will not be 
> recreated.
> # includedir /etc/krb5.conf.d/
> # my myorg krb5.conf file
> includedir /etc/krb5.conf.d/
>
> [libdefaults]
> default_realm = MYORG.DOM
>
> # The follodomg krb5.conf variables are only for MIT Kerberos.
> kdc_timesync = 1
> ccache_type = 4
> forwardable = true
> proxiable = true
>
> # The follodomg encryption type specification will be used by MIT 
> Kerberos
> # if uncommented.  In general, the defaults in the MIT Kerberos code 
> are
> # correct and overriding these specifications only serves to disable 
> new
> # encryption types as they are added, creating interoperability 
> problems.
> #
> # The only time when you might need to uncomment these lines and change
> # the enctypes is if you have local software that will break on ticket
> # caches containing ticket encryption types it doesn't know about 
> (such as
> # old versions of Sun Java).
>
> #   default_tgs_enctypes = des3-hmac-sha1
> #   default_tkt_enctypes = des3-hmac-sha1
> #   permitted_enctypes = des3-hmac-sha1
>
> # The follodomg libdefaults parameters are only for Heimdal Kerberos.
> fcc-mit-ticketflags = true
>
> [realms]
> MYORG.DOM = {
> kdc = dc1.myorg.dom
> kdc = dc2.myorg.dom
> admin_server = dc1.myorg.dom
> default_domain = MYORG.DOM
> }
> [domain_realm]
> .myorg.dom = MYORG.DOM
>
> ---
> apiVersion: awx.ansible.com/v1beta1
> kind: AWX
> metadata:
>   name: awx-myorg
> spec:
>   service_type: nodeport
>   web_extra_volume_mounts: |
> - name: krb5-conf
>   mountPath: /etc/krb5.conf
>   subPath: krb5.conf
>   task_extra_volume_mounts: |
> - name: krb5-conf
>   mountPath: /etc/krb5.conf
>   subPath: krb5.conf
>   ee_extra_volume_mounts: |
> - name: krb5-conf
>   mountPath: /etc/krb5.conf
>   subPath: krb5.conf
>   extra_volumes: |
> - name: krb5-conf
>   configMap:
> defaultMode: 420
> items:
>   - key: krb5.conf
> path: krb5.conf
> name: awx-myorg
>
>
> kustomize accepts this when I issue a 
> VERSION=0.22.0 kustomize build . | kubectl app

[ansible-project] Helm module issue.

2020-11-13 Thread Sebastian
Hi,
I'm trying to install Helm chart from the local file on the local Minikube 
instance but I'm constantly getting the same error:

fatal: [localhost]: FAILED! => { 
   "changed": false, 
   "command": "/usr/local/bin/helm --namespace=kube-system list 
--output=yaml --filter registrylocal", 
   "invocation": { 
   "module_args": { 
   "atomic": false, 
   "binary_path": null, 
   "chart_ref": "registry-1.3.0-1026.tgz", 
   "chart_repo_url": null, 
   "chart_version": null, 
   "create_namespace": false, 
   "disable_hook": false, 
   "force": false, 
   "kube_context": null, 
   "kubeconfig_path": null, 
   "purge": true, 
   "release_name": "registrylocal", 
   "release_namespace": "kube-system", 
   "release_state": "present", 
   "release_values": {}, 
   "replace": false, 
   "update_repo_cache": false, 
   "values_files": [], 
   "wait": false, 
   "wait_timeout": null 
   } 
   }, 
   "msg": "Failure when executing Helm command. Exited 1.\nstdout: 
\nstderr: Error: unknown flag: --filter\n", 
   "stderr": "Error: unknown flag: --filter\n", 
   "stderr_lines": [ 
   "Error: unknown flag: --filter" 
   ], 
   "stdout": "", 
   "stdout_lines": [] 
}

As a test I'm able to create a namespace against the same Minikube instance:
--- 
- hosts: localhost 
 connection: local 
 gather_facts: false 

 tasks: 
   - name: Create namespace. 
 community.kubernetes.k8s: 
   name: test
   api_version: v1 
   kind: Namespace 
   state: present 

   - name: Deploy local Registry chart 
 community.kubernetes.helm: 
   chart_ref: registry-1.3.0-1026.tgz 
   release_namespace: kube-system 
   release_name: registrylocal

For some reason it doesn't like `release_name` value, I've tried changing 
to `name` alias but it is returning the same error. Running Helm version is 
the same on both sides:
Client: {SemVer:"v2.14.3", 
GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"} 
Server: {SemVer:"v2.14.3", 
GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}

Any ideas what this could be?


-- 
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/e80438f6-fd68-4479-8e8e-119bed5cd75fn%40googlegroups.com.


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] Trying to background a start up script

2020-09-03 Thread Sebastian Collins
Touché!

Ok, I understand now. I thought using pm2 involved a lot of tweaking. I was
trying and failing to get it to read my npm dotenv. Instead of trying to
use pm2 to call my app.js directly I have just realised I can use it to
launch it indirectly via npm without having to change any config . Simples!

Thanks for your advice.



On Thu, Sep 3, 2020 at 7:02 PM Stefan Hornburg (Racke) 
wrote:

> On 9/3/20 7:58 PM, Sebastian Collins wrote:
> > I tried the command module before using the shell module.
> >
> > I thought the command module was the wrong choice because when I run it,
> as below, it simply hangs.
> >
> > If I log on to the host I can see the ansible task has spawned the
> node.js process but I suppose my playbook is hanging
> > because it can't background it.
> >
>
> Correct, npm doesn't do that. Use PM2.
>
> Regards
>  Racke
>
> > Any ideas how to do this because the documentation has left me none the
> wiser.
> >
> >tasks:
> >
> >   - name: execute startup script
> > command: npm start app.js
> > register: status
> > args:
> >   chdir: "/apps/test/postcodes.io <http://postcodes.io>"
> >
> >   - debug:
> >   var: status
> >
> >
> >
> > On Thu, Sep 3, 2020 at 5:52 PM Stefan Hornburg (Racke)  <mailto:ra...@linuxia.de>> wrote:
> >
> > On 9/3/20 5:45 PM, Sebastian Collins wrote:
> > > Thanks for your suggestion. PM2 actually looks really good. Great
> monitoring metrics and ansible seems to
> > > seamlessly invoke it no problem:
> > >
> > > - name: Task17 - start nodejs - Step1 of 3 - execute startup script
> > > shell: pm2 start app.js
> > > register: status
> > > args:
> > >   chdir: "/apps/test/postcodes.io <http://postcodes.io> <
> http://postcodes.io>"
> > >
> > >   - debug:
> > >   var: status
> > > ]
> > >
> >
> > Use command instead of shell module. See documentation.
> >
> >
> > > and provides a handy output to the terminal
> > >
> > >
> > > "stdout": "[PM2] Applying action restartProcessId on app
> [app](ids: [ 0 ])\n[PM2] [app](0) ✓\n[PM2] Process
> > successfully
> > >
> >
>  
> started\n┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐\n│
> > > id  │ name   │ namespace   │ version │ mode│ pid  │ uptime
> │ ↺│ status│ cpu  │ mem  │ user
> > │
> > > watching
> > >
> >
>  
> │\n├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤\n│
> > > 0   │ app│ default │ 12.0.0  │ fork│ 59888│ 0s
> │ 1│ online│ 0%   │ 8.7mb│
> > wasadm   │
> > > disabled
> > >
> >
>  
> │\n└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘",
> > > "stdout_lines": [
> > > "[PM2] Applying action restartProcessId on app
> [app](ids: [ 0 ])",
> > > "[PM2] [app](0) ✓",
> > > "[PM2] Process successfully started",
> > >
> > >
> >
>  
> "┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐",
> > > "│ id  │ name   │ namespace   │ version │ mode│
> pid  │ uptime │ ↺│ status│ cpu  │
> > mem
> > >│ user │ watching │",
> > >
> > >
> >
>  
> "├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤",
> > > "│ 0   │ app│ default │ 12.0.0  │ fork│
> 59888│ 0s │ 1│ online│ 0%   │
> > 8.7mb
> > >│ wasadm   │ disabled │",
> > >
> > >
> >
>  
> "└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘"
> > > ]
> > > }
> > >

Re: [ansible-project] Trying to background a start up script

2020-09-03 Thread Sebastian Collins
Thanks for your suggestion. PM2 actually looks really good. Great
monitoring metrics and ansible seems to seamlessly invoke it no problem:

- name: Task17 - start nodejs - Step1 of 3 - execute startup script
shell: pm2 start app.js
register: status
args:
  chdir: "/apps/test/postcodes.io"

  - debug:
  var: status
]

and provides a handy output to the terminal


"stdout": "[PM2] Applying action restartProcessId on app [app](ids: [ 0
])\n[PM2] [app](0) ✓\n[PM2] Process successfully
started\n┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐\n│
id  │ name   │ namespace   │ version │ mode│ pid  │ uptime │ ↺│
status│ cpu  │ mem  │ user │ watching
│\n├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤\n│
0   │ app│ default │ 12.0.0  │ fork│ 59888│ 0s │ 1│
online│ 0%   │ 8.7mb│ wasadm   │ disabled
│\n└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘",
"stdout_lines": [
"[PM2] Applying action restartProcessId on app [app](ids: [ 0
])",
"[PM2] [app](0) ✓",
"[PM2] Process successfully started",

"┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐",
"│ id  │ name   │ namespace   │ version │ mode│ pid  │
uptime │ ↺│ status│ cpu  │ mem  │ user │ watching │",

"├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤",
"│ 0   │ app│ default │ 12.0.0  │ fork│ 59888│
0s │ 1│ online│ 0%   │ 8.7mb│ wasadm   │ disabled │",

"└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘"
]
}
}


However, using pm2 has introduced other problems such as me failing to have
it read the process.env file that node had no issues with so now I am not
listening on the intended port with the custom credentials. No doubt there
is a way to do this but  before looking at adopting pm2 is there not just a
simple fix to my existing ansible task in order to launch "node start" and
keep that process up and running?



On Thu, Sep 3, 2020 at 1:20 PM Stefan Hornburg (Racke) 
wrote:

> On 9/3/20 2:07 PM, Sebastian Collins wrote:
> > Hi,
> >
> > I have this task and I can't for the life of me get it to keep the
> process running. I have added in some debug and it
> > shows me the process is getting shutdown almost immediately after it is
> started up as can be seen by the end time in the
> > output I have provided below. Please advise how I can fix this so that
> the process keeps on running as future tasks are
> > performed.
> >
> >
> >   - hosts: nodes
> > remote_user: root
> > become_user: test
> > become: true
> > tasks:
> >
> >   - name: execute startup script
> > shell: nohup npm start > test.out 2>&1 &
> > register: status
> > args:
> >   chdir: "/apps/test/postcodes.io"
> >
> >   - debug:
> >   var: status
> >
> >
>
> Use a proper daemon process manager (PM2, https://pm2.keymetrics.io/).
>
> Regards
> Racke
>
> > Output:
> >
> > TASK [execute startup script]
> 
> > changed: [host] => {"changed": true, "cmd": "nohup npm start > test.out
> 2>&1 &", "delta": "0:00:00.006275", "end":
> > "2020-09-03 12:37:51.797561", "rc": 0, "start": "2020-09-03
> 12:37:51.791286", "stderr": "", "stderr_lines": [],
> > "stdout": "", "stdout_lines": []}
> >
> > TASK [debug]
> >
> **
> > ok: [host] => {
> > "status": {
> > "changed": true,
> > "cmd": "nohup npm start > test.out 2>&1 &",
> > "delta": "0:00:00.006275",
> > "end": "2020-09-03 12:37:51.797561",
> > 

[ansible-project] Trying to background a start up script

2020-09-03 Thread Sebastian Collins
Hi,

I have this task and I can't for the life of me get it to keep the process 
running. I have added in some debug and it shows me the process is getting 
shutdown almost immediately after it is started up as can be seen by the 
end time in the output I have provided below. Please advise how I can fix 
this so that the process keeps on running as future tasks are performed.

  
  - hosts: nodes
remote_user: root
become_user: test
become: true
tasks:

  - name: execute startup script
shell: nohup npm start > test.out 2>&1 &
register: status
args:
  chdir: "/apps/test/postcodes.io"

  - debug:
  var: status


Output:

TASK [execute startup script] 

changed: [host] => {"changed": true, "cmd": "nohup npm start > test.out 
2>&1 &", "delta": "0:00:00.006275", "end": "2020-09-03 12:37:51.797561", 
"rc": 0, "start": "2020-09-03 12:37:51.791286", "stderr": "", 
"stderr_lines": [], "stdout": "", "stdout_lines": []}

TASK [debug] 
**
ok: [host] => {
"status": {
"changed": true,
"cmd": "nohup npm start > test.out 2>&1 &",
"delta": "0:00:00.006275",
"end": "2020-09-03 12:37:51.797561",
"failed": false,
"rc": 0,
"start": "2020-09-03 12:37:51.791286",
"stderr": "",
"stderr_lines": [],
"stdout": "",
"stdout_lines": []
}
}

If I go on to the host and run it manually it works:

host:APACHE > nohup npm start > host.out 2>&1 &
[1] 45428
user@host:/apps/test/postcodes.io
host:APACHE > ps -ef | grep node
user   45439 45428  3 12:54 pts/200:00:00 node server.js


Any help much appreciated.


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/02be6001-7a5f-4f13-b478-199947412270n%40googlegroups.com.


[ansible-project] Ansible task not starting up custom node.js script with either shell or command module

2020-09-02 Thread Sebastian Collins
Hi,

Any ideas where I am going wrong here?

I have a web server task which uses shell to start apache no problem:

- hosts: webservers
remote_user: root
become_user: test
become: True
tasks:
  - name: Task18 - Start webservers back up
shell: ./apache/bin/apachectl start
tags:
  - startweb

I have made a similar task to try start node for which I pass in the same 
'start' arguement

- hosts: nodes
remote_user: root
become_user: test
become: True
tasks:
  - name:  Start node back up
shell: ./***/***/init.d/etc.d/control.postcodesio.nodejs.sh start
tags:
  - startnode

This task fails with : 

 "msg": "non-zero return code", "rc": 127, "start": "2020-09-02 
19:07:49.395993", "stderr": "sh: control.postcodesio.nodejs.sh: No such 
file or directory",

This script definitely exists in this location and works if triggered 
manually:

./control.postcodesio.nodejs.sh start
Starting NodeJS: 26182
 NodeJS instance running


I have tried a different approach but I still get the same  No such file or 
directory

 tasks:
  - name:  Change Directory
command: cd /***/***/init.d/etc.d/

  - command: "ls /***/***/init.d/etc.d/"
register: dir_out

  - debug: var={{item}}
with_items: dir_out.stdout_lines

   - name: start nodejs 
 command: sh control.postcodesio.nodejs.sh start

The output of the debug step above confirms the presence of the script as 
shown in the output below so i really don't understand why it says the "
control.postcodesio.nodejs.sh" can't be found?

:
TASK  Change Directory] 
***
changed: [hostname]
changed: [h ostname]

TASK [command] 
*
changed: [ hostname  ]
changed: [hostname]

TASK [debug] 
***
ok: [hostname] => (item=dir_out.stdout_lines) => {
"changed": false,
"dir_out.stdout_lines": [
"control.apache.sh",
"control.postcodesio.nodejs.sh"
],
"item": "dir_out.stdout_lines"
}
ok: [hostname] => (item=dir_out.stdout_lines) => {
"changed": false,
"dir_out.stdout_lines": [
"control.apache.sh",
"control.postcodesio.nodejs.sh"
],
"item": "dir_out.stdout_lines"
}

TASK start nodejs 
*
fatal: [hostname]: FAILED! => {"changed": true, "cmd": ["sh", "
control.postcodesio.nodejs.sh", "start"], "delta": "0:00:00.007772", "end": 
"2020-09-02 19:07:49.098795", "msg": "non-zero return code", "rc": 127, 
"start": "2020-09-02 19:07:49.091023", "stderr": "sh: 
control.postcodesio.nodejs.sh: No such file or directory", "stderr_lines": 
["sh: control.postcodesio.nodejs.sh: No such file or directory"], "stdout": 
"", "stdout_lines": []}



Any ideas much appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e814918d-97b0-4127-9fcb-bb2e57a6ad44n%40googlegroups.com.


Re: [ansible-project] Trying to use pexpect ansible module to run interactive script

2020-08-29 Thread Sebastian Collins
OK, 

I see what I was doing the wrong. The last question of the interactive 
script was framed slightly differently and included an extra colon 
immediately after the word Port which I had omitted:

Postgresql Port: [default: 5432]:

Now I have added this colon to my final response, the pexpect module is 
working a treat.

Thanks very much for your help.


On Friday, August 28, 2020 at 3:36:30 PM UTC+1 Sebastian Collins wrote:

> Legend! I never would have figured this out, so thanking you kindly.
>
> I have hit one error after this:  : 
>
> "argument responses is of type  and we were unable to convert 
> to dict" 
>
> for which I have managed to nearly resolve it having found a solution to 
> which you again had provided to someone else:  : 
> https://groups.google.com/g/ansible-project/c/dDKvb1m5yM8
>
> I now have the ansible task formed liked this:
>
> - name: Setup postcodesiodb
>   expect:
> echo: yes
> chdir: "/apps/was/postcodes.io"
> command: npm run setup
> timeout: "10"
> responses: 
>
> 'Postgresql Superuser \(for database creation\) \[default: 
> postgres\]': 'postgres'
>
> 'New Database Username \(for readonly access\) \[default: 
> postcodesio\]': 'postcodesio'
> 'Password for new user \[default: secret\]': 'secret'
> 'Postgresql Host \[default: localhost\]': 'localhost'
> 'Database Name \[default: postcodesiodb\]': 'postcodesiodb'
> 'Postgresql Port \[default: 5432\]': 5432
>   tags:
> - setup
> - install
> - test   
>
>  The task is no longer producing that error and I can see the values being 
> populated with the exception the the final Port value which still does not 
> look to be parsing "5432" correctly. I have tried removing the single 
> quotes around it, to make it clear it is an integer as opposed to a string 
> but that has made no difference. I also can't see any discrepancies with 
> the escape characters used for regex  compared to the previous responses 
> which are now working. Any ideas what I need to do to close this off?
>
> FAILED! => {"changed": true, "cmd": "npm run setup",
> ...
> Apply read-only privileges for the new user to the new database", "", 
> "Postgresql Superuser (for database creation) [default: 
> postgres]:postgres", "New Database Username (for readonly access) [default: 
> postcodesio]:postcodesio", "Password for new user [default: 
> secret]:secret", "Postgresql Host [default: localhost]:localhost", 
> "Database Name [default: postcodesiodb]:postcodesiodb", "Postgresql Port: 
> [default: 5432]:"]}
>
>
> On Thursday, August 27, 2020 at 2:41:41 PM UTC+1 Matt Martz wrote:
>
>> There are a few problems with your task.
>>
>> 1. `Question` as used in the example, is supposed to represent the prompt 
>> or string to match. So you need to remove that.
>> 2. The "questions", prompts, or matches are regex, so you have to escape 
>> characters that have special meaning in regex
>>
>> responses:
>> 'Postgresql Superuser \(for database creation\) \[default: 
>> postgres\]': 'postgres'
>> 'New Database Username \(for readonly access\) \[default: 
>> postcodesio\]': 'postcodesio'
>> 'Password for new user \[default: secret\]': 'secret'
>> 'Postgresql Host \[default: localhost\]': 'localhost'
>> 'Database Name \[default: postcodesiodb\]': 'postcodesiodb'
>> 'Postgresql Port \[default: 5432\]': '5432'
>> On Thu, Aug 27, 2020 at 6:22 AM Sebastian Collins  
>> wrote:
>>
>>> Hi,
>>>
>>> I have composed this ansible task using the pexpect module to run a 
>>> setup.sh script with npm run
>>>
>>> - name: Setup postcodesiodb
>>>   expect:
>>> echo: yes
>>> chdir: "/apps/was/postcodes.io"
>>> command: npm run setup
>>> timeout: "10"
>>> responses:
>>>   Question: 
>>>
>>> - 'Postgresql Superuser (for database creation) [default: 
>>> postgres]': 'postgres'
>>>
>>> - 'New Database Username (for readonly access) [default: 
>>> postcodesio]': 'postcodesio'
>>> - 'Password for new user [default: secret]': 'secret'
>>> - 'Postgresql Host [default: localhost]': 'localhost'
>>> - 'Database Nam

Re: [ansible-project] Trying to use pexpect ansible module to run interactive script

2020-08-28 Thread Sebastian Collins
Legend! I never would have figured this out, so thanking you kindly.

I have hit one error after this:  : 

"argument responses is of type  and we were unable to convert 
to dict" 

for which I have managed to nearly resolve it having found a solution to 
which you again had provided to someone else:  : 
https://groups.google.com/g/ansible-project/c/dDKvb1m5yM8

I now have the ansible task formed liked this:

- name: Setup postcodesiodb
  expect:
echo: yes
chdir: "/apps/was/postcodes.io"
command: npm run setup
timeout: "10"
responses: 
'Postgresql Superuser \(for database creation\) \[default: 
postgres\]': 'postgres'
'New Database Username \(for readonly access\) \[default: 
postcodesio\]': 'postcodesio'
'Password for new user \[default: secret\]': 'secret'
'Postgresql Host \[default: localhost\]': 'localhost'
'Database Name \[default: postcodesiodb\]': 'postcodesiodb'
'Postgresql Port \[default: 5432\]': 5432
  tags:
- setup
- install
- test   

 The task is no longer producing that error and I can see the values being 
populated with the exception the the final Port value which still does not 
look to be parsing "5432" correctly. I have tried removing the single 
quotes around it, to make it clear it is an integer as opposed to a string 
but that has made no difference. I also can't see any discrepancies with 
the escape characters used for regex  compared to the previous responses 
which are now working. Any ideas what I need to do to close this off?

FAILED! => {"changed": true, "cmd": "npm run setup",
...
Apply read-only privileges for the new user to the new database", "", 
"Postgresql Superuser (for database creation) [default: 
postgres]:postgres", "New Database Username (for readonly access) [default: 
postcodesio]:postcodesio", "Password for new user [default: 
secret]:secret", "Postgresql Host [default: localhost]:localhost", 
"Database Name [default: postcodesiodb]:postcodesiodb", "Postgresql Port: 
[default: 5432]:"]}


On Thursday, August 27, 2020 at 2:41:41 PM UTC+1 Matt Martz wrote:

> There are a few problems with your task.
>
> 1. `Question` as used in the example, is supposed to represent the prompt 
> or string to match. So you need to remove that.
> 2. The "questions", prompts, or matches are regex, so you have to escape 
> characters that have special meaning in regex
>
> responses:
> 'Postgresql Superuser \(for database creation\) \[default: 
> postgres\]': 'postgres'
> 'New Database Username \(for readonly access\) \[default: 
> postcodesio\]': 'postcodesio'
> 'Password for new user \[default: secret\]': 'secret'
> 'Postgresql Host \[default: localhost\]': 'localhost'
> 'Database Name \[default: postcodesiodb\]': 'postcodesiodb'
> 'Postgresql Port \[default: 5432\]': '5432'
> On Thu, Aug 27, 2020 at 6:22 AM Sebastian Collins  
> wrote:
>
>> Hi,
>>
>> I have composed this ansible task using the pexpect module to run a 
>> setup.sh script with npm run
>>
>> - name: Setup postcodesiodb
>>   expect:
>> echo: yes
>> chdir: "/apps/was/postcodes.io"
>> command: npm run setup
>> timeout: "10"
>> responses:
>>   Question: 
>>
>> - 'Postgresql Superuser (for database creation) [default: 
>> postgres]': 'postgres'
>>
>> - 'New Database Username (for readonly access) [default: 
>> postcodesio]': 'postcodesio'
>> - 'Password for new user [default: secret]': 'secret'
>> - 'Postgresql Host [default: localhost]': 'localhost'
>> - 'Database Name [default: postcodesiodb]': 'postcodesiodb'
>> - 'Postgresql Port [default: 5432]': '5432'
>>   tags:
>> - setup
>> - install
>> - test   
>>
>>
>>
>> Below is the only error logging I have but it's failed at the first input 
>> I am attempting to populate here the postgres Super user. Any ideas how I 
>> need to pass in these answers and or variables if I don't want to hard 
>> code? Currently it just looks like it is picking up  "] characters.
>>  
>> Fatal: [hostname]: FAILED! => {"changed": true, "cmd": "npm run setup", 
>> "delta": "0:02:00.145566", "end": "2020-08-25 21:33:22.107526", "msg": 
>> "command exceeded timeout", &

[ansible-project] Trying to use pexpect ansible module to run interactive script

2020-08-27 Thread Sebastian Collins
Hi,

I have composed this ansible task using the pexpect module to run a 
setup.sh script with npm run

- name: Setup postcodesiodb
  expect:
echo: yes
chdir: "/apps/was/postcodes.io"
command: npm run setup
timeout: "10"
responses:
  Question: 
- 'Postgresql Superuser (for database creation) [default: 
postgres]': 'postgres'
- 'New Database Username (for readonly access) [default: 
postcodesio]': 'postcodesio'
- 'Password for new user [default: secret]': 'secret'
- 'Postgresql Host [default: localhost]': 'localhost'
- 'Database Name [default: postcodesiodb]': 'postcodesiodb'
- 'Postgresql Port [default: 5432]': '5432'
  tags:
- setup
- install
- test   



Below is the only error logging I have but it's failed at the first input I 
am attempting to populate here the postgres Super user. Any ideas how I 
need to pass in these answers and or variables if I don't want to hard 
code? Currently it just looks like it is picking up  "] characters.
 
Fatal: [hostname]: FAILED! => {"changed": true, "cmd": "npm run setup", 
"delta": "0:02:00.145566", "end": "2020-08-25 21:33:22.107526", "msg": 
"command exceeded timeout", "rc": null, "start": "2020-08-25 
21:31:21.961960",
...
 "Postgresql Superuser (for database creation) [default: postgres]:"]}

The wording / syntax of the questions when the script is called is exactly 
like this:
Postgresql Superuser (for database creation) [default: postgres]:


I have tried various combinations to frame my inputs e.g. 

Question: 
- 'Postgresql Superuser (for database creation) [default: 
postgres]': 
[postgres]

or 

- 'Postgresql Superuser (for database creation) [default: postgres]': 
$postgres

or 

- 'Postgresql Superuser (for database creation) [default: postgres]': { 
postgres }

But they all seem to produce the same error message. The pexpect module 
documentation is very limited esp in terms of examples. I am not needing to 
use pexpect if there are other know working solutions to automate this with 
ansible.

Any ideas much appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a421440a-8468-49f9-a1fb-6ce22f61a1bfn%40googlegroups.com.


Re: [ansible-project] Re: Migrating playbook from ubuntu to amazon linux 2 - throws error missing dependency: python-apt

2020-02-06 Thread Adrian Sebastian Dutu
You can use package facts for that:
https://docs.ansible.com/ansible/latest/modules/package_facts_module.html

On Wednesday, February 5, 2020 at 10:27:01 AM UTC+1, Stefan Hornburg 
(Racke) wrote:
>
> On 2/5/20 9:48 AM, Adrian Sebastian Dutu wrote: 
> > Why are you using the command module? 
> > 
> > Use the package module. Then it will not matter what package manager the 
> distro is running. 
> > If you have ansible module available for what you want to do, never use 
> command. I would rewrite the entire play. 
> > 
>
> You can use the package module, but it will not be able to list packages 
> and the names of packages might 
> differ between different distros etc. 
>
> Regards 
>  Racke 
>
> > 
> > 
> > On Wednesday, February 5, 2020 at 2:08:01 AM UTC+1, Work-Hard wrote: 
> > 
> > Hello, 
> > Do you recommend Migrating playbook from ubuntu to amazon Linux 2 
> (as it uses *yum instead of apt*). If so, how can 
> > I check if missing add a package to a new instance to make sure it 
> installs python-apt*?* 
> > *Ansible-Playbook* 
> > --- 
> > - hosts: amazonlinux2 
> >   become: true 
> >   any_errors_fatal: true 
> >   serial: 1 
> >   max_fail_percentage: 0 
> >   vars: 
> > ansible_user: ec2-user 
> >   tasks: 
> > # do an "apt-get update", to ensure latest package lists 
> > - name: apt-get update 
> >   apt: 
> > update-cache: yes 
> >   changed_when: 0 
> > 
> > # get a list of packages that have updates 
> > - name: get list of pending upgrades 
> >   command: apt-get --simulate dist-upgrade 
> >   args: 
> > warn: false # don't warn us about apt having its own plugin 
> >   register: apt_simulate 
> >   changed_when: 0 
> > 
> > - name: Update cache 
> >   apt: 
> > update-cache: yes 
> >   changed_when: false 
> > 
> > - name: Fetch package list of updates 
> >   command: apt list --upgradable 
> >   register: aptlist 
> > 
> > - set_fact: 
> > updates: "{{ aptlist.stdout_lines | 
> difference(['Listing...']) 
> > | map('regex_replace', '^(.*?)/(.*)', '\\1') | list }}" 
> > 
> > - debug: var=updates 
> > 
> > # tell user about packages being updated 
> > - name: show pending updates 
> >   debug: 
> > var: updates 
> >   when: updates.0 is defined 
> > 
> > # comment this part in if you want to manually ack each server 
> update 
> > - pause: 
> >   when: updates.0 is defined 
> > 
> > # if a new kernel is incoming, remove old ones to avoid full 
> /boot 
> > - name: apt-get autoremove 
> >   command: apt-get -y autoremove 
> >   args: 
> > warn: false 
> >   when: '"Inst linux-image-" in apt_simulate.stdout' 
> >   changed_when: 0 
> > 
> > # do the actual apt-get dist-upgrade 
> > - name: apt-get dist-upgrade 
> >   apt: 
> > upgrade: dist # upgrade all packages to latest version 
> >   register: upgrade_output 
> > 
> > # check if we need a reboot 
> > - name: check if reboot needed 
> >   stat: path=/var/run/reboot-required 
> >   register: file_reboot_required 
> > 
> > # "meta: end_play" aborts the rest of the tasks in the current 
> «tasks:» 
> > # section, for the current webserver 
> > # "when:" clause ensures that the "meta: end_play" only triggers 
> if the 
> > # current server does _not_ need a reboot 
> > - meta: end_play 
> >   when: not file_reboot_required.stat.exists 
> > 
> > # because of the above meta/when we at this point know that the 
> current 
> > # host needs a reboot 
> > 
> > # prompt for manual input before doing the actual reboot 
> > - name: Confirm reboot of ec2-user 
> >   pause: 
> > 
> > - name: reboot node 
> >   shell: sleep 2 && shutdown -r now "Reboot triggered by 
> ansible" 
> >   async: 1 
> >   poll: 0 
> >   ignore_errors: true 
> > 
> &

[ansible-project] Re: Migrating playbook from ubuntu to amazon linux 2 - throws error missing dependency: python-apt

2020-02-05 Thread Adrian Sebastian Dutu
Why are you using the command module?

Use the package module. Then it will not matter what package manager the 
distro is running.
If you have ansible module available for what you want to do, never use 
command. I would rewrite the entire play.



On Wednesday, February 5, 2020 at 2:08:01 AM UTC+1, Work-Hard wrote:
>
> Hello,
> Do you recommend Migrating playbook from ubuntu to amazon Linux 2 (as it 
> uses *yum instead of apt*). If so, how can I check if missing add a 
> package to a new instance to make sure it installs python-apt*?*
> *Ansible-Playbook*
> ---
> - hosts: amazonlinux2
>   become: true
>   any_errors_fatal: true
>   serial: 1
>   max_fail_percentage: 0
>   vars:
> ansible_user: ec2-user
>   tasks:
> # do an "apt-get update", to ensure latest package lists
> - name: apt-get update
>   apt:
> update-cache: yes
>   changed_when: 0
>
> # get a list of packages that have updates
> - name: get list of pending upgrades
>   command: apt-get --simulate dist-upgrade
>   args:
> warn: false # don't warn us about apt having its own plugin
>   register: apt_simulate
>   changed_when: 0
>
> - name: Update cache
>   apt:
> update-cache: yes
>   changed_when: false
>
> - name: Fetch package list of updates
>   command: apt list --upgradable
>   register: aptlist
>
> - set_fact:
> updates: "{{ aptlist.stdout_lines | difference(['Listing...'])
> | map('regex_replace', '^(.*?)/(.*)', '\\1') | list }}"
>
> - debug: var=updates
>
> # tell user about packages being updated
> - name: show pending updates
>   debug:
> var: updates
>   when: updates.0 is defined
>
> # comment this part in if you want to manually ack each server update
> - pause:
>   when: updates.0 is defined
>
> # if a new kernel is incoming, remove old ones to avoid full /boot
> - name: apt-get autoremove
>   command: apt-get -y autoremove
>   args:
> warn: false
>   when: '"Inst linux-image-" in apt_simulate.stdout'
>   changed_when: 0
>
> # do the actual apt-get dist-upgrade
> - name: apt-get dist-upgrade
>   apt:
> upgrade: dist # upgrade all packages to latest version
>   register: upgrade_output
>
> # check if we need a reboot
> - name: check if reboot needed
>   stat: path=/var/run/reboot-required
>   register: file_reboot_required
>
> # "meta: end_play" aborts the rest of the tasks in the current «tasks:»
> # section, for the current webserver
> # "when:" clause ensures that the "meta: end_play" only triggers if the
> # current server does _not_ need a reboot
> - meta: end_play
>   when: not file_reboot_required.stat.exists
>
> # because of the above meta/when we at this point know that the current
> # host needs a reboot
>
> # prompt for manual input before doing the actual reboot
> - name: Confirm reboot of ec2-user
>   pause:
>
> - name: reboot node
>   shell: sleep 2 && shutdown -r now "Reboot triggered by ansible"
>   async: 1
>   poll: 0
>   ignore_errors: true
>
> # poll ssh port until we get a tcp connect
> - name: wait for node to finish booting
>   become: false
>   local_action: wait_for host=ec2-user
>   port=22
>   state=started
>   delay=5
>   timeout=600
>
> # give sshd time to start fully
> - name: wait for ssh to start fully
>   pause:
> seconds: 15
>
> # wait a few minutes between hosts, unless we're on the last
> - name: waiting between hosts
>   pause:
> minutes: 10
>   when: inventory_hostname != ansible_play_hosts[-1]
>
>
> *Ansible-Output*
> PLAY [amazonlinux2] 
> **
>
> TASK [Gathering Facts] 
> ***
> [WARNING]: Platform linux on host 10.11.12.13 is using the discovered 
> Python interpreter at /usr/bin/python, but future installation of another 
> Python
> interpreter could change this. See 
> https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html
>  
> for more information.
>
> ok: [10.11.12.13]
>
> TASK [apt-get update] 
> 
> [WARNING]: Updating cache and auto-installing *missing dependency: 
> python-apt*
>
> fatal: [10.11.12.13]: FAILED! => {"changed": false, "cmd": "apt-get 
> update", "msg": "[Errno 2] No such file or directory", "rc": 2}
>
> NO MORE HOSTS LEFT 
> ***
>
> NO MORE 

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-14 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
>>>>> Groups
>>>>> "Ansible

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
Hi,

in this case verify that

- debug:
var: ec2

works first.

Then try:

- debug:
var: ec2.instances

Afterwards:

- debug:
var: ec2.instances.0

So basically you try to build the path to the value you want. If one
fails, please post the output of the last succeeding debug.

- Sebastian


On 21.03.19 23:19, tinkuchowdar...@gmail.com wrote:
> Thank you sebastian for quick reply 
> unfortunately that didn't work
> 
> here the part that i am running
> 
>   - name: "gather instance facts"
> ec2_instance_facts:
>   instance_ids: i-xx
>   region: "{{ region }}"
> delegate_to: localhost
> when: ec2_instance_prov == 'no'
> register: ec2
> tags:
>   - gather-facts
>   - provision-ec2
>   - debug: 
>   var: ec2.instances.0.public_ip_address 
> tags:
>   - gather-facts
> 
> after i run this i see no output
> 
> PLAY [Provision an EC2 Instance] 
> *
> 
> TASK [gather instance facts] 
> *
> ok: [localhost -> localhost]
> 
> TASK [debug] 
> *
> ok: [localhost] => {
> "ec2.instances.0.public_ip_address": "VARIABLE IS NOT DEFINED!"
> }
> 
> PLAY RECAP 
> ***
> localhost  : ok=2changed=0unreachable=0
> failed=0   
> 
> 
> On Thursday, March 21, 2019 at 2:48:03 PM UTC-7, tinkuch...@gmail.com wrote:
>>
>> here is the dubug output ec2-facts
>>
>> "ec2": {
>> "changed": false, 
>> "failed": false, 
>> "instances": [
>> {
>> "ami_launch_index": 0, 
>> "architecture": "x86_64", 
>> "block_device_mappings": [
>> {
>> "device_name": "/dev/xvda", 
>> "ebs": {
>> "attach_time": "2019-03-21T18:28:03+00:00", 
>> "delete_on_termination": true, 
>> "status": "attached", 
>> "volume_id": "vol-"
>> }
>> }
>> ], 
>> "client_token": "", 
>> "cpu_options": {
>> "core_count": 1, 
>> "threads_per_core": 1
>> }, 
>> "ebs_optimized": false, 
>> "ena_support": true, 
>> "hibernation_options": {
>> "configured": false
>> }, 
>> "hypervisor": "xen", 
>> "image_id": "ami-", 
>> "instance_id": "i-xxx", 
>> "instance_type": "t2.micro", 
>> "key_name": "x", 
>> "launch_time": "2019-03-21T18:28:03+00:00", 
>> "monitoring": {
>> "state": "disabled"
>> }, 
>> "network_interfaces": [
>> {
>> "association": {
>> "ip_owner_id": "amazon", 
>> "public_dns_name": "
>> ec2-x.us-east-2.compute.amazonaws.com", 
>> "public_ip": "xx.xx.xx.51"
>> }, 
>> 

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=0    unreachable=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.


[ansible-project] Re: Having problems with a variable in vars_files

2019-02-19 Thread Adrian Sebastian Dutu
Can you run your playbook with -vvv then post the output? It's probably 
going to be a lot, so use https://pastebin.com/ .
Check if beforehand for any sensitive information.

-- 
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/d9df9905-0b23-4609-bee3-898970ed1f56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Execute eval from shell module to set up environment variables

2019-02-18 Thread Adrian Sebastian Dutu
You need to put those export commands in the shell initialization files. 
Running export will set it just for the current session, which will close 
when the playbook ends.

-- 
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/add0e635-9146-46cd-bd45-fe4dae29bd00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Execute eval from shell module to set up environment variables

2019-02-18 Thread Adrian Sebastian Dutu
You need to put those export commands in the shell initialization files.
Running export will set it just for the current session, which will close
when the playbook ends.

On Sat, Feb 16, 2019 at 10:12 PM Захари Палазов 
wrote:

> Is it possible to execute eval command from a shell module to set up
> environment variables ?
>
> This is a snippet from a playbook which tries to set up environment
> variables by executing eval command
>
> eval $(docker-machine env DEV-MACHINE)
>
>
> This is the result of the eval command
> export DOCKER_TLS_VERIFY="1"
> export DOCKER_HOST="tcp://192.168.99.100:2376"
> export DOCKER_CERT_PATH="/home/user/.docker/machine/machines/DEV-MACHINE"
> export DOCKER_MACHINE_NAME="DEV-MACHINE"
>
>
>
> When this is executed from an ansible playbook environment variables are
> not set
>
>
> Best Regards to the team !
>
> --
> 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/8d11195b-fb01-4e94-964b-dfc212a77fed%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAHd1FN5PRNK1ogTGEEiu2baLt0RjOnc%2BSxqmpEoSP8wr5ZJhbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: --skip-tags equivalent inside playbooks

2019-02-04 Thread Adrian Sebastian Dutu
You have the tag "never" which will make that role/task not execute by 
default when running the play, unless explicitly called with --tags. Check 
special tags in the 
docs: https://docs.ansible.com/ansible/latest/user_guide/playbooks_tags.html

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/32f4925e-71c7-4726-b9fe-a53da6712845%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] audit asnisble-playbook

2019-01-08 Thread Sebastian lusenti
hi,
I'm having a security issue problem with Ansible.
for policies, I have to know who did what. So, if I want to launch some 
playbooks and somehow cause trouble in the servers, I must bring back the 
information who did what on those servers. 
now the only information that I have is the servers audit log.
and the playbooks log. but It's impossible to match univocally a record on 
the audit with a record on the ansible log, so it's impossible to know the 
human user. 

how this could be archived?

thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/44c48396-fcb2-42b6-8295-7f393b642876%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: how to pass ansible variables from Jenkins by using parameters

2018-10-24 Thread Adrian Sebastian Dutu
-e allows you to pass variables to the command line. So you can put that in 
your job. Also, there's an ansible jenkins plugin. You can take a look at 
that.
https://wiki.jenkins.io/display/JENKINS/Ansible+Plugin

On Wednesday, October 24, 2018 at 8:40:34 AM UTC+2, kumar kittu wrote:
>
> Hello All,
>
> I have ansible-playbook which has variables defined and that playbook is 
> executed successfully from jenkins by creating job.
>
> my query is :
>
> I need to pass ansible variables defined in playbook from jenkins ,as 
> parameter(or what ever),so it would eliminate hard coding in 
> ansible-playbook.
>
> Searched a lot but couldn't get exact solution.
>
> Request anyone to help me at the earliest
>
> Thanks in advance
>

-- 
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/c940e59a-e939-4b32-8096-1159ebda2216%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Error add host to host collection with uri module api rest operations with satellite

2018-10-23 Thread Adrian Sebastian Dutu
Can you do a get on both of those ids (972,1280)?  Seems like one of them 
is not existing.

-- 
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/207d0264-8ec6-4bd7-b77d-c56b6349fa5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Get Field with equal condition from json generated ansible 2.5.2 uri module

2018-10-23 Thread Adrian Sebastian Dutu

>
> Define it under a vars section.
>
https://docs.ansible.com/ansible/devel/user_guide/playbooks_variables.html#variables-defined-in-a-playbook
 

-- 
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/a92dd8b9-7da8-4370-b8ab-7d6ec58f85c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Adrian Sebastian Dutu
I think the indentation appears wrong just in the preview. I downloaded the 
file and the indentation is fine on line 10.
It seems this line is the 
issue: 
combine(rxgt_mgmt_account.account_config.stacks['rxgt-ps-mgmt-direct-connect-gateway'].override_tags,
 
recursive=True) }}"
It says that dictionary has no key named stacks. Maybe try just printing 
that dict or do -vvv to see what keys that it actually has.

-- 
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/3bb5259e-ae7e-4db5-842a-77a6fd3149f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] with_items... in groups[item.hostgroups]

2017-07-13 Thread Sebastian Gogoasa
Hello,

I'm trying to create new users but I've encountered a problem with the when 
statement which doesn't allows me to move forward.

users.yml
  - fullname: Full Name Here1
username: sshusernamehere1
userkey: ../files/ssh-keys/sshusernamehere1/authorized_keys
access:
  state: present
  groups:
- wheel
- sftpusers
  hosts:
- all-management-servers
- all-jenkins-servers

  - fullname: Full Name Here2
username: sshusernamehere2
userkey: ../files/ssh-keys/sshusernamehere2/authorized_keys
access:
  state: present
  groups:
- agroup
- sftpusers
  hosts:
- all-servers
- all-web-servers


main.yml
- name: USERS | SSH USERS | Checking user(s) presence within the group...
  user: name="{{ item.username }}" groups="{{ item.access.groups }}" 
append=yes createhome=yes state="{{ item.access.state }}"
  when:
- item.access.state == "present"
- item.access.hosts is defined
- inventory_hostname in groups['item.access.hosts']
  with_items: "{{ users }}"

- name: USERS | SSH USERS | Deploying SSH Key(s) for our user(s)...
  authorized_key: user="{{ item.username }}" state="{{ item.access.state 
}}" key="{{ lookup('file', item.userkey)}}"
  when:
- item.access.state == "present"
- item.access.hosts is defined
- inventory_hostname in groups['item.access.hosts']
  with_items: "{{ users }}"

What's wrong with this or how may I change my main.yml code in order to 
deploy the users only if that inventory_hostname is part of the hosts: 
group (which is defined on ansible hosts file).

Thanks you!

-- 
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/d86c44a1-3163-4ebd-84d7-34ee524d08ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] bigip_irule module and token authentication

2017-07-05 Thread Sebastian Plush
Hi

Does anyone know whether the bigip_irule module supports token 
authentication?  Using remote (ldap) auth to the BigIP and, while initial 
authentication is successful, subsequent REST calls fail with auth error.  
All indications are that module does not support tokens, but unable to find 
any definitive documentation.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0dd3d1b5-7574-49b6-9cf6-526d9e1991e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] update of ansible seems to be inconsistent

2016-12-12 Thread Sebastian S.
You were right. There was a ansible pip installation. I uninstalled it and 
ansible --version is now correct. Thank you!! ^^ 

Am Donnerstag, 8. Dezember 2016 13:44:35 UTC+1 schrieb Sebastian S.:
>
> In fact there is one. But when I run this one something goes wrong:
>
> ansible@DE9899S76 /etc/ansible/roles % /usr/bin/ansible  
> Traceback (most recent call last):
>   File "/usr/bin/ansible", line 46, in 
> from ansible.module_utils._text import to_text
> ImportError: No module named _text
>
>
> Am Donnerstag, 8. Dezember 2016 09:02:31 UTC+1 schrieb Andreas Olsson:
>>
>> ons 2016-12-07 klockan 23:40 -0800 skrev Sebastian S.: 
>> > which ansible says: /usr/local/bin/ansible 
>>
>> That looks more like somewhere where Pip would install Ansible, or 
>> where someone would install Ansible manually. Any chance that you also 
>> have a /usr/bin/ansible, which better match the apt version? 
>>
>> // Andreas 
>>
>

-- 
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/81c19ee5-a5a0-44d5-9321-09cd60bf6ca4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] update of ansible seems to be inconsistent

2016-12-08 Thread Sebastian S.
In fact there is one. But when I run this one something goes wrong:

ansible@DE9899S76 /etc/ansible/roles % /usr/bin/ansible  
Traceback (most recent call last):
  File "/usr/bin/ansible", line 46, in 
from ansible.module_utils._text import to_text
ImportError: No module named _text


Am Donnerstag, 8. Dezember 2016 09:02:31 UTC+1 schrieb Andreas Olsson:
>
> ons 2016-12-07 klockan 23:40 -0800 skrev Sebastian S.: 
> > which ansible says: /usr/local/bin/ansible 
>
> That looks more like somewhere where Pip would install Ansible, or 
> where someone would install Ansible manually. Any chance that you also 
> have a /usr/bin/ansible, which better match the apt version? 
>
> // Andreas 
>

-- 
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/0f2afbf2-132f-47c2-a91b-49711fdb2bb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] update of ansible seems to be inconsistent

2016-12-07 Thread Sebastian S.
Hi,

which ansible says: /usr/local/bin/ansible

I did a apt-get remove for ansible-tower and ansible and reinstalled both 
with the bundled installer, no difference.
Didn't wanted to make a apt-get purge, because I do not want to configure 
everything again, but meanwhile i think about a complete new installation...

Am Mittwoch, 7. Dezember 2016 15:51:23 UTC+1 schrieb Andreas Olsson:
>
> ons 2016-12-07 klockan 03:52 -0800 skrev Sebastian S.: 
> > ansible@DE9899S76 ~ % ansible --version 
> > ansible 2.0.0.2 
> >  
> > 3. apt-cache --showpkg ansible says it' 2.2.0.0 
>
> What does `which ansible` say? 
>
> That is, any chance that you have an additional version of Ansible 
> installed, in addition to what is provided by the package manager? 
>
> // Andreas 
>

-- 
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/08b630eb-5041-4c81-ab8e-c2d277d16266%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Update of ansible seems incorrect

2016-12-07 Thread Sebastian S.


Hello,

I've a Ubuntu 14.04 box with Ansible and Ansible-Tower running. I do 
regularly upgrades of the packages and have the official mirror for Ansible 
in my sources.list. So it gets updates. So far, so good. But i think 
there's something wrong.

1.) When I do a ansible --version on the command line it says it version 
2.0.0.2:

ansible@DE9899S76 ~ % ansible --version
ansible 2.0.0.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides


2.) apt-cache --showpkg says it's 2.2.0.0:

ansible@DE9899S76 ~ % apt-cache showpkg ansible
..
Provides: 
2.2.0.0-1ppa~trusty - 
1.7.2+dfsg-1~ubuntu14.04.1 - 
1.5.4+dfsg-1 - 


3:) I use the synchronize module in a playbook now and have a problem, 
that, as far as I've read, has been solved in Ansible 2.1.

When using become: yes with the synchronize module it tries to use sudo not 
on the remote machine but on the Ansible server. You can read about it 
here, e.g.: http://cheat.readthedocs.io/en/latest/ansible/synchronize.html


Has anyone had the same behavior? Am I getting something wrong? Any help 
would be appreciated :) 

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


[ansible-project] update of ansible seems to be inconsistent

2016-12-07 Thread Sebastian S.
Hello folks,

we have a Ubuntu 14.04 box running Ansible and Ansible-Tower on it. The 
packages are updates regularly. The Ansible mirror is also listed in the 
sources.list, so it gets updates too. But there seem to be something wrong. 
I'm thinking this because

1. When I do a ansible --version it shows 2.0.0.2

ansible@DE9899S76 ~ % ansible --version
ansible 2.0.0.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides


2. apt-get -u -V upgrade says there are no upgrade pending. The ansible 
package is not locked or pinned in apt.

3. apt-cache --showpkg ansible says it' 2.2.0.0

4. Playbooks with the synchronize module have a problem that has been 
solved in version 2.1, as far as I've read. When you use this module with 
become: yes, sudo is not used on the remote machine but on the ansible 
server.

http://cheat.readthedocs.io/en/latest/ansible/synchronize.html


So it looks to me like some parts have been updated to version 2.2.0.0 and 
others not. Can anybody explain this to me or has any tips for me to get 
this riddle solved? Any help would be appreciated :)


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d2e45b08-baa9-4465-839f-d8d477ed820c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: any_errors_fatal as a global config?

2016-10-04 Thread Sebastian Szwed
Hello,

I've got a similar problem, did you solve it?

Thanks

W dniu czwartek, 12 maja 2016 19:10:44 UTC+2 użytkownik Bharathwaj Sankara 
napisał:
>
> Hello-
>  I want to stop the playbook on hitting the first error and not proceed 
> anything further, I understand 
> any_errors_fatal: True
>
> will take care of that at a playbook level.
>
> However I have a deployment/upgrade process where we run multiple 
> playbooks (over 150) and new ones are getting added on a weekly basis. So 
> adding 
> any_errors_fatal: True
>
> to each any every playbook is cumbersome and is a nightmare to make sure 
> all new playbooks will come with this option by default.
>
> Is there a global config - like a env variable or an ansible.cfg option to 
> run with option.
> any_errors_fatal: True
>
> Thanks
>
>
>

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


[ansible-project] installation on Mac OSX issue

2015-08-18 Thread Sebastian M Cheung
 

After installation via $brew install ansible


then, I added in ~/.bashrc


#Ansible

export PATH=/usr/local/Cellar/ansible/1.9.2/bin:$PATH


$source .bashrc


then


$ ansible

/usr/local/Cellar/ansible/1.9.2/bin/ansible: 
/usr/local/Cellar/ansible/1.9.2/libexec/bin/ansible: /usr/bin/python: bad 
interpreter: No such file or directory

/usr/local/Cellar/ansible/1.9.2/bin/ansible: line 2: 
/usr/local/Cellar/ansible/1.9.2/libexec/bin/ansible: Undefined error: 0


anyone? My default python is 


$which python

/Users/seb/anaconda/bin/python so I guess it doesn't know which python 
interpreter to use? If so how to modify Ansible script


Thanks




Sebastian

-- 
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/57590de1-4591-4052-bc1d-056989713051%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Same list from multiple vars-files consolidated

2015-01-08 Thread Sebastian Gumprich
Thanks for your input.
I tried setting hash_behaviour to merge but this doesn't work. Even when 
I put the two lists into one vars-file, only the last list will be used.
But you mentioning naming the variable different gave me an idea. I'm using 
different variables in group_vars and host_vars now and use multiple tasks 
and templates.

Thanks!


Am Mittwoch, 7. Januar 2015 15:11:30 UTC+1 schrieb Brian Coca:

 ansible by default will override previous definitions with newer ones, 
 in this case group 'all' gets loaded first and then overwritten by 
 group1. 

 You can change this behavior globally using the hash_behaviour entry 
 in ansible.cfg. 
 Or you can name the variable differently and then use the |union 
 filter in the task to aggregate them just for that task. 



 -- 
 Brian Coca 


-- 
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/6e266253-e510-4bbd-a3a4-001d2c0505be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Same list from multiple vars-files consolidated

2015-01-07 Thread Sebastian Gumprich
Hello,

I have a list-item in the group-vars for all hosts:

/etc/ansible/group_vars/all

splunkforwarder_log_items:
  - app_name: var_messages
source: /var/log/messages



I also have the same list-item in another (narrowed down) group-var:

/etc/ansible/group_vars/group_1
splunkforwarder_log_items:
  - app_name: var_secure
source: /var/log/secure
index: testindex
sourcetype: linux_secure



Now I want to use both lists (or the conflated list) in the following task, 
so {{ item.app_name }} would be substituted with var_messages
 and var_secure from both lists.


- name: create input configuration
  template:
src=inputs_conf.j2
dest=/etc/apps/{{ item.app_name }}/local/inputs.conf
  with_items: splunkforwarder_log_items


Sadly, only the list from group_1 is used.
Is there a way to conflate these lists / use both? Or am I doing something 
wrong?


Regards
Sebastian

-- 
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/0e77bece-92e4-4957-ba72-0424dfc4040f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] dpkg options

2014-12-19 Thread sebastian halfar
Hallo ansible-team,

first of all nice work i like this tool alot. We use it for Updates on 
Debian Server. I got one request for your dpkg options, we need the 
possibility to give apt module some dpkg options like only upgrade a 
certain package only if its already installed. Can u tell me if u guys 
working on it or is it just me who could need it.

Thanks 

Wish you guys a nice christmas and a happy new year keep up the good work

Greatings from germany


-- 
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/879e9f32-a2b9-4e07-87b5-2dc81f800079%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] use subelement-variables in templates

2014-08-14 Thread Sebastian Gumprich
That did the trick!

Here's my configuration now, for completeness:

vars:


splunkforwarder_log_items:
  - app1_name: var_log
source: /var/log
recursive: true
index: testindex

splunkforwarder_log_files:
  - logfile: messages
app_name: var_log
sourcetype: linux_messages_syslog


task:


- name: drop props configuration
  template:
src=props_conf.j2
dest={{splunkforwarder_dir}}/etc/apps/{{ item.app_name }}/props.conf
owner=splunk
group=splunk
mode=640
  with_items: splunkforwarder_log_files


template:

{% for source in splunkforwarder_log_files %}
[source::.../{{source.logfile}}]
sourcetype = {{source.sourcetype}}
{% endfor %}



Thanks!

Am Dienstag, 12. August 2014 16:14:18 UTC+2 schrieb Michael DeHaan:

 With what you have above, item.0 is the overall list and item.1 is each 
 item in the splunkforwarder_log_files, however it looks like you shouldn't 
 be using with_subelements at all, because the only variable in your task 
 definition that changes is item.0

 Unless I'm missing something, I would switch to a basic with_items and 
 avoid calling the template task multiple times, and then just rely on the 
 loop inside the template.



 On Tue, Aug 12, 2014 at 8:10 AM, Sebastian Gumprich zufal...@gmail.com 
 javascript: wrote:

 Hi,

 I have the following variables:

 splunkforwarder_log_items:
   - source: /var/log
 app_name: var_log
 recursive: true
 index: testindex
 splunkforwarder_log_files:
   - logfile: messages
 name: var_log
 sourcetype: linux_messages_syslog



 and the following task:

 - name: drop props configuration
   template:
 src=props_conf.j2
 dest={{splunkforwarder_dir}}/etc/apps/{{item.0.app_name}}/props.conf
 owner=splunk
 group=splunk
 mode=640
   with_subelements:
 - splunkforwarder_log_items
 - splunkforwarder_log_files



 Is it possible to use the variables from the subelement 
 splunkforwarder_log_files in the props_conf.j2-template? For example 
 like this:

 {% for sources in splunkforwarder_log_items.splunkforwarder_log_files %}
 [source::.../{{sources.logfile}}]
 sourcetype = {{sources.sourcetype}}
 {% endfor %}



 Or is there a simpler alternative?

 Regards
 Sebastian

 -- 
 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-proje...@googlegroups.com javascript:.
 To post to this group, send email to ansible...@googlegroups.com 
 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/ansible-project/6fa6b0f5-5bac-455c-bb8b-9cbd05ae5c76%40googlegroups.com
  
 https://groups.google.com/d/msgid/ansible-project/6fa6b0f5-5bac-455c-bb8b-9cbd05ae5c76%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.




-- 
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/07547963-998e-4988-97a7-b8404e4df28c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible + Vagrant with VirtualBox ssh error

2013-12-14 Thread Sebastian Pawluś
I've found the same issue this morning: 

- ansible 1.4.1, and devel with at #91f903eabeddfa19552eb1d1b998297d99627e3d 
as well
- Vagrant 1.4
- host machine ubuntu 13.10 64, 
- guest machine ubuntu 12.04 64

It looks a bit nondeterministic, there are moments when vagrant up works 
just fine. 


-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.