Final Exam Flashcards
Writing a module, regardless of language, requires what minimal information in the output so Ansible can properly run the modules?
- {“changed”:,”output”:”string”}
- {}
- “changed”=true,output=”string”
- Ansible doesn’t need output from a module
(2) {}
Ansible requires a JSON dictionary to be returned. The minimum dictionary is an empty dictionary.
When specifying more than one conditional requirements for a task, what is the proper form?
- -when: foo == “hello” and bar == “world”
- -when: foo == “hello” && bar == “world”
- -when: foo is “hello” and bar is “world”
- -when: foo == “hello”
- when: bar == “world”
-when: foo == “hello” and bar == “world”
What is the proper way of referencing a variables value in an Ansible task?
- ${variable_name}
- {variable_name}
- @variable_name
- ”{{variable_name}}”
(4) “{{variable_name}}”
How are variables referenced in an Ansible template
{{ variable }}
When running a playbook on remote target host you receive Python error similar to “[Error 13] Permission denied: ‘/home/nick/.ansible/tmp’.” What would be the most likely propblem?
- The user running ‘ansible-playbook’ must run it from their own directory
- The user’s home or .ansible directory on the Ansible remote host is not writeable by the user running the play
- The specified user does not exist on the remote system
- The user’s home or .ansible directory on the Ansible system is not writeable by the user running the play.
(2) The user’s home or .ansbl directory on the Ansible remote host is not writeable by the user running the play.
What ansible tool or method greatly enhances ability to reuse and share roles?
Ansible Galaxy: ansible-galaxy
In ansible, how can a task be run in “fire and forget” method?
- Use asnchronous mode but don’t poll the task
- Use shell to call a bash command and add ‘&’ to the end of the command
- Use asynchronous mode and set ‘async: 0’
- Use asynchronous mode and set ‘poll: 0’
Use asynchronous mode and set ‘poll: 0’
When using a role, where is the best location for setting default values for your variables?
- roles/vars/main.yml
- role/default/main.yml
- The master playbook
- Using –extra-vars on the command line
role/default/main.yml
How are roles called from a play?
- -roles:
- role:
- include:
- include: { role: }
-roles:
Which of the following is an invalid variable name in Ansible?
- host-first-ref
- Host1stRef
- host_first_ref
- host1st_ref
(1) host-first-ref
Valid variable names can contain only letters, numbers, and underscores
When writing an Ansible module using Python with the Ansible supplied helper module, what is the best way to return results to Ansible?
- Print json formatted output
- Using the JSON python module, use ‘json.dumps’ with a Python dictionary of results
- Write the results back to a file for Ansible to read in
- Use the exit_json and fail_json functions
Use the ‘exit_json’ and ‘fail_json’ functions.
Sometimes it is needed to call a roll dependency more than once. Ansible, by default, only calls a roll once unless the arguments are different. How can this be overridden in Ansible?
- Add ‘allow_duplicates: yes’ declarative in the playbook
- Add ‘run_always: yes’ declarative in the playbook
- This can not be overriden in Ansible
- Run the playbook with ‘–alow-duplicates’ on the command line
Add ‘allow_duplicates: yes’ declarative in the playbook.
How can Ansible be configured to invoke the interactive debugger when an error in the playbook is encountered?
- Set –debugger on the command line
- Set ‘strategy:debug’ in the play
- Call the debug module with parameter ‘interactive:true’
- Set ‘debugger: true’ in the play
(3) ‘strategy:debug’
Which resource can not be defined in an Ansible playbook?
- Fact Gathering State
- Inventory File
- Host Groups
- Variables
(2) Inventory File
Which of the following capabilities is not supported by Ansible Galaxy?
- Create filesystems structure for new roles
- Authenticate to Galaxy Hub for role development an management
- Manage existing roles
- Credential management
Ansible does not support
- (4) Credential management