Problem with Ansible Interview Questions

OP #7405160

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

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

Eine eigene Frage? Dieser Thread ist über 3 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.