You need to check the current configuration settings of your Git environment. Display them. ee the Solution below. Solution: git config --list Explanation: Viewing configuration settings verifies the global and repository-specific settings for consistency.
Create an inventory file inventory.yml with a host web1 and a group web_servers. Assign the variable ansible_user as admin for web1. ee the Solution below. Solution: # inventory.yml all: children: web_servers:hosts: web1: ansible_user: admin Explanation: The inventory file assigns variables like ansible_user for specific hosts or groups. This configuration defines web1 under the web_servers group with admin as the remote user.
Create a directory structure where host variables for web1 are stored in host_vars/web1.yml and group variables for web_servers in group_vars/
Set up a playbook to display ansible_user for web1 using the inventory from inventory.yml. ee the Solution below. Solution: # playbook.yml - name: Display ansible_user hosts: web1 tasks: - debug: var: ansible_user Execution: ansible-playbook -i inventory.yml playbook.yml Explanation:The debug module helps display variable values, verifying the correct assignment of ansible_user from the inventory.
Override the SSH port for web1 in the host_vars/web1.yml file. ee the Solution below. Solution: 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.
You are given access to a Git repository with the URL https://github.com/example/repo.git. Clone the repository to your local machine in the directory /home/user/projects. ee the Solution below. Solution: cd /home/user/projects git clone https://github.com/example/repo.git Explanation: Cloning a repository retrieves all files, branches, and history to your local system. The git clone command initiates this process by downloading the specified repository.