- Create a folder inventory with a hosts file in it
[server] # group name
{ip address}
{server name}
- Try to ping the servers with password
ansible -i ./inventory/hosts server -m ping --user sysadmin --ask-pass
- Create a folder playboos and has a yaml file apt.yml in it
- hosts: "*"
become:
tasks:
- name: apt
apt:
update_cache: yes
upgrade: 'yes'
- Run the playbook
ansible-playbook ./playbooks/apt.yml --user serveradmin --ask-pass --ask-become-pass -i ./inventory/hosts
- Create a file qemu-get-agent.yml under playbooks to install a module
- name: install latest qemu-guest-agent
hosts: "*"
tasks:
- name: install qemu-guest-agent
apt:
name: qemu-guest-agent
state: present
update_cache: true
become: true
- Add the mattermost playbook
---
- name: Install Mattermost Server
hosts: all
become: yes
vars:
mattermost_version: 5.31.0
mattermost_db_name: mattermost
mattermost_db_user: mmuser
mattermost_db_password: mmuser_password
tasks:
- name: Install necessary packages
apt:
name: "{{ item }}"
state: present
with_items:
- git
- nginx
- postgresql
- postgresql-contrib
- name: Create Mattermost user
user:
name: mattermost
state: present
- name: Clone Mattermost server
git:
repo: 'https://github.com/mattermost/mattermost-server.git'
dest: "/opt/mattermost-server"
version: "v{{ mattermost_version }}"
become: yes
become_user: mattermost
- name: Configure PostgreSQL
block:
- name: Create Mattermost database
postgresql_db:
name: "{{ mattermost_db_name }}"
login_user: postgres
- name: Create Mattermost database user
postgresql_user:
db: "{{ mattermost_db_name }}"
name: "{{ mattermost_db_user }}"
password: "{{ mattermost_db_password }}"
priv: ALL
login_user: postgres
- name: Set up Mattermost configuration
template:
src: mattermost_config.json.j2
dest: "/opt/mattermost-server/config/config.json"
owner: mattermost
mode: '0644'
- name: Start Mattermost service
systemd:
name: mattermost
state: started
enabled: yes