
Exam Questions Answers Braindumps EX374 Exam Dumps PDF Questions
Download Free RedHat EX374 Real Exam Questions
NEW QUESTION # 116
Replace a substring in all elements of a list.
Answer:
Explanation:
- name: Replace substrings hosts: localhost
vars:
items: ["file_1.log", "file_2.log", "file_3.log"] tasks:
- name: Transform filenames debug:
var: "{{ items | map('regex_replace', '_', '-') | list }}"
Explanation:
The regex_replace filter applies pattern-based transformations to all elements in a list.
NEW QUESTION # 117
Configure a playbook to dynamically retrieve the ansible_host variable of a host and display it.
Answer:
Explanation:
# playbook.yml
- name: Retrieve ansible_host hosts: web1
tasks:
- debug:
var: ansible_host
Explanation:
Dynamic variable retrieval helps validate host-level settings such as IP addresses or DNS names.
NEW QUESTION # 118
You are asked to pull the latest changes from the main branch of the remote repository into your local branch. Perform this operation.
Answer:
Explanation:
git pull origin main
Explanation:
Pulling updates the local branch with the latest remote changes, merging any new commits into your local repository.
NEW QUESTION # 119
Override the SSH port for web1 in the host_vars/web1.yml file.
Answer:
Explanation:
echo "ansible_port: 2222" >> host_vars/web1.yml
Explanation:
The ansible_port variable specifies the SSH port for a host. Adding it to host_vars ensures the override is host-specific.
NEW QUESTION # 120
Retrieve the hostname of a managed node using the ansible_hostname fact and display it.
Answer:
Explanation:
- name: Get hostname hosts: all
tasks:
- name: Display hostname debug:
var: ansible_hostname
Explanation:
Using the ansible_hostname fact allows playbooks to dynamically adapt to each managed node's hostname.
NEW QUESTION # 121
Write a playbook to run a task as a non-root user and use become to escalate privileges for that task.
Answer:
Explanation:
# playbook.yml
- name: Update and install packages hosts: all
tasks:
- name: Update apt cache
become: yes apt: update_cache: yes
Explanation:
The become: yes directive allows privilege escalation for specific tasks, enabling actions requiring elevated permissions without running the entire playbook as root.
NEW QUESTION # 122
Use lookup to retrieve the latest modification time of a file.
Answer:
Explanation:
- name: Get file modification time hosts: localhost
tasks:
- name: Fetch modification time set_fact:
mod_time: "{{ lookup('pipe', 'stat -c %y /tmp/example.txt') }}"
- debug:
var: mod_time
Explanation:
The pipe plugin retrieves external command output, enabling access to file metadata like modification time.
NEW QUESTION # 123
List all available EEs in the Automation Controller.
Answer:
Explanation:
1. Log in to Automation Controller.
2. Navigate to Execution Environments to view all registered EEs.
Explanation:
Viewing the list of EEs helps administrators track available environments and their configurations.
NEW QUESTION # 124
Run a playbook in an EE using Ansible Automation Controller.
Answer:
Explanation:
1. Log in to the Automation Controller web UI.
2. Go to Execution Environments and create a new EE entry using the image registry.example.com/my_execution_env:1.0.
3. Associate the EE with a Job Template and run the playbook.
Explanation:
Configuring the EE in the Automation Controller ensures playbooks run consistently across environments.
NEW QUESTION # 125
Run a command on db1 but store the results in the context of web1.
Answer:
Explanation:
- name: Store delegated results hosts: web1
tasks:
- name: Get uptime from db1
command: uptime
delegate_to: db1
register: db1_uptime
- name: Display uptime debug:
var: db1_uptime
Explanation:
The register variable captures the results of a delegated task, storing them within the current host's context for further processing.
NEW QUESTION # 126
Use the lookup plugin to fetch an API token from a Vault secret file.
Answer:
Explanation:
- name: Fetch API token hosts: localhost tasks:
- name: Retrieve token set_fact:
api_token: "{{ lookup('file', '/etc/vault/api_token') }}"
- debug:
var: api_token
Explanation:
Securely retrieving sensitive data such as API tokens from external files prevents hardcoding credentials in playbooks.
NEW QUESTION # 127
Retrieve and display a list of available files in a directory using the lookup plugin.
Answer:
Explanation:
- name: List directory files hosts: localhost
tasks:
- name: Get files in directory set_fact:
files: "{{ lookup('pipe', 'ls /tmp') }}"
- debug:
var: files
Explanation:
The pipe lookup plugin executes shell commands, and here it lists files in /tmp. This data is stored in a variable for further processing.
NEW QUESTION # 128
Integrate a webhook with Automation Controller to trigger a job.
Answer:
Explanation:
1. Go to Job Templates and enable Webhook.
2. Configure the webhook URL in an external system.
Explanation:
Webhooks enable external triggers for jobs, facilitating integration with CI/CD pipelines or monitoring tools.
NEW QUESTION # 129
Tag an EE image with multiple tags for versioning.
Answer:
Explanation:
podman tag my_execution_env:1.0 registry.example.com/my_execution_env:latest podman tag my_execution_env:1.0 registry.example.com/my_execution_env:stable
Explanation:
Tagging an EE with multiple versions provides flexibility for different environments (e.g., latest, stable).
NEW QUESTION # 130
Configure a private registry in Automation Controller to fetch EEs.
Answer:
Explanation:
1. Navigate to Settings > Registries in the Automation Controller.
2. Add a new registry:
o Name: Private Registry
o URL: registry.example.com
o Authentication: Provide credentials.
3. Save the configuration and test connectivity.
Explanation:
Adding a private registry allows Automation Controller to securely fetch and use custom EEs.
NEW QUESTION # 131
Use delegation to restart a service on a specific host (db1) from a different host.
Answer:
Explanation:
- name: Restart service on db1 hosts: web1
tasks:
- name: Restart nginx service:
name: nginx
state: restarted delegate_to: db1
Explanation:
Delegating service management to another host ensures targeted actions on infrastructure components.
NEW QUESTION # 132
Set up notifications for job completions in Automation Controller.
Answer:
Explanation:
1. Navigate to Notifications.
2. Add a new notification:
o Type: Email, Slack, or Webhook.
o Configure details.
3. Link it to a job template.
Explanation:
Notifications provide immediate feedback on job status, improving monitoring and responsiveness.
NEW QUESTION # 133
Inspect the logs of an EE build process.
Answer:
Explanation:
podman logs $(podman ps -aq --filter ancestor=my_execution_env:1.0)
Explanation:
Inspecting logs helps troubleshoot issues that occur during the build process, ensuring a functional EE.
NEW QUESTION # 134
Test the connectivity of managed nodes from within the EE.
Answer:
Explanation:
podman run --rm -v $(pwd):/workspace -w /workspace my_execution_env:1.0 ansible all -m ping -i inventory.yml
Explanation:
Testing connectivity from within the EE ensures that the environment can interact with managed nodes correctly.
NEW QUESTION # 135
......
Latest RedHat EX374 Real Exam Dumps PDF: https://dumpstorrent.actualpdf.com/EX374-real-questions.html
