lab:ansible_virtualbox_autoboot_linux:test_the_first_ubuntu_vm_on_ansible
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lab:ansible_virtualbox_autoboot_linux:test_the_first_ubuntu_vm_on_ansible [2024/01/19 02:41] – [Confirm the Server is Up] user | lab:ansible_virtualbox_autoboot_linux:test_the_first_ubuntu_vm_on_ansible [2024/05/10 05:17] (current) – removed user | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Test the First Ubuntu VM on Ansible ====== | ||
- | In this step we will test the basic connectivity to our new server. | ||
- | |||
- | ===== Test SSH Access ===== | ||
- | - Log in to your host machine and become the user '' | ||
- | * Option 1 - ssh to your host machine as the user '' | ||
- | * Option 2 - log in as usual and run '' | ||
- | - SSH to the IP address of the new server | ||
- | * '' | ||
- | * The IP address is displayed on the VM's console screen when it starts up | ||
- | * Another option is to look at your router' | ||
- | * Yet another another option is nmap | ||
- | - The login succeeds without entering a password (you do need accept the fingerprint to add to the list of known hosts) | ||
- | * Will use the user '' | ||
- | |||
- | ===== Test Ansible to the New Server ===== | ||
- | ==== Create the Inventory File ==== | ||
- | hosts | ||
- | |||
- | ==== Confirm the Server is Up ==== | ||
- | anisble -i hosts ping | ||
- | |||
- | |||
- | |||
- | Under [nodes] add the IP address | ||
- | |||
- | |||
- | Run some test Ansible ad hoc commands | ||
- | <code bash> | ||
- | ansible -i hosts all --list-hosts | ||
- | ansible -i hosts all -m ping | ||
- | ansible -i hosts servers -m ping | ||
- | ansible -i hosts servers -a "sudo / | ||
- | </ | ||
- | ==== Update Ubuntu ==== | ||
- | |||
- | <file yaml update_servers.yml> | ||
- | --- | ||
- | - hosts: nodes | ||
- | become: true | ||
- | become_user: | ||
- | tasks: | ||
- | - name: Update apt repo and cache on all Debian/ | ||
- | apt: update_cache=yes force_apt_get=yes cache_valid_time=3600 | ||
- | |||
- | - name: Upgrade all packages on servers | ||
- | apt: upgrade=dist force_apt_get=yes | ||
- | |||
- | - name: Check if a reboot is needed on all servers | ||
- | register: reboot_required_file | ||
- | stat: path=/ | ||
- | |||
- | - name: Reboot the box if kernel updated | ||
- | reboot: | ||
- | msg: " | ||
- | connect_timeout: | ||
- | reboot_timeout: | ||
- | pre_reboot_delay: | ||
- | post_reboot_delay: | ||
- | test_command: | ||
- | when: reboot_required_file.stat.exists | ||
- | </ | ||
- | |||
- | '' | ||
- | |||
- | ==== Disable DNS Stub Resolver ==== | ||
- | Even though each node receives its DNS information via DHCP, Ubuntu 22.04 will at times fail to resolve names. Rebooting solves the problem temporarily, | ||
- | |||
- | <file yaml disable_dns_stub.yml> | ||
- | --- | ||
- | - name: Disable DNS stub listener | ||
- | hosts: nodes | ||
- | remote_user: | ||
- | become: true | ||
- | tasks: | ||
- | - name: Disable DNS stub listener | ||
- | ini_file: dest=/ | ||
- | tags: configuration | ||
- | - name: Restart NetworkManager | ||
- | systemd: | ||
- | name: NetworkManager | ||
- | state: restarted | ||
- | - name: Restart systemd-resolved | ||
- | systemd: | ||
- | name: systemd-resolved | ||
- | state: restarted | ||
- | - name: daemon-reload | ||
- | systemd: | ||
- | daemon_reload: | ||
- | </ | ||
- | |||
- | ansible-playbook -i hosts disable-dns-stub.yml | ||
lab/ansible_virtualbox_autoboot_linux/test_the_first_ubuntu_vm_on_ansible.1705632071.txt.gz · Last modified: 2024/01/19 02:41 by user