Below is the topology that I have used to install the Apache webserver via Ansible.
Make sure the Debian server allows Linuxmint to access by using Public key authentication.
On Linuxmint sever.
Create a new tungapache.yaml file
---
- hosts: tunglamp
become: yes
vars:
firstname: "XXX"
lastname: "YYY"
tasks:
- name: Update Debian Server 10 System packages
become: yes
apt: update_cache=yes
- name: install apache2
apt: name=apache2 state=latest
- name: Copy index text page
template:
src: "files/index.html.j2"
dest: "/var/www/html/index.html"
Add Debian server with corresponding IP address information on hosts file.
Go to /etc/ansible directory and create a new files directory.
#pwd /etc/ansible
sudo mkdir files
sudo touch index.html.j2 && sudo nano index.html.j2
<html>
<head>
<title>{{ firstname}} - {{ lastname }}</title>
</head>
<body>
<h1>{{ firstname }} - {{ lastname }}</h1>
<h3>Welcome to Tung's Ansbile Test Page</h3>
<img src="http://imagefromtheinternet.jpg">
</body>
</html>
Run ansible-playbook to install apache webserver on remote Debian Linux server.
ansible-playbook -i /etc/ansible/hosts tungapache.yaml -u root
Check web content on the Debian server.
http://192.168.5.27/index.html