Forum: PC-Programmierung Problem with Ansible Interview Questions


von Ashna S. (ashna_s)


Lesenswert?

I am having a problem with the Ansible 
questions:(https://www.interviewbit.com/ansible-interview-questions/) 
for job preparations .I am trying to answer the questions but the code 
is not working properly. I have tried several methods of troubleshooting 
but have not been able to solve the problem.

Here is the code I am using:
1
import ansible
2
3
ansible.setup(
4
  hosts: ["host1", "host2", "host3"],
5
  roles: [
6
    {
7
      name: 'web',
8
      tasks: [
9
        {
10
          name: 'Install web server',
11
          register: 'result',
12
          command: 'apt-get install nginx -y'
13
        }
14
      ]
15
    }
16
  ]
17
)
18
19
ansible.run

I would greatly appreciate any help or advice to resolve this issue. 
Thank you.

: Bearbeitet durch User
von Harald K. (kirnbichler)


Lesenswert?

Ashna S. schrieb:
> but the code is not working properly

This is a very precise description. Not.

Describe, what you expect the code to do.

Describe, what the code does instead.

Change the code by inserting log outputs (or whatever your programming 
environment has instead of it) so that you can follow your code's 
execution step by step.

Check if your programming environment has a debugger, use that.

> I have tried several methods of troubleshooting
> but have not been able to solve the problem.

Did any of these several methods give you any information, any error 
messages or similar?

Did you read the documentation?

von Oliver S. (oliverso)


Lesenswert?

Harald K. schrieb:
> Describe, what you expect the code to do.

And the open ChatGPT, and let it create the code...

Oliver

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.