first commit
This commit is contained in:
commit
c81a696979
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
.vagrant
|
||||
73
Vagrantfile
vendored
Normal file
73
Vagrantfile
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://vagrantcloud.com/search.
|
||||
config.vm.box = "generic/ubuntu2004"
|
||||
|
||||
config.vm.define "master" do | master |
|
||||
master.vm.hostname = "master"
|
||||
master.vm.network "private_network", ip: "192.168.33.10"
|
||||
master.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "master.yml"
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "minion01" do | minion01 |
|
||||
minion01.vm.hostname = "minion01"
|
||||
minion01.vm.network "private_network", ip: "192.168.33.20"
|
||||
minion01.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "master.yml"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
# NOTE: This will enable public access to the opened port
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine and only allow access
|
||||
# via 127.0.0.1 to disable public access
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
# config.vm.synced_folder "../data", "/vagrant_data"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
# vb.memory = "1024"
|
||||
# end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
# config.vm.provision "shell", inline: <<-SHELL
|
||||
# apt-get update
|
||||
# apt-get install -y apache2
|
||||
# SHELL
|
||||
end
|
||||
140
master.yml
Normal file
140
master.yml
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
---
|
||||
|
||||
- hosts: all
|
||||
|
||||
handlers:
|
||||
|
||||
- name: reboot
|
||||
reboot:
|
||||
become: true
|
||||
|
||||
vars:
|
||||
|
||||
minion_master: localhost
|
||||
|
||||
tasks:
|
||||
|
||||
- name: update system.
|
||||
apt:
|
||||
name: '*'
|
||||
state: latest
|
||||
update_cache: true
|
||||
become: true
|
||||
notify: reboot
|
||||
|
||||
- name: install pip
|
||||
apt:
|
||||
name: python3-pip
|
||||
state: latest
|
||||
become: true
|
||||
|
||||
- name: install salt
|
||||
pip:
|
||||
name: salt
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: create salt dirs.
|
||||
file:
|
||||
path: /etc/salt/minion.d
|
||||
state: directory
|
||||
mode: u=rwX,g=rwX
|
||||
become: true
|
||||
|
||||
- name: create minion file.
|
||||
copy:
|
||||
dest: /etc/salt/minion_id
|
||||
content: "{{ ansible_hostname }}"
|
||||
mode: u=rw,g=rw,o=r
|
||||
become: true
|
||||
|
||||
- name: set master fact.
|
||||
set_fact:
|
||||
minion_master: 192.168.33.10
|
||||
when: ansible_hostname != 'master'
|
||||
|
||||
- name: set minion master.
|
||||
copy:
|
||||
dest: /etc/salt/minion.d/master.conf
|
||||
content: "master: {{ minion_master }}"
|
||||
mode: u=rw,g=r,o=r
|
||||
become: true
|
||||
|
||||
- hosts: master
|
||||
tasks:
|
||||
- name: Ensure salt master dir is created.
|
||||
file:
|
||||
state: directory
|
||||
path: /etc/salt/master.d
|
||||
mode: u=rwX,g=rwX,o=rX
|
||||
become: true
|
||||
|
||||
- name: Ensure roots.conf is created.
|
||||
copy:
|
||||
dest: /etc/salt/master.d/roots.conf
|
||||
content: |
|
||||
file_roots:
|
||||
base:
|
||||
- /srv/salt/base
|
||||
mode: u=rw,g=rw,o=r
|
||||
become: true
|
||||
|
||||
- name: Create salt base dir.
|
||||
file:
|
||||
path: /srv/salt/base
|
||||
state: directory
|
||||
mode: u=rwX,g=rwX,o=rX
|
||||
become: true
|
||||
|
||||
- name: Wack down systemd unit for master.
|
||||
copy:
|
||||
dest: /etc/systemd/system/salt-master.service
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Salt master daemon
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/salt-master -d
|
||||
PIDFile=/var/run/salt-master.pid
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
mode: u=rw,g=rw,o=r
|
||||
become: true
|
||||
|
||||
- name: Ensure salt-master is running.
|
||||
systemd:
|
||||
daemon_reload: true
|
||||
name: salt-master.service
|
||||
enabled: true
|
||||
state: started
|
||||
become: true
|
||||
|
||||
- hosts: all
|
||||
tasks:
|
||||
|
||||
- name: Wack down systemd unit for minion.
|
||||
copy:
|
||||
dest: /etc/systemd/system/salt-minion.service
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Salt minion daemon
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/salt-minion -d
|
||||
PIDFile=/var/run/salt-minion.pid
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
mode: u=rw,g=rw,o=r
|
||||
become: true
|
||||
|
||||
- name: Ensure salt-minion is running.
|
||||
systemd:
|
||||
daemon_reload: true
|
||||
name: salt-minion.service
|
||||
enabled: true
|
||||
state: started
|
||||
become: true
|
||||
Loading…
Reference in New Issue
Block a user