Code Monkey home page Code Monkey logo

ansible-centos7-python3-django's Introduction

CentOS 7 Python 3 & Django Ansible Playbooks and Roles

This repository holds Ansible playbooks and roles for configuring Python 3 & Django servers. You should be able to clone the repository and follow these steps to get a server up and running; this has been tested with Digital Ocean droplets.

You'll want to come up with a service account name that you'll use in place of your_project_ansible_user. After cloning this repository, edit ansible.cfg and change remote_user = your_project_ansible_user with the username you will use.

Preparing a Destination Server

The destination server will need to be kickstarted with CentOS 7. Log in as root to your freshly created Digital Ocean droplet (you used SSH keys, right?), and create a user called your_project_ansible_user on the destination server:

adduser your_project_ansible_user
passwd your_project_ansible_user
usermod -aG wheel your_project_ansible_user
chmod 640 /etc/sudoers

Then edit /etc/sudoers. Comment out the line that says # %wheel ALL=(ALL) ALL and uncomment the line that says %wheel ALL=(ALL) NOPASSWD: ALL. Then let's become the your_project_ansible_user user, and generate keys:

su - your_project_ansible_user
ssh-keygen

You will then need to add your public key from your host control machine to your_project_ansible_user's authorized keys in ~/.ssh/authorized_keys:

echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAv+IdIP7geRsOXUz7scIKTwkfxJ3J7UelRObTifdnmCHR6s53+irm9uVBP8se2IH1Vw4ETfjtdzI4vHce1lYwFVQx9V9cmKFyxCnroV7bTx6EPQ2WqkpAOfM5IGG7vGnrX3M0MPLrA0T8XrhPpCzM2GfNR8fqOQiPROP5blahblahblahblahblah5TQknqu7/twBtXuMpKakR4Vo08cq1MBJI8akEG/tzppoeYuRY8BzKqJVD+2Gp1RgBVsXLxX2W9ng6cFAHTRxs65koTWyVLCCCXsP54X4UqJRy1x5/PumL1VJn8LvXTGcOyfyFSBLClQ== [email protected]" >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys

Preparing a Destination Server

The destination server will need to be kickstarted with CentOS 7. Create a user called sepia_ansible on the destination server:

adduser sepia_ansible
passwd sepia_ansible
usermod -aG wheel sepia_ansible

Then edit /etc/sudoers and add these lines:

User_Alias        NO_SUDO_PASSWORD = sepia_ansible
NO_SUDO_PASSWORD  ALL = (ALL) NOPASSWD: ALL

You will then need to add your public key from your host control machine to sepia_ansible's authorized keys.

Getting started

Clone this repository.

git clone [email protected]:YourUsername/ansible-centos7-python3-django.git
cd ansible-centos7-python3-django.git

Edit the inventory file and add the destination servers.

[web-py]
dev.yourserver.com
123.34.56.789

Edit the ansible.cfg file and change the remote_user to the one you created above on the destination server.

remote_user = your_project_ansible_user

Deploy the dev environment:

ansible-playbook playbooks/web-py.yml

Show some servers:

ansible centos-7 --list-hosts
ansible web-py --list-hosts

Run some commands; shell is required for arguments and shell functions (command runs without the target user's shell):

ansible all -m command -a uptime -i inventory
ansible all -m shell -oa 'ps -eaf'
ansible rhel-7 -m copy -a 'content="Welcome to SEPIA, Ansiblized.\n" dest=/etc/motd' -u apache --become --become-user root

Documentation: list help section, show documentation for specific command (with examples!):

ansible-doc -l
ansible-doc yum

ansible-centos7-python3-django's People

Contributors

flipperpa avatar rsumner73 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.