Introduction
In this post, I used the Ansible aws_ec2 plugin which allowed me to control and configure these virtual machines.
---
plugin: aws_ec2
regions:
- eu-central-1
filters:
tag:Project: num3
compose:
ansible_host: public_ip_address
hostnames:
- name: 'dns-name'
separator: '_'
prefix: 'tag:Name'
- private-ip-address
- dns-name
keyed_groups:
- key: tags['Name']
prefix: tag
This ansible inventory specifies regions and filters them based on the ‘Project: num3’ tag. It defines how Ansible should communicate with the instances based on their ‘Name’ tag.
To verify the setup and check all ec2 instances with the ‘Project: num3’ name tag, I ran the following command:
ansible-inventory -i aws_ec2.yml --graph
Output:
@all:
|--@aws_ec2:
| |--Jenkins Server_ec2-18-197-111-73.eu-central-1.compute.amazonaws.com
| |--Jmeter Server_ec2-18-196-31-8.eu-central-1.compute.amazonaws.com
| |--Mattermost Server_ec2-18-153-92-64.eu-central-1.compute.amazonaws.com
| |--Rocketchat Server_ec2-3-67-8-171.eu-central-1.compute.amazonaws.com
| |--Zabbix Server_ec2-3-70-52-119.eu-central-1.compute.amazonaws.com
|--@tag_Jenkins_Server:
| |--Jenkins Server_ec2-18-197-111-73.eu-central-1.compute.amazonaws.com
|--@tag_Jmeter_Server:
| |--Jmeter Server_ec2-18-196-31-8.eu-central-1.compute.amazonaws.com
|--@tag_Mattermost_Server:
| |--Mattermost Server_ec2-18-153-92-64.eu-central-1.compute.amazonaws.com
|--@tag_Rocketchat_Server:
| |--Rocketchat Server_ec2-3-67-8-171.eu-central-1.compute.amazonaws.com
|--@tag_Zabbix_Server:
| |--Zabbix Server_ec2-3-70-52-119.eu-central-1.compute.amazonaws.com
|--@ungrouped:
Project Directory Structure
├── ansible.cfg
├── aws_ec2.yml
├── jenkins
│ ├── jenkins.yml
│ └── var.yml
├── jmeter
│ ├── jmeter.yml
│ └── var.yml
├── mattermost
│ ├── mattermost.yml
│ ├── roles
│ │ ├── mattermost
│ │ │ ├── files
│ │ │ │ └── mattermost.service
│ │ │ └── tasks
│ │ │ └── mattermost_server.yml
│ │ ├── nginx
│ │ │ ├── files
│ │ │ │ ├── mattermost
│ │ │ │ └── nginx.conf
│ │ │ └── tasks
│ │ │ └── nginx.yml
│ │ ├── postgres
│ │ │ └── tasks
│ │ │ └── psql.yml
│ │ └── zabbix_agent
│ │ └── tasks
│ │ └── zabbix_agent.yml
│ └── vars.yml
├── rocketchat
│ ├── rocketchat.yml
│ ├── roles
│ │ ├── mongodb
│ │ │ └── tasks
│ │ │ └── mongo.yml
│ │ ├── nginx
│ │ │ ├── files
│ │ │ │ ├── nginx.conf
│ │ │ │ └── rocketchat
│ │ │ └── tasks
│ │ │ └── nginx.yml
│ │ ├── npm
│ │ │ └── tasks
│ │ │ └── npm.yml
│ │ ├── rocketchat
│ │ │ ├── files
│ │ │ │ ├── mongod.conf
│ │ │ │ ├── override.conf
│ │ │ │ └── rocketchat.service
│ │ │ └── tasks
│ │ │ └── rocketchat_server.yml
│ │ └── zabbix_agent
│ │ └── tasks
│ │ └── zabbix_agent.yml
│ └── vars.yml
└── zabbix
├── roles
│ ├── nginx
│ │ └── tasks
│ │ └── nginx.yml
│ ├── postgres
│ │ └── tasks
│ │ └── psql.yml
│ └── zabbix
│ └── tasks
│ └── zabbix_server.yml
├── vars.yml
└── zabbix.yml
This structure was the backbone of my entire setup. It helped me to to managing a complex infrastructure and multiple services.
I used directories organized by the services they represent (Jenkins, JMeter, Mattermost, Rocketchat, Zabbix). Each service directory contains specific configurations and roles tailored to that service. These modules simplified maintenance and allowed me to work on each service independently.
It was also role based configuration that iin each service directory, there were roles and tasks defined. For example, the Mattermost directory includes roles for Mattermost, Nginx, PostgreSQL, and Zabbix Agent, each with their respective files and tasks.
Conclusion
In summary, this project represents a straightforward method to deploy, configure, test, and monitor various services running on these instances. Due to the substantial amount of text, I couldn’t post all the details on this blog. For further information, please refer to my Git repository here: My Git repo for Installing
In the next post, I will create a simple test plan and attempt to generate load on the two chat servers.