[ansible-project] Register Variable /Setfacts and use it in Jinja2

2022-10-24 Thread Jatashankar Mishra
Hello team, I am trying to register variable /setfacts and use it in jinja2 template for printing the output but it says variable not define , Please can yo suggest something what is missing Playbook = --- - name: WinRM Test hosts: all tasks:

[ansible-project] Register variable in another task

2022-04-13 Thread Gabz Modz
Hi, I hope you are well Im blocked to register variable to use in other task: Here is the tree structure: └── ansible-role ├── add_user.yml ├── collections │ └── requirements.yml ├── Export-Test.csv ├── roles ├── gargentieri.search │ └── tasks │ └──

[ansible-project] Register variable using {{ item }}

2021-05-28 Thread R.B. Kumar
Hello Everyone again - Trying to get the IP address of the multiple Interfaces from a Cisco Router and register it. Using {{ item }} loop method to feed the Multiple Interfaces (eg: GigabitEthernet 0/0/0) in the command. How to get the unique variables for each interface? I will pick those

[ansible-project] Register variable in task with loop and use registered results for task conditional

2021-03-29 Thread tterr...@gmail.com
I am trying to run a loop over a task and I am registering the results. The items in the loop are not unique and can repeat. I don't want to run the same item twice. So, in the same task, I want to use a conditional to check if the current loop item has run so far in the loop. For this, I use

Re: [ansible-project] register variable can't be used in shell module?

