LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Containers
User Name
Password
Linux - Containers This forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.

Notices


Reply
  Search this Thread
Old 04-13-2023, 03:34 AM   #1
1s440
Member
 
Registered: Mar 2018
Posts: 266

Rep: Reputation: Disabled
ansible regex arugments


Hi all,

I am looking for some help with regex generator, as ansible uses python regex. Is there any way that i could generate it on online.
I also wanted the ansible to prompt for interactions(questions) when running a particular task and below is my code. ERROR! conflicting action statements: command, prompt
Looking for some suggestions.

Code:
  - name: install 
    command: /tmp/install.run
    prompt: 
      - Installation path? "[/tmp/output]":
    when: condition

Last edited by 1s440; 04-13-2023 at 04:12 AM.
 
Old 04-13-2023, 07:31 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,656

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by 1s440 View Post
Hi all,
I am looking for some help with regex generator, as ansible uses python regex. Is there any way that i could generate it on online.
Maybe, so you should probably do a search for this and find it, rather than asking us to look it up for you.
Quote:
I also wanted the ansible to prompt for interactions(questions) when running a particular task and below is my code. ERROR! conflicting action statements: command, prompt
Looking for some suggestions.
Code:
  - name: install 
    command: /tmp/install.run
    prompt: 
      - Installation path? "[/tmp/output]":
    when: condition
As written, your question is hard to figure out. Do you GET that error message?? What are you actually trying to do? And posting 5 lines of an entire Ansible playbook doesn't give anyone much to work with. You've been working with Ansible for a few years now...have you referenced their docs?
https://www.linuxquestions.org/quest...le-4175712393/

Post a clear question with clear errors/messages, and we can try to help.
 
Old 04-13-2023, 12:26 PM   #3
1s440
Member
 
Registered: Mar 2018
Posts: 266

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Maybe, so you should probably do a search for this and find it, rather than asking us to look it up for you.


As written, your question is hard to figure out. Do you GET that error message?? What are you actually trying to do? And posting 5 lines of an entire Ansible playbook doesn't give anyone much to work with. You've been working with Ansible for a few years now...have you referenced their docs?
https://www.linuxquestions.org/quest...le-4175712393/

Post a clear question with clear errors/messages, and we can try to help.
well working with ansible should not mean that i should have knowledge on all topics. I am looking for some interactive prompts. I have referenced the docs and seems they donot have option using both shell and prompt at a time. hence i am asking here for the same if anyone has tried it.

Or it’s easier to do it with bash .. and then call script via ansible.

Last edited by 1s440; 04-13-2023 at 01:13 PM.
 
Old 04-13-2023, 02:16 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,656

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by 1s440 View Post
well working with ansible should not mean that i should have knowledge on all topics. I am looking for some interactive prompts. I have referenced the docs and seems they donot have option using both shell and prompt at a time. hence i am asking here for the same if anyone has tried it. Or it’s easier to do it with bash .. and then call script via ansible.
Really??? You looked at the Ansible documentation?? Funny, I found this:
https://docs.ansible.com/ansible/lat...%20flexibility.

And you couldn't find it?? Even after two years experience with Ansible?
 
Old 04-14-2023, 02:24 AM   #5
1s440
Member
 
Registered: Mar 2018
Posts: 266

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Really??? You looked at the Ansible documentation?? Funny, I found this:
https://docs.ansible.com/ansible/lat...%20flexibility.

And you couldn't find it?? Even after two years experience with Ansible?
hello first stop critzing people. also read the question or my answer given. everytime i post something you always wanted me to say something which is not fair. And you dont have to talk to me regarding my experience.

Last edited by 1s440; 04-14-2023 at 02:32 AM.
 
1 members found this post helpful.
Old 04-14-2023, 08:52 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,656

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by 1s440 View Post
hello first stop critzing people. also read the question or my answer given. everytime i post something you always wanted me to say something which is not fair. And you dont have to talk to me regarding my experience.
You claim to have referenced the docs, and couldn't find anything...yet just putting "ansible interactive prompt" into any search-engine pulls up the ansible docs, with the page you were handed. You can't say you read the docs when the answer to exactly what you're asking is IN those documents.

Your question was read, and you asked how to get an ansible playbook to ask questions/prompt users. You have been working with ansible for a good while, and claimed to have looked for solutions in the documentation, and the answer to your question was in what you claimed to look at. Which is how to get interactive prompts. You were also asked to clarify things, since (again) your question was unclear. Not sure how python or regex fits into any of this, when you can use ansible native to prompt users for things, but you never clarified.

So, read the docs and follow them. Use your knowledge and experience.
 
Old 04-14-2023, 10:19 AM   #7
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,141
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
Quote:
ansible uses python regex.
Do you mean using re?
https://docs.python.org/3/library/re.html
https://www.guru99.com/python-regula...-tutorial.html
https://www.geeksforgeeks.org/python-regex/
 
Old 04-14-2023, 03:42 PM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,235

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Look, 1s440. We don't mean to give you a hard time. It's just that no-one can tell what you're actually asking for.
 
