Automation

From wiki.kungfootek.net
Revision as of 15:25, 4 August 2017 by Daniel Baker (talk | contribs) (→‎Ansible)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sudo and Sudoers

Sometimes you want to be able to allow daemons to do things as root but without giving the root password away.

Yes, this *can* be a stupid thing to do.

<user_account> ALL=(ALL)   NOPASSWD: ALL
#Defaults    requiretty
#Defaults   !visiblepw
Add the top line, comment out the second two and test.

These entries may not be arranged as above.

VirtualBox

More details can be found on the tecmint website on the topic: 'how-to-install-vagrant-on-centos-7'

cd /etc/yum.repo.d
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
yum install -y VirtualBox-5.1
/sbin/rcvboxdrv setup

Vagrant

yum -y install https://releases.hashicorp.com/vagrant/1.9.6/vagrant_1.9.6_x86_64.rpm


The most basic setup using only Vagrant:

 ] cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
  # https://docs.vagrantup.com.
  # boxes at https://vagrantcloud.com/search.

Vagrant.configure("2") do |config|
  config.vm.provider "virtualbox" do |vb|
  vb.memory = "1024"
end

  config.vm.box = "centos/7"
  config.vm.network "public_network", bridge: "enp0s25", ip: "10.245.5.210"
  config.vm.synced_folder "./data", "/data"
  config.vm.provision "shell", inline: <<-SHELL
  yum -y install vim lynx nmap
  mkdir -p /vagrant/data
  cp /vagrant/data/.bashrc /home/vagrant/.bashrc
  cp /vagrant/data/vimrc /etc/vimrc
  cat /vagrant/data/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
  SHELL
end


Ansible

yum -y install ansible
 ]cat provisioning/playbook.yml
---
- hosts: all
  become: true
  tasks:
    - name: Install VIM
      yum: name=vim state=present update_cache=yes
    - name: Install lynx
      yum: name=lynx state=present update_cache=yes
    - name: Install nmap
      yum: name=nmap state=present update_cache=yes
    - name: Add the private ssh key
      authorized_key:
        user: vagrant
        state: present
        key: "{{ lookup('file', '/path/to/key/id_rsa.pub') }}"