0. Introduction.
Q: Which operating system utilizes Ansible the most?
A: Linux
1. Building Great Tasks.
Q: Instead of using a loop to supply multiple items and specifying name: '{{item}}', what is recommended?
A: using name: '{{packages}}' and removing the loop
Q: Which Ansible default group contains every host?
A: The all group.
Q: Which statement is the recommended approach for conditional executions?
A: The when statement.
Q: Which option indicates a verbosity level of 3 when running tasks against the localhost?
A: Control_Node> ansible-playbookcontrolnode.yml -vvv
Q: Which command will run a playbook in check mode?
A: Control_Node> ansible-playbook use_templates.yml --check
Q: What is used inside of a playbook in order to carry out actions against a host?
A: Tasks
Q: If you are running the playbook interactively through the command line and type in the following command, what will be returned first?
Control_Node> ansible-playbook tags.yml --step
A: Perform task: TASK: Gathering Facts (N)o/(y)es/(c)ontinue:
Q: When running tasks against the localhost, what is the default verbosity?
A: 0
Q: You are using an aws_ec2 example to create a dynamic inventory file. What is the correct syntax for using the private IP address field value when connecting to the Ansible host?
A:
compose:
ansible_host: private_ip_address
Q: When using variables inside playbooks, what is the correct syntax?
A: dest: '{{temp_file}}'
Q: Which templating engine is Ansible built to use?
A: Jinja2
2. Using Roles
Q: Consider the file below. If you uncomment the entry that gives the default location for roles in the system, what would the result be?
Control_Node> cat /etc/ansible/ansible.cfg
A: roles_path = etc/ansible/roles
Q: What can you include inside of your roles to briefly explain the details of a project?
A: A README file.
Q: By default, what does Ansible look for in each directory within a role?
A: For a main.yml file.
Q: How can you create a role-based template?
A: Move the template into the templates directory of the role.
Q: Which command option, when added to the playbook ansible-playbook roles.yml, will override all other variables?
A: -e
3. Using Secrets
Q: Which option will create a new encrypted file?
A: Control_Node> ansible-vault create test1.yml
Q: What is an example of a secret in Ansible?
A: Tokens
Q: What needs to be provided at the end of the following code to encrypt the string?
Control_Node> ansible-vault encrypt_string --vault-id @prompt
A: The string you want encrypted.
4. Performing Network Management
Q: Consider the code below. If your IP gateway address is 10.10.0.1 and your network mask is 255.255.255.224, what will be returned when you run the command Control_Node> ansible-playbook ip_address.yml?
tasks:
- set_fact: ip1="{{ipgw}}/{{ipnm}}"
- set_fact: ip2="{{ip1|ipaddr('network/prefix')}}"
- debug:
msg: "Our network is {{ip2}}, gateway is {{ipgw}}"
A:
TASK [debug]
ok: [localhost] => {
"msg": "Our network is 10.10.0.0/27, gateway is 10.10.0.1"
}
Q: What is Ansible expecting to see on the node that it will be managing?
A: SSH and Python.
5. Leveraging Indempotence
Q: What does idempotence mean?
A: You can execute commands over and over again without changing the result or the target.
Q: Which command will modify the cat register_state.yml file in place?
A: The sed command.
Q: When working out the registration of state by grepping the command, what is returned to indicate success?
A: "grep_state.rc": "0"
Comments
Post a Comment