1 members found this post helpful.
Old 04-14-2023, 04:49 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,656

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by dugan View Post
Look, 1s440. We don't mean to give you a hard time. It's just that no-one can tell what you're actually asking for.
Agreed, and this pattern often repeats. The OP seems to ask about how to make an ansible playbook that has interactive prompts, which is documented/supported by ansible. They were given a link to the documentation (which they said they read, and didn't see anything about it). They have the instructions, and at least two years experience with ansible...hard to know why they can't apply what's documented to give them what they want.
 
Old 04-17-2023, 03:41 AM   #10
1s440
Member
 
Registered: Mar 2018
Posts: 266

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Agreed, and this pattern often repeats. The OP seems to ask about how to make an ansible playbook that has interactive prompts, which is documented/supported by ansible. They were given a link to the documentation (which they said they read, and didn't see anything about it). They have the instructions, and at least two years experience with ansible...hard to know why they can't apply what's documented to give them what they want.


I clearly quoted "command " and "prompt" together doesn't work. In the ansible documentation they dont have option to use "command" but just prompting questions and answer.

Code:
vars_prompt:

  - name: my_password2
    prompt: Enter password2
    private: true
    encrypt: sha512_crypt
    confirm: true
    salt_size: 7
I am looking something like
Code:
  - name: my_password2
    command: /tmp/install.run
    prompt: Enter password2
    private: true
    encrypt: sha512_crypt
    confirm: true
    salt_size: 7
I know this is possible using expect module but expect module doesnot have interactions. Hence asked for help here. If my question is not clear, better you can tell me to explain clearly and you donot have to point me regarding my experience again and again.

And its clear ansible doesnot have option like this hence closing this case

Last edited by 1s440; 04-17-2023 at 03:46 AM.
 
Old 04-17-2023, 08:22 AM   #11
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,656

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by 1s440 View Post
I clearly quoted "command " and "prompt" together doesn't work. In the ansible documentation they dont have option to use "command" but just prompting questions and answer.
Code:
vars_prompt:
  - name: my_password2
    prompt: Enter password2
    private: true
    encrypt: sha512_crypt
    confirm: true
    salt_size: 7
I am looking something like
Code:
  - name: my_password2
    command: /tmp/install.run
    prompt: Enter password2
    private: true
    encrypt: sha512_crypt
    confirm: true
    salt_size: 7
I know this is possible using expect module but expect module doesnot have interactions. Hence asked for help here. If my question is not clear, better you can tell me to explain clearly and you donot have to point me regarding my experience again and again. And its clear ansible doesnot have option like this hence closing this case
No, it's clear you haven't done much research, since (again) it's covered in the Ansible docs, which someone with experience should know to reference first. And this is the same clear question you were asked to provide in post #2, since none of us could figure out what you were asking.

From Ansible docs:
https://docs.ansible.com/ansible/lat...pt_module.html
https://docs.ansible.com/ansible/lat...ll_module.html

So between the three things looked up for you, you can:
  • Prompt a user for input
  • Run a script while passing that input
What else would you like???
 
Old 04-17-2023, 08:54 AM   #12
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Code:
- name: Install software
  hosts: localhost
  vars_prompt:
    - name: installation_path
      prompt: "Installation path? [/tmp/output]"
      default: "/tmp/output"
  tasks:
    - name: Run installation script
      command: /tmp/install.run {{ installation_path }}
It's just a matter of breaking your playbook up into the correct sections. You prompt for input and shove it into variables, then you take those variables and use them in a task.
 
Old 04-17-2023, 10:53 AM   #13
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,656

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by szboardstretcher View Post
Code:
- name: Install software
  hosts: localhost
  vars_prompt:
    - name: installation_path
      prompt: "Installation path? [/tmp/output]"
      default: "/tmp/output"
  tasks:
    - name: Run installation script
      command: /tmp/install.run {{ installation_path }}
It's just a matter of breaking your playbook up into the correct sections. You prompt for input and shove it into variables, then you take those variables and use them in a task.
+1 Totally correct.
 
Old 04-23-2023, 02:40 PM   #14
1s440
Member
 
Registered: Mar 2018
Posts: 266

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by szboardstretcher View Post
Code:
- name: Install software
  hosts: localhost
  vars_prompt:
    - name: installation_path
      prompt: "Installation path? [/tmp/output]"
      default: "/tmp/output"
  tasks:
    - name: Run installation script
      command: /tmp/install.run {{ installation_path }}
It's just a matter of breaking your playbook up into the correct sections. You prompt for input and shove it into variables, then you take those variables and use them in a task.
Unfortunately vars_prompt doesn’t work in my case. The vars_prompt questions are basically from installer.run file. When I run install.run file on remote hosts there were questions being asked which user has to answer. So I used expect module but with expect module It answers up to 3 questions and then I get „Installation aborted by user“

https://docs.ansible.com/ansible/lat...ct_module.html

.

Last edited by 1s440; 04-23-2023 at 02:41 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Ansible Guide: Create Ansible Playbook for LEMP Stack LXer Syndicated Linux News 0 04-13-2019 05:03 AM
LXer: Ansible Tutorial: Introduction to simple Ansible commands LXer Syndicated Linux News 0 05-21-2018 10:28 AM
LXer: Ansible Tutorial: Intorduction to simple Ansible commands LXer Syndicated Linux News 0 01-14-2018 05:37 PM
[SOLVED] differences between shell regex and php regex and perl regex and javascript and mysql golden_boy615 Linux - General 2 04-19-2011 01:10 AM
scp Good arugments? bkeating Linux - Software 3 10-21-2003 02:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Containers

All times are GMT -5. The time now is 07:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration