LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Containers (https://www.linuxquestions.org/questions/linux-containers-122/)
-   -   ansible regex arugments (https://www.linuxquestions.org/questions/linux-containers-122/ansible-regex-arugments-4175724022/)

1s440 04-13-2023 03:34 AM

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


TB0ne 04-13-2023 07:31 AM

Quote:

Originally Posted by 1s440 (Post 6424216)
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.

1s440 04-13-2023 12:26 PM

Quote:

Originally Posted by TB0ne (Post 6424245)
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.

TB0ne 04-13-2023 02:16 PM

Quote:

Originally Posted by 1s440 (Post 6424300)
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?

1s440 04-14-2023 02:24 AM

Quote:

Originally Posted by TB0ne (Post 6424322)
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.

TB0ne 04-14-2023 08:52 AM

Quote:

Originally Posted by 1s440 (Post 6424432)
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.

teckk 04-14-2023 10:19 AM

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/

dugan 04-14-2023 03:42 PM

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.

TB0ne 04-14-2023 04:49 PM

Quote:

Originally Posted by dugan (Post 6424600)
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.

1s440 04-17-2023 03:41 AM

Quote:

Originally Posted by TB0ne (Post 6424616)
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

TB0ne 04-17-2023 08:22 AM

Quote:

Originally Posted by 1s440 (Post 6425148)
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???

szboardstretcher 04-17-2023 08:54 AM

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.

TB0ne 04-17-2023 10:53 AM

Quote:

Originally Posted by szboardstretcher (Post 6425203)
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.

1s440 04-23-2023 02:40 PM

Quote:

Originally Posted by szboardstretcher (Post 6425203)
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

.


All times are GMT -5. The time now is 09:54 AM.