/ajk-simple-sop-installation

SOP Lab AJK using basic ansible

Primary LanguagePython

# Automation SOP AJK Using Ansible

● Current Requirements

No Name Version Function
1 Ansible 2.8.4 or latest Automation tools
2 Python 3.6.8 or latest Running SSH Key Gen script
3 SSHPASS 1.06 or latest Forced using password inline

● Goals

No Name
1 Terminator
2 Chrome
3 VSCode
4 Apache2
5 MySQL
6 Virtualbox
7 PHP
8 Git
9 Tmux
10 pip3
11 npm
12 Node.js
13 Htop

>> Tested on Ubuntu Desktop 18.04 LTS

● Step 1 - Prepare

>> Prepare File Needed
  1. Clone this repository
$ git clone https://github.com/cphikmawan/automation-sop-ajk-using-ansible
  1. Rename hosts.bak to hosts
$ mv hosts.bak hosts
  1. Rename hosts.json.bak with hosts.json
$ mv hosts.json.bak hosts.json
>> SSH Key Gen
  1. Generate ssh-keygen on master host
$ ssh-keygen -t rsa
  1. Copy ssh-key-id to remoted host
$ ssh-copy-id username@host
  1. Try to ssh into remoted host
$ ssh username@host
>> SSH Key Gen With Script

If you want automation using script try to run gen.py

  1. Edit hosts.json with your remoted servers
  2. run gen.py
$ python3 gen.py
  1. Done

● Step 2 - Configuration & Connection

  1. Edit hosts file with remoted server what ever you want, example:
[workstation]
10.0.0.1 ansible_user=cloudy ansible_become_pass=secret
  1. Test connection from master host to remoted host
$ ansible workstation -m ping
  1. Success output
10.0.0.1 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    }, 
    "changed": false, 
    "ping": "pong"
}

● Step 3 - Run The Playbook

  1. Run the playbook
$ ansible-playbook main.yml
  1. Enjoy :)

Additional Example Running Apache2 Service From Website

Requirements
  • Python3
  • Virtualenv
  • Pip3
  • Flask
Step
  1. Install pip3
$ sudo apt install python3-pip
  1. Install requirements
$ pip3 install -r requirements.txt
  1. Change directory to webs
$ cd webs
  1. Edit directory path on app.py
home = 'path/to/directory'
  1. Export
$ export FLASK_APP=app.py
$ export FLASK_ENV=development
$ flask run
  1. Access web on http://localhost:5000/

References

Created with <3 By Cloudy