ansible | 2.2 |
debian | 9 “stretch” |
Install Debian 8 into virtual box (name: debian8)
Login as root
ssh root@<target ip>
Install sudo & python
apt-get update apt-get install sudo python ssh mg
Add a deploy user & set a password
/sbin/adduser deploy
Add your user to the ‘sudo’ group within /etc/group
/sbin/adduser deploy sudo
Don’t ask for a password when using sudo, risky (optional) Note: This is optional if you are using the -b then there is no need for this. /etc/sudoers
%sudo ALL = NOPASSWD: ALL %sudo ALL= (postgres) NOPASSWD: ALL
Create passwordless access (server to client)
ssh-copy-id deploy@<target ip>
<Optionally take a snapshot here of your server>
Ansible 2.2 (currently the HEAD branch when you clone).
sudo apt-get install python-yaml python-jinja2 python-paramiko git clone https://github.com/ansible/ansible.git cd ansible git submodule update --init --recursive sudo make install
(Make sure you do not have any other ansible installed through your systems package manager).
Clone this repo (ansible-recipes)
git clone https://github.com/map7/ansible_recipes.git
Install the roles
sudo ansible-galaxy install Heroqu.nodejs4x sudo ansible-galaxy install mtpereira.passenger
Add target’s IP to /etc/ansible/hosts file under the top ungrouped section EG:
192.168.0.100
sudo ansible-galaxy install -r requirements.yml --roles-path /etc/ansible/roles --force
Now you can run with this command (on the development machine)
For server boxes
ansible-playbook webserver.yml -b -v
-b | become sudo |
-v | verbose |
For dev (non server) boxes
ansible-playbook dev.yml -K -v
-K | ask for sudo password and pass |
-v | verbose |
NOTES
- For an encypted ssh key file with password, to prevent always being asked for password
eval `ssh-agent` ssh-add /home/user/.ssh/id_rsa
- With mysql I leave the password blank for the root user until I’ve finished setup, then manually assign a new password using the following;
mysqladmin -u root password 'newpassword'
Create your custom variables in vars/custom.yml (this is ignored in the repository) Place it at the bottom of your vars list to override the defaults I’ve set.
ansible <target ip> -m setup
media_center | Installs XBMC with LTSP (fat-clients) |
ltsp_thin | Thin client server |
ltsp_fat | Fat client server |
webserver | Ruby on Rails server |
- [X] Look at changes from 1.2 to 1.5 and optimise
- [X] Update any ‘cp’ command to using the copy module. Since ansible 1.4 the copy module allows recursive copy.