Problem with Ansible Interview Questions

OP #7405160
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.

#7405171
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?

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren