Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated linode ansible module and provision playbook and added delete playbook #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
289 changes: 289 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@

# Created by https://www.toptal.com/developers/gitignore/api/linux,windows,macos,vim,emacs,ansible,python
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,windows,macos,vim,emacs,ansible,python

### Ansible ###
*.retry

### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*

# Org-mode
.org-id-locations
*_archive

# flymake-mode
*_flymake.*

# eshell files
/eshell/history
/eshell/lastdir

# elpa packages
/elpa/

# reftex files
*.rel

# AUCTeX auto folder
/auto/

# cask packages
.cask/
dist/

# Flycheck
flycheck_*.el

# server auth directory
/server/

# projectiles files
.projectile

# directory configuration
.dir-locals.el

# network security
/network-security.data


### Linux ###

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytestdebug.log

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
doc/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
pythonenv*

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# profiling data
.prof

### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/linux,windows,macos,vim,emacs,ansible,python

vars/config.yml
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
# ansible-playbook-linode


An super simple ansible playbook to provision a new linode server,
set its hostname and FQDN,
deploy a public ssh key under its root account,
disable password based ssh login (changes /etc/ssh/sshd_config).
Enabled password based ssh login (changes /etc/ssh/sshd_config).

Each time you run it, it creates a NEW LINODE SERVER.

### Defaults:

The default configuration (`vars/config.yml`) creates a Linode 1024 in Fremont, CA, USA.
It gives it 1GB swap (it's on SSD) and installs Ubuntu 14.04 LTS.
It gives it 1GB swap (it's on SSD) and installs Debian 9.

### Installation

Install the official Python library for the Linode API v4.

pip install linode_api4

### Usage:

Copy sample config `vars/config.yml.example` to `vars/config.yml`.

Change variables in `vars/config.yml` to suit your needs.

Then, deploy instance by running playbook `provision.yml`

```
$ export LINODE_API_KEY=4kfjh59shlhdkjhksdj00sdsTTsskklkjoiRPrbDtgHY
$ ansible-playbook --extra-vars server_hostname=hades provision.yml
$ export LINODE_API_KEY="Enter Your API KEY"
$ ansible-playbook provision.yml
```

After the playbook finishes, you can login via ssh as root@THE-IP-IN-THE-OUTPUT.

### Cleanup

finally cleanup the instance by running playbook `delete.yml`

```
$ export LINODE_API_KEY="Enter Your API KEY"
$ ansible-playbook delete.yml
```
24 changes: 24 additions & 0 deletions delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# 2020/12/05 by Pratik Raj
#
# An ansible playbook to Delete linode server by Instance Label
#
# Usage:
#
# export LINODE_API_KEY=4kfjh59shlhdkjhksdj00sdsTTsskklkjoiRPrbDtgHY
# ansible-playbook delete.yml
#
- name: Delete linode server
hosts: localhost
connection: local
gather_facts: false

vars_files:
- vars/config.yml

tasks:
- name: Delete your Linode Instance.
linode_v4:
access_token: "{{ token }}"
label: "{{ label }}"
state: absent
3 changes: 1 addition & 2 deletions files/ssh/sshd_config
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PermitEmptyPasswords no
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes
PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
Expand Down Expand Up @@ -89,4 +89,3 @@ UsePAM yes

# Morpht
UseDNS no
PasswordAuthentication no
Loading