How to mention wildcard in ansible commands

user3147180

I am executing shell commands via Ansible.

Sometimes i don't have the complete foldername. Suppose i have dirname solr4.7.0.

In shell I can type cd solr*.

But in ansible I can't do:

chdir=/var/solr*

Is there any workaround?

larsks

No. The chdir= parameter to, e.g., the command module does not support wildcards.

You could accomplish what you want using a register variable to store the output of the ls command:

- shell: ls -d solr*
  register: dir_name
- command: some_command
  args:
    chdir: "{{ dir_name.stdout }}"

But this is, frankly, an ugly solution. You're better off just using the actual directory name. If it differs on different hosts, you can use host variables to set it appropriately.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to add @ mention in response to slash commands in slack

From Java

ansible : how to pass multiple commands

From Dev

Interleave two wildcard commands

From Dev

Ansible wildcard condition

From Dev

Bash: Using filenames as commands with the wildcard

From Java

Ansible conditionals - Wildcard match string

From Dev

Ansible and Playbook. How to convert shell commands into yaml syntax?

From Dev

How to disable json output from specific ansible commands?

From Dev

How to execute TCL commands of Rocket Universe through Ansible?

From Dev

how to mention user in android app

From Dev

How to mention a user in MantisBT note

From Dev

Return Values of Ansible Commands

From Dev

Ansible equivalent of the two commands

From Dev

Run several commands with Ansible

From Dev

How to mention C:\Program Files in batchfile

From Dev

How to mention current working directory in Batch File

From Dev

How to mention If else condition in batch file

From Dev

How to mention MYSQLDialect for hibernate 5.4.17 and MySQL 8.0?

From Dev

Discord.js How to mention message author?

From Dev

How to mention two aggregation functions in the same query?

From Dev

How to start Group Mention plugin development?

From Dev

How to do this condintional mention RegEx properly?

From Dev

How to get user id from a mention string

From Dev

Running bash commands in Ansible task

From Dev

Ansible register result of multiple commands

From Dev

Ansible Playbook to run Shell commands

From Dev

How to use a wildcard in egrep?

From Dev

How to use a wildcard in egrep?

From Dev

How is the wildcard * interpreted as a command?