I wish to list down all the hosts where it first checks for working telnet
on port 22. If telnet succeeds; it should check for passwordless ssh and
list down all hosts where telnet works but passwordless ssh fails.
The below playbook helps with the first part of checking all hosts where
telnet
Below is my playbook that helps check telnet connections from my localhost
to all remote hosts.
- wait_for:
host: "{{ item }}"
port: 22
state: started # Port should be open
delay: 0 # No wait before first check (sec)
ou please suggest?
>
> You already put two errors in your task which prevent it from running
> correctly.
> So in that light, i'm wondering if your actual task does, in fact,
> contain more differences than what you've posted here.
>
> Also, "prints
@Dick Hi,
That was a typo the problem remains writing to a file is all good with
newlines while writing to email body does not translate "\n" as new line !!
Could this be a bug ?
On Thu, Jun 4, 2020 at 3:37 PM Dick Visser wrote:
> On Thu, 4 Jun 2020 at 10:50, Shifa Shaikh wrote:
y, June 4, 2020 at 1:26:56 PM UTC+5:30, Stefan Hornburg (Racke)
wrote:
>
> On 6/4/20 8:54 AM, Shifa Shaikh wrote:
> > I tried multiline too as below, but that too fails
> >
> >mailbody: |
> > "{{ mailbody | default('') + 'PROFILE
| default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}"
"{{ 'SERVER_NAME: ' + SERVER_NAME }}"
and
mailbody: |
"{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}" +
"\\n"
"{{
Stephan Hi,
The article does not discuss newline inside parenthesis `{{` inside a
variable definition. That is where I have no clue.
On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan Hornburg (Racke)
wrote:
>
> On 6/4/20 6:41 AM, Shifa Shaikh wrote:
> > I tried all of th
'PROFILE_NAME:' + PROFILE_NAME ~ }}
\n + {{ 'SERVER_NAME:' + SERVER_NAME ~ }} + \n + {{ 'NODE_NAME:' +
NODE_NAME ~ }} \n\n\n\n\"
On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh wrote:
>
> @Dick VIsser Hi,
>
> Upon your suggest
27;NODE_NAME:'
+ NODE_NAME ~ \"\n\n\n\n\" }}"
Can someone please suggest?
On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser wrote:
>
> I won't comment on whatever it is you're trying to do, but in any case you
> need to use double quotes ar
How can I add new line characters to Ansible variable mailbody. This
mailbody variable is used for mail module's body attribute.
I tried the below from suggestions but none of them works.
1.
- set_fact:
mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + PROFILE_NAME ~
'\n
@Stefan Our service involves a set of processes thus, the start script
invokes those several processes and hence the need to count the number of
processes using `wc -l` to determine if the service (not the process) is
running or not.
On Thursday, May 21, 2020 at 8:18:56 AM UTC+5:30, Shifa
My requirement is to run the script stop-all as many times (5 retries)
until the output of ps -fu user1 |wc -l becomes less than 2.
I wrote the below ansible playbook for the same:
cat stop.yml
- hosts: dest_nodes
tasks:
- name: Start service
include_tasks: "{{ playbook-dir
environment:
CLASSPATH: "{{ wlsenv.stdout }}"
register: wlsversion
- debug:
msg: "{{ wlsversion }}
On Saturday, May 16, 2020 at 12:47:26 AM UTC+5:30, Shifa Shaikh wrote:
>
> In order to run java code I need to first set the classpath of d
In order to run java code I need to first set the classpath of dependent
libraries by running a script setWLSEnv.sh as below:
$ . /app/wlserv*/server/bin/setWLSEnv.sh
$ java weblogic.version
The output gives me the version of the product which I need.
I wrote the below playbook but it does not
I have two Plays having one task each.
The first Play 1 checks if the/var/test.datexists on each target host.
Only if the Play 1 is successful do I want the second play Play 2 to run
which executes scripts in parallel.
If Play 1 fails i.e if the test.dat does not exist I wish to terminate
My jinja2 template yields correct value for the variable
{{ vars[allip.name | join("")] | default('ERR') }}
The variable has value 82.3 which gets printed by Ansible's template module.
I wish to write an if condition where I want to check if the value of the
variable is more than 80
{% if ( v
My jinja2 template yields correct value for the variable
{{ vars[allip.name | join("")] | default('ERR') }}
The variable has value 82.3 which gets printed by Ansible's template module.
I wish to write an if condition where I want to check if the value of the
variable is more than 80
{% if ( v
Thank you @Kai for the excellent explanation :)
On Thursday, March 26, 2020 at 12:41:00 AM UTC+5:30, Kai Stian Olstad wrote:
>
> On Wed, Mar 25, 2020 at 09:54:07AM -0700, Shifa Shaikh wrote:
> > @Kia Hi,
> >
> > As suggested I tried
> >
> > item.size_
Below playbook gets the disk usage percentage of '/tmp' from a list of
remote_hosts [20 remote servers] and stores it locally (delegate_to) in a
file {{ playbook_dir }}/tmpfiles/stats.yml
---
hosts: remote_hosts
tasks:
- name: Generate JSON data
lineinfile:
path: "{{ play
an you please let me know what's wrong and why the difference?
On Wednesday, March 25, 2020 at 10:10:24 PM UTC+5:30, Kai Stian Olstad
wrote:
>
> On Wed, Mar 25, 2020 at 07:15:51AM -0700, Shifa Shaikh wrote:
> >
> > "{{ ansible_host }}_{{ item.mount }}: {{ (
Here is the output of df -k from the target server:
# df -k
> Filesystem 1K-blocks Used Available Use% Mounted on
> devtmpfs 1905280 0 1905280 0% /dev
> tmpfs 1922024 0 1922024 0% /dev/shm
> /dev/sda1 1942528 295616 1646912 16% /boot
> /dev/mapper/OMT-home 15718400 832120 14886280 6% /home
> /
Here is the output of df -k from the target server:
ok: [myhostone] => (item={u'block_used': 2857014, u'uuid':
> u'3fa1ec29-aca5-476b-8041-6a7bc6b1efc2', u'size_total': 52701921280,
> u'block_total': 12866680, u'mount': u'/ihs', u'block_available': 10009666,
> u'size_available': 40999591936
Below is my playbook that loads and prints the variables
---
- name: Demonstrating variables in Jinja2 Loops
hosts: localhost
- name: Load variable files
include_vars:
file="{{ playbook_dir }}/vars/vars.yml"
- debug:
msg: "COUNTRY {{ item.countries
Here is my playbook:
cat test.yml
- name: Play 2
hosts: targetserver
tasks:
- copy: src=./centosscript.sh dest=~ mode=775
- shell: ~/centosscript.sh
Here is my shell script:
cat centosscript.sh
#/bin/ksh
grabip=`ip r | grep kernel`
I also tried
grabip=`ifconfig | grep inet`
c
Here is my playbook:
cat test.yml
- name: Play 2
hosts: targetserver
tasks:
- copy: src=./centosscript.sh dest=~ mode=775
- shell: ~/centosscript.sh
Here is my shell script:
cat centosscript.sh
#/bin/ksh
grabip=`ip r | grep kernel`
I also tried
grabip=`ifconfig | grep inet`
c
/dashboard/{{ my_result.name }}
> state=directory recurse=yes"
>
> Do this:
>
>- file: path="{{ playbook_dir }}/dashboard/{{ my_result.name }}"
> state=directory recurse=yes
>
>
> On Mon, 16 Mar 2020 at 08:41, Shifa Shaikh > wrote:
> &
it has some nice examples of how loops work:
>
>
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#iterating-over-a-simple-list
>
>
>
>
> On Mon, 16 Mar 2020 at 08:21, Shifa Shaikh > wrote:
> >
> > Here is my variable file:
> >
Here is my variable file:
cat vars.yml
---
layers:
- name: APP
layers:
- name: WLS
Here is my playbook
cat varloop.yml
---
hosts: localhost
vars_files:
- vars.yml
tasks:
- name: Create sublinks based of bad.txt files
include_tasks: "{{ playbook_d
"Database is not reachable."
)
}}
On Fri, 13 Mar, 2020, 8:06 am James Cassell,
wrote:
>
> On Thu, Mar 12, 2020, at 10:12 PM, Shifa Shaikh wrote:
> > Hi,
> >
> > I have a playbook with a task that greps for a string in a file. If
Hi,
I have a playbook with a task that greps for a string in a file. If the
string is found the block should fail which is the case. However, in the
fail module it fails to print the message.
Here is my playbook:
Here is my playbook:
---
- name: "Play 1"
hosts: localhost
tasks:
- blo
Experts Hi,
I have couple of variable files like below:
$ cat vars_ip.yml
---
12.1.1.25: TAP1
12.1.1.26: TAP2
11.0.0.26: TAP3
11.0.0.27: TAP4
9.2.2.211: SAT1
9.2.2.212: SAT2
10.7.7.28: SAT3
10.7.7.29: SAT4
9.2.2.213: SAT5
10.7.7.30: SAT6
$ cat vars.yml
---
layers:
- name: MY_LAYER
I have a variable file like below:
12.1.1.25: TAP1
12.1.1.26: TAP2
11.0.0.26: TAP3
11.0.0.27: TAP4
9.2.2.211: SAT1
9.2.2.212: SAT2
10.7.7.28: SAT3
10.7.7.29: SAT4
layers:
- name: MY_LAYER
things_prod:
- 12.1.1.25
- 12.1.1.26
things_dr:
- 11.0.0.26
I wish to check using if condition inside a jinja template where any of the
folders starting with the name "dump_" has any file starting with the name
bad
For for single folder the below jinja template works as suggested by an
expert on this forum.
{% if lookup('fileglob', playbook_dir + '/'
I know how to lookup a file using fileglob in Ansible but not sure how to
inside a Jinja template.
On Fri, 6 Mar, 2020, 5:55 pm Stefan Hornburg (Racke),
wrote:
> On 3/6/20 1:12 PM, Shifa Shaikh wrote:
> > @Stefan I wish to check if the file bad*.txt exists on the path. Based
&g
@Stefan I wish to check if the file bad*.txt exists on the path. Based on
the if condition I wish to template different output.
On Fri, 6 Mar, 2020, 5:34 pm Stefan Hornburg (Racke),
wrote:
> On 3/6/20 12:52 PM, Shifa Shaikh wrote:
> > @Stefan I tried you suggestion of not using
;exists" filter.
On Friday, March 6, 2020 at 5:13:26 PM UTC+5:30, Stefan Hornburg (Racke)
wrote:
>
> On 3/6/20 11:52 AM, Shifa Shaikh wrote:
> > Vladimir Hi,
> >
> > I tried
> >
> > |
> > {%if{{playbook_dir }}/{{item }}/bad*.txt |exists %}
>
se {{ item }}
> in the template on its own.
>
> Regards
> Racke
>
> >
> > Looks like you didn't give us the good one
> >
> > Regards,
> >
> > JYL
> >
> >
> > Le 06/03/2020 à 11:52, Shifa Shaikh a
ur error is about a for loop, but your template included in your email
> doesn't have this loop.
>
> Looks like you didn't give us the good one
>
> Regards,
>
> JYL
>
>
> Le 06/03/2020 à 11:52, Shifa Shaikh a écrit :
>
> Vladimir Hi,
>
't have this loop.
>
> Looks like you didn't give us the good one
>
> Regards,
>
> JYL
>
>
> Le 06/03/2020 à 11:52, Shifa Shaikh a écrit :
>
> Vladimir Hi,
>
> I tried
>
> {% if {{ playbook_dir }}/{{ item }}/bad*.txt | exists %}
>
>
> {{ ite
PM UTC+5:30, Vladimir Botka wrote:
>
> On Fri, 6 Mar 2020 01:59:00 -0800 (PST)
> Shifa Shaikh > wrote:
>
> > How do i put the if /else condition in the jinja template ?
>
> See "if"
> https://jinja.palletsprojects.com/en/2.11.x/templates/#if
>
>
-
Here is my variable file
layers:
- name: APP
things:
- cactus
- lotus
- jasmine
- rose
- name: WAS
things:
- mango
- apple
Below is my jinja template file:
{% for layer in layers %}
{% for item in layer.things %}
{{ it
Thank you @Stefan,
That solves the issue !!
On Friday, March 6, 2020 at 2:32:07 PM UTC+5:30, Stefan Hornburg (Racke)
wrote:
>
> On 3/6/20 9:04 AM, Shifa Shaikh wrote:
> > I have a variable files like below:
> >
> > |
> > layers:
> > -name:APP
&g
I have a variable files like below:
layers:
- name: APP
things:
- cactus
- lotus
- jasmine
- rose
bgcolor:
- sky blue
- name: WAS
things:
- mango
- apple
bgcolor:
- yellow
Below is my jinja templa
Experts Hi,
I have a variable file that has a set of flowers, colors, and countries.
# cat vars/DASHBOARD_vars.yaml
---
myarch:
- COLOR:
name: blue,white,black,green
- FLOWER:
name: rose,jasmine
- COUNTRY:
name: Japan,Germany,France
I wish to create one HTML file each, thu
Experts Hi,
I have a variable file that has a set of flowers, colors, and countries.
# cat vars/DASHBOARD_vars.yaml
---
myarch:
- name: brown,white,black,green
- name: rose,jasmine
- name: Japan,Germany,France
I wish to create one HTML file each, thus 1 HTML for all colors, 1 HTML
fil
:53 AM, Shifa Shaikh wrote:
> > I need to get the output of ls command from list of remote ips and under
> each ip there is are different directories. The
> > output of ls command needs to be saved in a file and the name of the
> file should be the value of ccode variable
The reason for grabbing the ls output across servers is for audit purpose.
The audit team randomly checks for this output with the server.
On Tue, 3 Mar, 2020, 3:29 pm Stefan Hornburg (Racke),
wrote:
> On 3/3/20 10:53 AM, Shifa Shaikh wrote:
> > I need to get the output of ls com
vel.
> You are using ansible to achieve something - what is that?
>
> On Tue, 3 Mar 2020 at 09:20, Shifa Shaikh wrote:
> >
> > Under an ip I want a variable ccode which will be global variable for
> that ip.
> >
> > I also want variable name & path which wi
gt; Can you tell what is the big picture? What task is this intended for?
>
> On Tue, 3 Mar 2020 at 05:43, Shifa Shaikh wrote:
>
>> Below is my playbook which loads variables and passes it to ls command on
>> remote hosts.
>>
>>- name: Load repository
>>
Below is my playbook which loads variables and passes it to ls command on
remote hosts.
- name: Load repository
include_vars:
file="{{ playbook_dir }}/vars/listing.yml"
name=user1
- set_fact:
allinonecmd: "{{ allinonecmd | default('') + 'ls -ltr ' + item.path
+
@Vladimir this prints only the first name and path under the hostname.
I wish to loop all name and path under the given host.
On Monday, March 2, 2020 at 11:40:36 AM UTC+5:30, Vladimir Botka wrote:
>
> On Sun, 1 Mar 2020 21:37:42 -0800 (PST)
> Shifa Shaikh > wrote:
>
&
I have a include_vars file with the below entries in listings.yml
---
10.9.9.42:
- name: myapp
path: /app/myapp_war.ear/myapp.war
- name: myapp JS
path: /app/myapp_war.ear/myapp.war/javascripts
10.9.9.43:
- name: CVS
path: /app/CVS.ear/CVS.war/ui/js
- name: CHK
path: /app/l
#x27;') }}"
> with_items: "{{ lookup('vars', 'EXCLUDE_' + Layer).split(',') }}"
>
> On Wed, Feb 26, 2020 at 12:00 PM Shifa Shaikh > wrote:
>
>> I need to set_fact variable and contact to itself a list of item
.ansible.com/ansible/latest/plugins/lookup/vars.html
> >
> > Also try to use the args: chdir option instead of doing &&, see
> > https://docs.ansible.com/ansible/latest/modules/shell_module.html
> >
>
> "{{ vars['EXCLUDE_' + Layer] }}" shoul
Stefan Hornburg
(Racke) wrote:
>
> On 2/26/20 8:05 AM, Shifa Shaikh wrote:
> > Below is my playbook:
> >
> > |
> >-set_fact:
> >excludefolders:"{{ excludefolders + ' -o -name ' + item |
> default('') }}"
Below is my playbook:
- set_fact:
excludefolders: "{{ excludefolders + ' -o -name ' + item |
default('') }}"
with_items: "{{ lookup('vars', 'EXCLUDE_' + Layer).split(',') }}"
- debug:
msg: "excludedfolder is {{ excludefolders }}"
I get the below output
ok: [10.0.17.1
I need to set_fact variable and contact to itself a list of items as below:
- set_fact:
excludefolders: "{{ excludefolders + ' -o -name ' + item |
default('') }}"
with_items: "{{ lookup('vars', 'MY_' + Layer).split(',') }}"
Getting error:
FAILED! => {"msg": "The task includes
I have a playbook where I load a variable file
cat vars/BASE.yaml
EXCLUDE_front: value1
EXCLUDE_back: value2
I run my test.yml playbook using this command:
ansible-playbook test.yml -e Layer="back" -e base_folder="/tmp"
- name: Load a variable file"
include_vars:
file: "vars/BASE.yam
How do I make changes to the below complex when condition without breaking
the code in order to address the warning.
- debug: msg: "Hi"
when: entrycurrdb.stdout.find("{{
hostvars['localhost']['BASEPATH_FINAL'] }}/{{ vars[(item |
splitext)[1].split('.')[1] | default('exe')] }}/{{ item
How do I make changes to the below complex when condition without breaking
the code in order to address the warning.
- debug: msg: "Hi"
when: entrycurrdb.stdout.find("{{
hostvars['localhost']['BASEPATH_FINAL'] }}/{{ vars[(item |
splitext)[1].split('.')[1] | default('exe')] }}/{{ item
re REALLY
> looking to achieve.
> The file names in your example suggest: "configuring a web server".
> In which case, a few template tasks and a handler might be all you need.
>
> Dick
>
>
> On Sat, 25 Jan 2020 at 00:10, Shifa Shaikh > wrote:
> >
I use the stat module to read multiple files statistics from each remote
server.
Thus, I'm able to get the file mode and checksum value of say 3 files on
host1 and 2 files on host2.
I wish to know what is a good way to create/construct an include_vars file
so that I can easily read back each
{
> "msg": "Unexpected failure during module execution.",
> "stdout": ""
> }
On Wednesday, January 15, 2020 at 12:04:52 PM UTC+5:30, Jean-Yves LENHOF
wrote:
>
> Hi,
>
> Perhaps you should better use slurp module to register the
I wish to match all lines that begin with SSLFile or SSLFile in
a file httpd.conf on a remote server and store the matched found strings in
a variable for use later in the playbook.
Below is what i did.
- name: Find entries
shell: "cat /tmp/httpd.conf"
register: filecontent
I wish to search for all entries of string starting with "SSLFile" or
starting with "SSLFile" in a file(httpd.conf) and register it
to a variable and print all the matches found.
The string is found as evident from the output and the file is not modified
which is good; but I'm unable to print
Here is my requirement:
-
I have a playbook where I add the dynamic host to group "desthosts" in
[Play 1]
-
In [Play 2] desthosts group I append a set_fact variable "storerecords".
-
In [Play 3] I try to read set_fact "storerecords" of Play 2 however, I get
66 matches
Mail list logo