2021-01-20 Thread liyo...@126.com
it works,thanks very mush 在2021年1月20日星期三 UTC+8 下午4:21:04 写道: > thanks,I try it : > shell: kubeadm join --control-plane {{ groups['master'][0] }}:6443 --token > {{ hostvars[groups['master']|first]['kubeadm_token'].stdout }} > --discovery-token-ca-cert-hash sha256:{{ >

Re: [ansible-project] register variable can't be used in shell module?

2021-01-20 Thread liyo...@126.com
thanks,I try it : shell: kubeadm join --control-plane {{ groups['master'][0] }}:6443 --token {{ hostvars[groups['master']|first]['kubeadm_token'].stdout }} --discovery-token-ca-cert-hash sha256:{{ hostvars[groups['master']|first]['kubeadm_hash'].stdout }} but the ansible-playbook command is

Re: [ansible-project] register variable can't be used in shell module?

2021-01-20 Thread Jean-Yves LENHOF
You could try something hostvars[groups['master']|first] instead of hostvars['master'] in my proposition to see it that works...not sure Use a debug module could help Regards, JYL Le 20/01/2021 à 08:53, liyo...@126.com a écrit : yes,I want only get one host in member of group ‘master’,how 

Re: [ansible-project] register variable can't be used in shell module?

2021-01-20 Thread liyo...@126.com
I just try to use set_fact,but only one one host: 47.108.234.26 get the token value,the other master node : 47.108.213.148 dont get it --- - hosts: master gather_facts: no tasks: - name: register hash shell: "openssl x509 -in /etc/kubernetes/pki/ca.crt -noout -pubkey | openssl

Re: [ansible-project] register variable can't be used in shell module?

2021-01-19 Thread liyo...@126.com
yes,I want only get one host in member of group ‘master’,how to write it ? [root@localhost ~]# cat /etc/ansible/hosts [master] 47.108.222.84 47.108.234.26 47.108.213.148 only use "47.108.222.84" to do shell command 在2021年1月20日星期三 UTC+8 下午3:47:31 写道: > I'm wrong it's not

Re: [ansible-project] register variable can't be used in shell module?

2021-01-19 Thread Jean-Yves LENHOF
I'm wrong it's not hostvars['master'], because master is not the name of your first host in group master Le 20/01/2021 à 08:33, Jean-Yves LENHOF a écrit : You're looking for something like this I think (not tested) :     - name: add master node       shell: "kubeadm join {{

Re: [ansible-project] register variable can't be used in shell module?

2021-01-19 Thread Jean-Yves LENHOF
You're looking for something like this I think (not tested)  :     - name: add master node       shell: "kubeadm join {{ groups['master']|first }}:6443 --token {{hostvars['master']['kubeadm_token'].stdout}} --discovery-token-ca-cert-hash sha256:{{hostvars['master']['kubeadm_hash'].stdout}}

Re: [ansible-project] register variable can't be used in shell module?

2021-01-19 Thread Dick Visser
You could register the variable to a dummy host. It's a bit of a hack imho but it does work. https://stackoverflow.com/questions/33896847/how-do-i-set-register-a-variable-to-persist-between-plays-in-ansible On Wed, 20 Jan 2021 at 08:17, liyo...@126.com wrote: > I know,but I want get the token

Re: [ansible-project] register variable can't be used in shell module?

2021-01-19 Thread liyo...@126.com
I know,but I want get the token in A host,use it in other hosts,how to do it ? 在2021年1月20日星期三 UTC+8 下午2:31:36 写道: > Hii > > You're registering a variable for one host (47.108.222.84) but then try to > use it for another (47.108.213.148). > > I'm have no experience with kubeadm but I think your

Re: [ansible-project] register variable can't be used in shell module?

2021-01-19 Thread Dick Visser
Hii You're registering a variable for one host (47.108.222.84) but then try to use it for another (47.108.213.148). I'm have no experience with kubeadm but I think your logic wrt host selection should be improved, so that you can reliably pick the variable from a stable group name, instead of

[ansible-project] register variable can't be used in shell module?

2021-01-19 Thread liyo...@126.com
when I edit a playbook test.yml: --- - hosts: master gather_facts: no tasks: - name: register hash shell: "openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^ .* //'|cut -d' ' -f 2"

Re: [ansible-project] Register variable, get specific strings and use strings in subsequent task

2020-09-28 Thread Sven
Thank you for your reply. I can't rly get a JSON response from the command ovs-vsctl show, since it is only possible for *find/list *operations. I tried to get a JSON output using a list operation, but it looks kinda strange to me.. (it shows only a small part, since the output is really long)

Re: [ansible-project] Register variable, get specific strings and use strings in subsequent task

2020-09-28 Thread Dick Visser
I don't know ovs-vsctl, but http://www.openvswitch.org/support/dist-docs/ovs-vsctl.8.txt mentions the option of generating output as JSON for that command. This will probably simplify your problem. Can you show some output with that option enabled? On Mon, 28 Sep 2020 at 19:45, Sven wrote: > >

[ansible-project] Register variable, get specific strings and use strings in subsequent task

2020-09-28 Thread Sven
Hello guys, I am not quite sure how to describe this. I have a simple task, which executes a shell command and register a variable. *- name: execute ovs-vsctl show command* * shell: ovs-vsctl show* * register: output* This will give me stdout with different ports like this: Port "7da0c92dc

Re: [ansible-project] Register variable not capturing

2020-03-11 Thread Stefan Hornburg (Racke)
On 3/11/20 11:20 AM, Sivaraman P wrote: > & is present in the command to stop so I have used.. it is optional... and > without & also I have used.. but still it is registering only the first line > It should be all there, so for example the following playbook: --- - hosts: all tasks: -

Re: [ansible-project] Register variable not capturing

2020-03-11 Thread Sivaraman P
& is present in the command to stop so I have used.. it is optional... and without & also I have used.. but still it is registering only the first line -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop

Re: [ansible-project] Register variable not capturing

2020-03-11 Thread Stefan Hornburg (Racke)
On 3/11/20 11:09 AM, Sivaraman P wrote: > Hi I have the below playbook to stop and start the service using the script > present in the the target machine, > > tasks: > - name : stop > command: ./coconf.sh -stop & > register: stop_details > > - debug: var=stop_details > > The actual

[ansible-project] Register variable not capturing

2020-03-11 Thread Sivaraman P
Hi I have the below playbook to stop and start the service using the script present in the the target machine, tasks: - name : stop command: ./coconf.sh -stop & register: stop_details - debug: var=stop_details The actual output of stop details contains multiline as below Using

[ansible-project] register variable value + string

2016-09-25 Thread Anthony Cheng
Does anyone know how I would go about to register values into variable + string (within a loop), so something like: register: "{{ item }}"_LIST with_items: "{{ LIST.stdout_lines }}" or register: {{ item }}_LIST -- You received this message because you are subscribed to the Google

Re: [ansible-project] Register variable locally and use on remote host

2015-06-06 Thread Martin
Boto is required on the host it runs on. There is no way to execute boto specific things on test when it is only installed on local host. What you can do is something like collect information on test then run boto stuff on localhost. /martin On Sat 6 Jun 2015 at 05:53 David Pires da...@unite.me

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread David Pires
I am getting the same error: failed=True msg='boto required for this module My inventory file is as follows: [localhost] localhost ansible_python_interpreter=PATH [test] IP And my playbook: --- - hosts: test pre_tasks: - name: Read host connection: local

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread Brian Coca
then if you added connection: local to the task, it should be executing locally and picking up boto On Fri, Jun 5, 2015 at 8:33 PM, David Pires da...@unite.me wrote: boto is installed on the ansible machine, not the remote host On Friday, June 5, 2015 at 8:31:04 PM UTC-4, Brian Coca wrote:

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread Brian Coca
Do you have boto installed on your machine? -- 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

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread David Pires
boto is installed on the ansible machine, not the remote host On Friday, June 5, 2015 at 8:31:04 PM UTC-4, Brian Coca wrote: Do you have boto installed on your machine? -- You received this message because you are subscribed to the Google Groups Ansible Project group. To unsubscribe from

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread Brian Coca
--- - hosts: remote_hosts sudo: True gather_facts: True pre_tasks: - name: Read current host connection: local sudo: False route53: command: get zone: zone record: record type: A register: host_record roles: -

[ansible-project] Register variable locally and use on remote host

2015-06-05 Thread David Pires
I am trying to use the route53 module in a playbook. If i install boto and add credentials the play works (reading a record and registering it), however I want to know if I can do this locally (where boto is installed) and have that registered variable available on remote hosts. Example

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread Brian Coca
I don't think I'm parsing what you are saying correctly. I thought you were running the task that required boto locally. ansible_python_interpreter is what you use to direct ansible to the correct python with the correct dependencies, it only applies for those hosts for which you set it. --

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread David Pires
I am trying to run the route53 module locally, register its output and use that variable in a task for a remote host. This works if i have boto installed globally, using connection: local. It does not work when using inside a virtualenv. I reproduced this in a virtual machine with boto

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread Brian Coca
I'm confused, what you are stating seems to contradict itself. -- 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

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread David Pires
--- - hosts: remote_host pre_tasks: - name: Read host connection: local route53: command: get zone: ZONE record: RECORD type: A register: host_record roles: - test When boto/ansible is

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread David Pires
I think I have found the issue, I'm running ansible in a virtualenv. I have ansible_python_interpreter set for localhost, this doesn't work for remote hosts. When I run ansible with boto available globally, it works. Is there a solution to get ansible to find dependencies for remote hosts?

Re: [ansible-project] Register variable locally and use on remote host

2015-06-05 Thread David Pires
Setting the interpreter for the remote host would require boto being installed on the remote host, which isn't what I'm after. Setting the variable on localhost and accessing it remotely using hostvars does work, however, the real issue is how ansible can't seem to find boto when its run

[ansible-project] register variable

2015-04-09 Thread Nico K.
Hi, I'm trying to register the output of a command which returns json. When I do this as a standalone task (not role) it works fine, for example: - name: x hosts: localhost tasks: - shell: aws iam list-server-certificates register: y - set_fact: test: {{ y.stdout }}

[ansible-project] Register variable in a loop can't access through with_items

2015-04-09 Thread Michael Mallett
Hi, I'm an ansible noob, and I'm following this tutorial to use the rax module to spin up and configure rackspace servers http://nicholaskuechler.com/2015/01/09/build-rackspace-cloud-servers-ansible-virtualenv/#comment-550108 It's great but it's not dynamic, as you can seemingly only add one

Re: [ansible-project] Register variable in a loop can't access through with_items

2015-04-09 Thread Brian Coca
try using debug module to see the actual structure of the returned data: debug: var=rax -- 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

Re: [ansible-project] register: variable as {{item}}?

2015-03-15 Thread Serge van Ginderachter
On 15 March 2015 at 05:55, Rick Kasten rickkas...@gmail.com wrote: Nothing's stopping me. I don't know what you're referring to. ​I meant, don;t use the jinja variable construct on register, just a plain variable. A registered variable on with_items will have a list of registered results.

Re: [ansible-project] register: variable as {{item}}?

2015-03-14 Thread Serge van Ginderachter
What's stopping you from registering this loop task with one variable? The iterated results get registered in a .results list . On 14 March 2015 at 20:19, Rick Kasten rickkas...@gmail.com wrote: - shell: alternatives --display {{ item }} | grep best | grep jre1.7.0_75 sudo: yes register:

[ansible-project] register: variable as {{item}}?

2015-03-14 Thread Rick Kasten
- shell: alternatives --display {{ item }} | grep best | grep jre1.7.0_75 sudo: yes register: {{ item }} ignore_errors: with_items: - java - javaws - jcontrol I've tried several iterations of this, all fail. Is there any way this can work? I don't want to have to create 3

Re: [ansible-project] register: variable as {{item}}?

2015-03-14 Thread Rick Kasten
Nothing's stopping me. I don't know what you're referring to. -- You received this message because you are subscribed to the Google Groups Ansible Project group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To

Re: [ansible-project] register variable being truncated

2014-01-31 Thread Adam Heath
debug: msg={{ commit error }} On 01/31/2014 11:55 AM, David Gethings wrote: Hi, I am working with a custom module. Sometimes it returns an error that I want to capture and then act on in another task. I have a register set and ignore_errors set to True in the playbook. However the msg returned