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:
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
│ └──
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
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
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:{{
>
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
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
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
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
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 {{
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}}
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
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
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
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"
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)
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:
>
>
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
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:
-
& 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
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
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
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
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
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
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:
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
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
---
- 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:
-
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
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.
--
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
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
---
- 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
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?
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
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 }}
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
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
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.
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:
- 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
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
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
44 matches
Mail list logo