Compare commits
49 Commits
25b055eae0
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 91acf65a52 | |||
| 3fe81f42a2 | |||
| aaae16f141 | |||
| afbe9fafee | |||
| 93a9b18cb7 | |||
| e6d32540ef | |||
| 4ffc84f786 | |||
| 0593ae6310 | |||
| 613e6be0f8 | |||
| 16266c1a18 | |||
| ac2f836117 | |||
| 7dcda52588 | |||
| ab22558e14 | |||
| 47cbd68739 | |||
| fe74206930 | |||
| 4ce18f3889 | |||
| e9fda294b2 | |||
| 0ce169d569 | |||
| 554488ea14 | |||
| 873cdaa756 | |||
| 559e7ae3d3 | |||
| 45d8444aa5 | |||
| d39cbd6fcb | |||
| 49da229a98 | |||
| 38b476fc1a | |||
| 7f536273d9 | |||
| 5d18e93a98 | |||
| 444094781b | |||
| 21c9ce145f | |||
| af6fcca768 | |||
| 3e631906c1 | |||
| 670fca8aed | |||
| d455c1e765 | |||
| 0d54576660 | |||
| c66143ca34 | |||
| 8f477950d8 | |||
| 52e636b8e5 | |||
| 0ef9103ec3 | |||
| 8ae6813615 | |||
| fe6e91d8e4 | |||
| f0d9bdd6f8 | |||
| a5bfb18c33 | |||
| 2abb4d7d57 | |||
| f4fb1f178a | |||
| 4e35138e6d | |||
| 7da40dce19 | |||
| 4103845e98 | |||
| 837aa86a8d | |||
| 473f98bfd7 |
BIN
Ansible.pdf
Normal file
BIN
Ansible.pdf
Normal file
Binary file not shown.
9
UbuntuAnsible.sh
Normal file
9
UbuntuAnsible.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Script to install Ansible on a Ubuntu system
|
||||||
|
apt-get update
|
||||||
|
# Install required packages
|
||||||
|
apt install software-properties-common -y
|
||||||
|
# Add Ansible PPA and install Ansible
|
||||||
|
apt-add-repository ppa:ansible/ansible
|
||||||
|
apt-get install ansible net-tools -y
|
||||||
|
# Add vagrant user to sudoers
|
||||||
|
echo "vagrant ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/vagrant
|
||||||
56
UbuntuVagrantfile
Normal file
56
UbuntuVagrantfile
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
Vagrant.configure(2) do |config|
|
||||||
|
# Máquina de control para el agente Ansible
|
||||||
|
config.vm.define "ansible" do |ansible|
|
||||||
|
ansible.vm.box = "bento/ubuntu-24.04" # Imagen base Ubuntu 24.04
|
||||||
|
ansible.vm.network "private_network", ip: "192.168.11.10" # IP privada
|
||||||
|
ansible.vm.hostname = "ansible" # Nombre de host
|
||||||
|
ansible.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync" # Carpeta sincronizada
|
||||||
|
ansible.vm.provider "virtualbox" do |vb|
|
||||||
|
vb.memory = 512 # Memoria RAM asignada
|
||||||
|
vb.cpus = 1 # Número de CPUs asignadas
|
||||||
|
end
|
||||||
|
ansible.vm.provision :shell, :path => "ansible.sh" # Script de aprovisionamiento
|
||||||
|
end
|
||||||
|
|
||||||
|
# Máquina para la base de datos
|
||||||
|
config.vm.define "database" do |database|
|
||||||
|
database.vm.box = "bento/ubuntu-24.04"
|
||||||
|
database.vm.network "private_network", ip: "192.168.11.20"
|
||||||
|
database.vm.hostname = "database"
|
||||||
|
database.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"
|
||||||
|
database.vm.network "forwarded_port", guest: 80, host: 8081 # Redirección del puerto 80
|
||||||
|
database.vm.network "forwarded_port", guest: 3306, host: 3306 # Redirección del puerto MySQL
|
||||||
|
database.vm.provider "virtualbox" do |vb|
|
||||||
|
vb.memory = 512
|
||||||
|
vb.cpus = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Máquina para el balanceador de carga
|
||||||
|
config.vm.define "loadbalancer" do |loadbalancer|
|
||||||
|
loadbalancer.vm.box = "bento/ubuntu-24.04"
|
||||||
|
loadbalancer.vm.network "private_network", ip: "192.168.11.30"
|
||||||
|
loadbalancer.vm.hostname = "loadbalancer"
|
||||||
|
loadbalancer.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"
|
||||||
|
loadbalancer.vm.network "forwarded_port", guest: 80, host: 8080 # Redirección del puerto 80
|
||||||
|
loadbalancer.vm.network "forwarded_port", guest: 3306, host: 33061 # Redirección del puerto MySQL alternativo
|
||||||
|
loadbalancer.vm.provider "virtualbox" do |vb|
|
||||||
|
vb.memory = 512
|
||||||
|
vb.cpus = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Máquina para el servidor web
|
||||||
|
config.vm.define "webserver" do |webserver|
|
||||||
|
webserver.vm.box = "bento/ubuntu-24.04"
|
||||||
|
webserver.vm.network "private_network", ip: "192.168.11.40"
|
||||||
|
webserver.vm.hostname = "webserver"
|
||||||
|
webserver.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"
|
||||||
|
webserver.vm.network "forwarded_port", guest: 80, host: 80 # Redirección del puerto 80
|
||||||
|
webserver.vm.network "forwarded_port", guest: 3306, host: 33062 # Redirección del puerto MySQL alternativo
|
||||||
|
webserver.vm.provider "virtualbox" do |vb|
|
||||||
|
vb.memory = 512
|
||||||
|
vb.cpus = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
8
Vagrantfile
vendored
8
Vagrantfile
vendored
@@ -1,7 +1,7 @@
|
|||||||
Vagrant.configure(2) do |config|
|
Vagrant.configure(2) do |config|
|
||||||
# Máquina de control para el agente Ansible
|
# Máquina de control para el agente Ansible
|
||||||
config.vm.define "ansible" do |ansible|
|
config.vm.define "ansible" do |ansible|
|
||||||
ansible.vm.box = "bento/ubuntu-24.04" # Imagen base Ubuntu 24.04
|
ansible.vm.box = "bento/debian-13.1" # Imagen base Ubuntu 24.04
|
||||||
ansible.vm.network "private_network", ip: "192.168.11.10" # IP privada
|
ansible.vm.network "private_network", ip: "192.168.11.10" # IP privada
|
||||||
ansible.vm.hostname = "ansible" # Nombre de host
|
ansible.vm.hostname = "ansible" # Nombre de host
|
||||||
ansible.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync" # Carpeta sincronizada
|
ansible.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync" # Carpeta sincronizada
|
||||||
@@ -14,7 +14,7 @@ Vagrant.configure(2) do |config|
|
|||||||
|
|
||||||
# Máquina para la base de datos
|
# Máquina para la base de datos
|
||||||
config.vm.define "database" do |database|
|
config.vm.define "database" do |database|
|
||||||
database.vm.box = "bento/ubuntu-24.04"
|
database.vm.box = "bento/debian-13.1"
|
||||||
database.vm.network "private_network", ip: "192.168.11.20"
|
database.vm.network "private_network", ip: "192.168.11.20"
|
||||||
database.vm.hostname = "database"
|
database.vm.hostname = "database"
|
||||||
database.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"
|
database.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"
|
||||||
@@ -28,7 +28,7 @@ Vagrant.configure(2) do |config|
|
|||||||
|
|
||||||
# Máquina para el balanceador de carga
|
# Máquina para el balanceador de carga
|
||||||
config.vm.define "loadbalancer" do |loadbalancer|
|
config.vm.define "loadbalancer" do |loadbalancer|
|
||||||
loadbalancer.vm.box = "bento/ubuntu-24.04"
|
loadbalancer.vm.box = "bento/debian-13.1"
|
||||||
loadbalancer.vm.network "private_network", ip: "192.168.11.30"
|
loadbalancer.vm.network "private_network", ip: "192.168.11.30"
|
||||||
loadbalancer.vm.hostname = "loadbalancer"
|
loadbalancer.vm.hostname = "loadbalancer"
|
||||||
loadbalancer.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"
|
loadbalancer.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"
|
||||||
@@ -42,7 +42,7 @@ Vagrant.configure(2) do |config|
|
|||||||
|
|
||||||
# Máquina para el servidor web
|
# Máquina para el servidor web
|
||||||
config.vm.define "webserver" do |webserver|
|
config.vm.define "webserver" do |webserver|
|
||||||
webserver.vm.box = "bento/ubuntu-24.04"
|
webserver.vm.box = "bento/debian-13.1"
|
||||||
webserver.vm.network "private_network", ip: "192.168.11.40"
|
webserver.vm.network "private_network", ip: "192.168.11.40"
|
||||||
webserver.vm.hostname = "webserver"
|
webserver.vm.hostname = "webserver"
|
||||||
webserver.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"
|
webserver.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
# Script to install Ansible on a Ubuntu system
|
# Script to install Ansible on a Ubuntu system
|
||||||
apt-get update
|
apt-get update
|
||||||
# Install required packages
|
# Add Ansible repository and install Ansible
|
||||||
apt install software-properties-common -y
|
|
||||||
# Add Ansible PPA and install Ansible
|
|
||||||
apt-add-repository ppa:ansible/ansible
|
|
||||||
apt-get install ansible net-tools -y
|
apt-get install ansible net-tools -y
|
||||||
# Add vagrant user to sudoers
|
# Add vagrant user to sudoers
|
||||||
echo "vagrant ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/vagrant
|
echo "vagrant ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/vagrant
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
httpd_port: 80
|
|
||||||
ntpserver: 192.168.0.2
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
iface: '{{ ansible_default_ipv4.interface }}'
|
|
||||||
apache_test_message: hello world
|
|
||||||
apache_max_keep_alive_requests: 113
|
|
||||||
apache_docroot: /var/www/html
|
|
||||||
sites_available: /etc/httpd/conf/sites-available
|
|
||||||
sites_enabled: /etc/httpd/conf/sites-enabled
|
|
||||||
lameapp_version: 1
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
[webservers]
|
|
||||||
192.168.0.2
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for apache
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for apache
|
|
||||||
- name: restart apache
|
|
||||||
service: name=apache2 state=restarted
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
galaxy_info:
|
|
||||||
author: your name
|
|
||||||
description: your description
|
|
||||||
company: your company (optional)
|
|
||||||
|
|
||||||
# If the issue tracker for your role is not on github, uncomment the
|
|
||||||
# next line and provide a value
|
|
||||||
# issue_tracker_url: http://example.com/issue/tracker
|
|
||||||
|
|
||||||
# Some suggested licenses:
|
|
||||||
# - BSD (default)
|
|
||||||
# - MIT
|
|
||||||
# - GPLv2
|
|
||||||
# - GPLv3
|
|
||||||
# - Apache
|
|
||||||
# - CC-BY
|
|
||||||
license: license (GPLv2, CC-BY, etc)
|
|
||||||
|
|
||||||
min_ansible_version: 1.2
|
|
||||||
|
|
||||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
|
||||||
# min_ansible_container_version:
|
|
||||||
|
|
||||||
# Optionally specify the branch Galaxy will use when accessing the GitHub
|
|
||||||
# repo for this role. During role install, if no tags are available,
|
|
||||||
# Galaxy will use this branch. During import Galaxy will access files on
|
|
||||||
# this branch. If Travis integration is configured, only notifications for this
|
|
||||||
# branch will be accepted. Otherwise, in all cases, the repo's default branch
|
|
||||||
# (usually master) will be used.
|
|
||||||
#github_branch:
|
|
||||||
|
|
||||||
#
|
|
||||||
# platforms is a list of platforms, and each platform has a name and a list of versions.
|
|
||||||
#
|
|
||||||
# platforms:
|
|
||||||
# - name: Fedora
|
|
||||||
# versions:
|
|
||||||
# - all
|
|
||||||
# - 25
|
|
||||||
# - name: SomePlatform
|
|
||||||
# versions:
|
|
||||||
# - all
|
|
||||||
# - 1.0
|
|
||||||
# - 7
|
|
||||||
# - 99.99
|
|
||||||
|
|
||||||
galaxy_tags: []
|
|
||||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
|
||||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
|
||||||
# remove the '[]' above, if you add tags to this list.
|
|
||||||
#
|
|
||||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
|
||||||
# Maximum 20 tags per role.
|
|
||||||
|
|
||||||
dependencies: []
|
|
||||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
|
||||||
# if you add dependencies to this list.
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
# tasks file for apache
|
|
||||||
- name: install apache
|
|
||||||
apt: name=apache2 state=present update-cache=yes
|
|
||||||
|
|
||||||
- name: copy index.html
|
|
||||||
template:
|
|
||||||
src: index.html.j2
|
|
||||||
dest: /var/www/html/index.html
|
|
||||||
|
|
||||||
- name: copy httpd conf
|
|
||||||
template:
|
|
||||||
src: httpd.conf.j2
|
|
||||||
dest: /etc/apache2
|
|
||||||
notify: restart apache
|
|
||||||
|
|
||||||
- name: start apache
|
|
||||||
service:
|
|
||||||
name: apache2 state=started enabled=yes
|
|
||||||
@@ -1,225 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
# This is the main Apache server configuration file. It contains the
|
|
||||||
# configuration directives that give the server its instructions.
|
|
||||||
# See http://httpd.apache.org/docs/2.4/ for detailed information about
|
|
||||||
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
|
|
||||||
# hints.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Summary of how the Apache 2 configuration works in Debian:
|
|
||||||
# The Apache 2 web server configuration in Debian is quite different to
|
|
||||||
# upstream's suggested way to configure the web server. This is because Debian's
|
|
||||||
# default Apache2 installation attempts to make adding and removing modules,
|
|
||||||
# virtual hosts, and extra configuration directives as flexible as possible, in
|
|
||||||
# order to make automating the changes and administering the server as easy as
|
|
||||||
# possible.
|
|
||||||
|
|
||||||
ServerName {{ apache2_server_name|default(ansible_fqdn) }}
|
|
||||||
|
|
||||||
# It is split into several files forming the configuration hierarchy outlined
|
|
||||||
# below, all located in the /etc/apache2/ directory:
|
|
||||||
#
|
|
||||||
# /etc/apache2/
|
|
||||||
# |-- apache2.conf
|
|
||||||
# | `-- ports.conf
|
|
||||||
# |-- mods-enabled
|
|
||||||
# | |-- *.load
|
|
||||||
# | `-- *.conf
|
|
||||||
# |-- conf-enabled
|
|
||||||
# | `-- *.conf
|
|
||||||
# `-- sites-enabled
|
|
||||||
# `-- *.conf
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# * apache2.conf is the main configuration file (this file). It puts the pieces
|
|
||||||
# together by including all remaining configuration files when starting up the
|
|
||||||
# web server.
|
|
||||||
#
|
|
||||||
# * ports.conf is always included from the main configuration file. It is
|
|
||||||
# supposed to determine listening ports for incoming connections which can be
|
|
||||||
# customized anytime.
|
|
||||||
#
|
|
||||||
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
|
|
||||||
# directories contain particular configuration snippets which manage modules,
|
|
||||||
# global configuration fragments, or virtual host configurations,
|
|
||||||
# respectively.
|
|
||||||
#
|
|
||||||
# They are activated by symlinking available configuration files from their
|
|
||||||
# respective *-available/ counterparts. These should be managed by using our
|
|
||||||
# helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
|
|
||||||
# their respective man pages for detailed information.
|
|
||||||
#
|
|
||||||
# * The binary is called apache2. Due to the use of environment variables, in
|
|
||||||
# the default configuration, apache2 needs to be started/stopped with
|
|
||||||
# /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
|
|
||||||
# work with the default configuration.
|
|
||||||
|
|
||||||
|
|
||||||
# Global configuration
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# ServerRoot: The top of the directory tree under which the server's
|
|
||||||
# configuration, error, and log files are kept.
|
|
||||||
#
|
|
||||||
# NOTE! If you intend to place this on an NFS (or otherwise network)
|
|
||||||
# mounted filesystem then please read the Mutex documentation (available
|
|
||||||
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
|
|
||||||
# you will save yourself a lot of trouble.
|
|
||||||
#
|
|
||||||
# Do NOT add a slash at the end of the directory path.
|
|
||||||
#
|
|
||||||
#ServerRoot "/etc/apache2"
|
|
||||||
|
|
||||||
#
|
|
||||||
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
|
|
||||||
#
|
|
||||||
Mutex file:${APACHE_LOCK_DIR} default
|
|
||||||
|
|
||||||
#
|
|
||||||
# PidFile: The file in which the server should record its process
|
|
||||||
# identification number when it starts.
|
|
||||||
# This needs to be set in /etc/apache2/envvars
|
|
||||||
#
|
|
||||||
PidFile ${APACHE_PID_FILE}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Timeout: The number of seconds before receives and sends time out.
|
|
||||||
#
|
|
||||||
Timeout 300
|
|
||||||
|
|
||||||
#
|
|
||||||
# KeepAlive: Whether or not to allow persistent connections (more than
|
|
||||||
# one request per connection). Set to "Off" to deactivate.
|
|
||||||
#
|
|
||||||
KeepAlive On
|
|
||||||
|
|
||||||
#
|
|
||||||
# MaxKeepAliveRequests: The maximum number of requests to allow
|
|
||||||
# during a persistent connection. Set to 0 to allow an unlimited amount.
|
|
||||||
# We recommend you leave this number high, for maximum performance.
|
|
||||||
#
|
|
||||||
MaxKeepAliveRequests 100
|
|
||||||
|
|
||||||
#
|
|
||||||
# KeepAliveTimeout: Number of seconds to wait for the next request from the
|
|
||||||
# same client on the same connection.
|
|
||||||
#
|
|
||||||
KeepAliveTimeout 5
|
|
||||||
|
|
||||||
|
|
||||||
# These need to be set in /etc/apache2/envvars
|
|
||||||
User ${APACHE_RUN_USER}
|
|
||||||
Group ${APACHE_RUN_GROUP}
|
|
||||||
|
|
||||||
#
|
|
||||||
# HostnameLookups: Log the names of clients or just their IP addresses
|
|
||||||
# e.g., www.apache.org (on) or 204.62.129.132 (off).
|
|
||||||
# The default is off because it'd be overall better for the net if people
|
|
||||||
# had to knowingly turn this feature on, since enabling it means that
|
|
||||||
# each client request will result in AT LEAST one lookup request to the
|
|
||||||
# nameserver.
|
|
||||||
#
|
|
||||||
HostnameLookups Off
|
|
||||||
|
|
||||||
# ErrorLog: The location of the error log file.
|
|
||||||
# If you do not specify an ErrorLog directive within a <VirtualHost>
|
|
||||||
# container, error messages relating to that virtual host will be
|
|
||||||
# logged here. If you *do* define an error logfile for a <VirtualHost>
|
|
||||||
# container, that host's errors will be logged there and not here.
|
|
||||||
#
|
|
||||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
|
||||||
|
|
||||||
#
|
|
||||||
# LogLevel: Control the severity of messages logged to the error_log.
|
|
||||||
# Available values: trace8, ..., trace1, debug, info, notice, warn,
|
|
||||||
# error, crit, alert, emerg.
|
|
||||||
# It is also possible to configure the log level for particular modules, e.g.
|
|
||||||
# "LogLevel info ssl:warn"
|
|
||||||
#
|
|
||||||
LogLevel warn
|
|
||||||
|
|
||||||
# Include module configuration:
|
|
||||||
IncludeOptional mods-enabled/*.load
|
|
||||||
IncludeOptional mods-enabled/*.conf
|
|
||||||
|
|
||||||
# Include list of ports to listen on
|
|
||||||
Include ports.conf
|
|
||||||
|
|
||||||
|
|
||||||
# Sets the default security model of the Apache2 HTTPD server. It does
|
|
||||||
# not allow access to the root filesystem outside of /usr/share and /var/www.
|
|
||||||
# The former is used by web applications packaged in Debian,
|
|
||||||
# the latter may be used for local directories served by the web server. If
|
|
||||||
# your system is serving content from a sub-directory in /srv you must allow
|
|
||||||
# access here, or in any related virtual host.
|
|
||||||
<Directory />
|
|
||||||
Options FollowSymLinks
|
|
||||||
AllowOverride None
|
|
||||||
Require all denied
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
<Directory /usr/share>
|
|
||||||
AllowOverride None
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
<Directory /var/www/>
|
|
||||||
Options FollowSymLinks
|
|
||||||
AllowOverride None
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
#<Directory /srv/>
|
|
||||||
# Options Indexes FollowSymLinks
|
|
||||||
# AllowOverride None
|
|
||||||
# Require all granted
|
|
||||||
#</Directory>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# AccessFileName: The name of the file to look for in each directory
|
|
||||||
# for additional configuration directives. See also the AllowOverride
|
|
||||||
# directive.
|
|
||||||
#
|
|
||||||
AccessFileName .htaccess
|
|
||||||
|
|
||||||
#
|
|
||||||
# The following lines prevent .htaccess and .htpasswd files from being
|
|
||||||
# viewed by Web clients.
|
|
||||||
#
|
|
||||||
<FilesMatch "^\.ht">
|
|
||||||
Require all denied
|
|
||||||
</FilesMatch>
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# The following directives define some format nicknames for use with
|
|
||||||
# a CustomLog directive.
|
|
||||||
#
|
|
||||||
# These deviate from the Common Log Format definitions in that they use %O
|
|
||||||
# (the actual bytes sent including headers) instead of %b (the size of the
|
|
||||||
# requested file), because the latter makes it impossible to detect partial
|
|
||||||
# requests.
|
|
||||||
#
|
|
||||||
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
|
|
||||||
# Use mod_remoteip instead.
|
|
||||||
#
|
|
||||||
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
|
|
||||||
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
|
||||||
LogFormat "%h %l %u %t \"%r\" %>s %O" common
|
|
||||||
LogFormat "%{Referer}i -> %U" referer
|
|
||||||
LogFormat "%{User-agent}i" agent
|
|
||||||
|
|
||||||
# Include of directories ignores editors' and dpkg's backup files,
|
|
||||||
# see README.Debian for details.
|
|
||||||
|
|
||||||
# Include generic snippets of statements
|
|
||||||
IncludeOptional conf-enabled/*.conf
|
|
||||||
|
|
||||||
# Include the virtual host configurations:
|
|
||||||
IncludeOptional sites-enabled/*.conf
|
|
||||||
|
|
||||||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{{ apache_test_message }} {{ ansible_distribution }} {{ ansible_distribution_version }} <br>
|
|
||||||
Current Host: {{ ansible_hostname }} <br>
|
|
||||||
Server list: <br>
|
|
||||||
{% for host in groups.webservers %}
|
|
||||||
{{ host }} <br>
|
|
||||||
{% endfor %}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
localhost
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: webservers
|
|
||||||
remote_user: root
|
|
||||||
roles:
|
|
||||||
- apache
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for apache
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for common
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for common
|
|
||||||
- name: restart ntp
|
|
||||||
service: name=ntpd state=restarted
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
galaxy_info:
|
|
||||||
author: your name
|
|
||||||
description: your description
|
|
||||||
company: your company (optional)
|
|
||||||
|
|
||||||
# If the issue tracker for your role is not on github, uncomment the
|
|
||||||
# next line and provide a value
|
|
||||||
# issue_tracker_url: http://example.com/issue/tracker
|
|
||||||
|
|
||||||
# Some suggested licenses:
|
|
||||||
# - BSD (default)
|
|
||||||
# - MIT
|
|
||||||
# - GPLv2
|
|
||||||
# - GPLv3
|
|
||||||
# - Apache
|
|
||||||
# - CC-BY
|
|
||||||
license: license (GPLv2, CC-BY, etc)
|
|
||||||
|
|
||||||
min_ansible_version: 1.2
|
|
||||||
|
|
||||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
|
||||||
# min_ansible_container_version:
|
|
||||||
|
|
||||||
# Optionally specify the branch Galaxy will use when accessing the GitHub
|
|
||||||
# repo for this role. During role install, if no tags are available,
|
|
||||||
# Galaxy will use this branch. During import Galaxy will access files on
|
|
||||||
# this branch. If Travis integration is configured, only notifications for this
|
|
||||||
# branch will be accepted. Otherwise, in all cases, the repo's default branch
|
|
||||||
# (usually master) will be used.
|
|
||||||
#github_branch:
|
|
||||||
|
|
||||||
#
|
|
||||||
# platforms is a list of platforms, and each platform has a name and a list of versions.
|
|
||||||
#
|
|
||||||
# platforms:
|
|
||||||
# - name: Fedora
|
|
||||||
# versions:
|
|
||||||
# - all
|
|
||||||
# - 25
|
|
||||||
# - name: SomePlatform
|
|
||||||
# versions:
|
|
||||||
# - all
|
|
||||||
# - 1.0
|
|
||||||
# - 7
|
|
||||||
# - 99.99
|
|
||||||
|
|
||||||
galaxy_tags: []
|
|
||||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
|
||||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
|
||||||
# remove the '[]' above, if you add tags to this list.
|
|
||||||
#
|
|
||||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
|
||||||
# Maximum 20 tags per role.
|
|
||||||
|
|
||||||
dependencies: []
|
|
||||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
|
||||||
# if you add dependencies to this list.
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
# tasks file for common
|
|
||||||
- name: install epel repo
|
|
||||||
apt:
|
|
||||||
name: epel-release
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- include: selinux.yml
|
|
||||||
- include: ntp.yml
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install ntp
|
|
||||||
apt:
|
|
||||||
name: ntp
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: configure ntp file
|
|
||||||
template:
|
|
||||||
src: ntp.conf.j2
|
|
||||||
dest: /etc/ntp.conf
|
|
||||||
|
|
||||||
- name: start ntp
|
|
||||||
service:
|
|
||||||
name: ntpd
|
|
||||||
state: started
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install python bindings for SELinux
|
|
||||||
apt:
|
|
||||||
name: {{item}}
|
|
||||||
state: present
|
|
||||||
with_items:
|
|
||||||
- libselinux-python
|
|
||||||
- libsemanage-python
|
|
||||||
|
|
||||||
- name: test to see if SELinux is running
|
|
||||||
command: getenforce
|
|
||||||
register: sestatus
|
|
||||||
changed_when: false
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
driftfile /var/lib/ntp/drift
|
|
||||||
|
|
||||||
restrict 127.0.0.1
|
|
||||||
restrict -6 ::1
|
|
||||||
server {{ ntpserver }}
|
|
||||||
includefile /etc/ntp/crypto/pw
|
|
||||||
keys /etc/ntp/keys
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
localhost
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: localhost
|
|
||||||
remote_user: root
|
|
||||||
roles:
|
|
||||||
- common
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for common
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install and start apache
|
|
||||||
hosts: webservers
|
|
||||||
remote_user: root
|
|
||||||
become: yes
|
|
||||||
roles:
|
|
||||||
- apache
|
|
||||||
8
examples/000_initial_example/000_initial_example.yml
Normal file
8
examples/000_initial_example/000_initial_example.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: get server hostname
|
||||||
|
command: hostname
|
||||||
|
- name: Debug hostname
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: ansible_facts['hostname']
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: all
|
|
||||||
tasks:
|
|
||||||
- command: hostname
|
|
||||||
@@ -1,19 +1,8 @@
|
|||||||
[database]
|
[database]
|
||||||
192.168.0.2
|
192.168.11.20
|
||||||
192.168.0.3
|
|
||||||
|
|
||||||
[loadbalancer]
|
[loadbalancer]
|
||||||
192.168.0.3
|
192.168.11.30
|
||||||
192.168.0.4
|
|
||||||
|
|
||||||
[webserver]
|
[webserver]
|
||||||
192.168.0.4
|
192.168.11.40
|
||||||
|
|
||||||
[alfa]
|
|
||||||
192.168.0.2
|
|
||||||
|
|
||||||
[bravo]
|
|
||||||
192.168.0.3
|
|
||||||
|
|
||||||
[charlie]
|
|
||||||
192.168.0.4
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
[loadbalancer]
|
|
||||||
lb01 ansible_connection=local
|
|
||||||
|
|
||||||
[webserver]
|
|
||||||
app01 ansible_connection=local
|
|
||||||
app02 ansible_connection=local
|
|
||||||
|
|
||||||
[database]
|
|
||||||
db01 ansible_connection=local
|
|
||||||
|
|
||||||
[control]
|
|
||||||
control ansible_connection=local
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: all
|
|
||||||
tasks:
|
|
||||||
- name: get server hostname
|
|
||||||
command: hostname
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
[loadbalancer]
|
|
||||||
lb01
|
|
||||||
|
|
||||||
[webserver]
|
|
||||||
app01
|
|
||||||
app02
|
|
||||||
|
|
||||||
[database]
|
|
||||||
db01
|
|
||||||
|
|
||||||
[control]
|
|
||||||
control ansible_connection=local
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
[database]
|
[database]
|
||||||
192.168.0.2
|
192.168.11.20
|
||||||
|
|
||||||
[loadbalancer]
|
[loadbalancer]
|
||||||
192.168.0.3
|
192.168.11.30
|
||||||
|
|
||||||
|
[webserver]
|
||||||
|
192.168.11.40
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
- hosts: database
|
- hosts: database
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: install mysql-server
|
- name: install default-mysql-server
|
||||||
apt: name=mysql-server state=present update_cache=yes
|
apt: name=default-mysql-server state=present update_cache=yes
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: all
|
|
||||||
tasks:
|
|
||||||
- name: get server hostname
|
|
||||||
command: hostname
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
[database]
|
[database]
|
||||||
192.168.0.2
|
192.168.11.20
|
||||||
|
|
||||||
[loadbalancer]
|
[loadbalancer]
|
||||||
192.168.0.3
|
192.168.11.30
|
||||||
|
|
||||||
[webserver]
|
[webserver]
|
||||||
192.168.0.4
|
192.168.11.40
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: install nginx
|
- name: install nginx
|
||||||
apt: name=nginx state=present update_cache=yes
|
apt: name=nginx state=present update_cache=yes
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
- hosts: database
|
- hosts: database
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: install mysql-server
|
- name: install default-mysql-server
|
||||||
apt: name=mysql-server state=present update_cache=yes
|
apt: name=default-mysql-server state=present update_cache=yes
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: all
|
|
||||||
tasks:
|
|
||||||
- name: get server hostname
|
|
||||||
command: hostname
|
|
||||||
8
examples/003_with_items/hosts
Normal file
8
examples/003_with_items/hosts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[database]
|
||||||
|
192.168.11.20
|
||||||
|
|
||||||
|
[loadbalancer]
|
||||||
|
192.168.11.30
|
||||||
|
|
||||||
|
[webserver]
|
||||||
|
192.168.11.40
|
||||||
@@ -7,6 +7,5 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- apache2
|
- apache2
|
||||||
- libapache2-mod-wsgi-py3
|
- libapache2-mod-wsgi-py3
|
||||||
- python-pip-whl
|
- python3-pip-whl
|
||||||
- python3-virtualenv
|
- python3-virtualenv
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: control
|
|
||||||
become: true
|
|
||||||
tasks:
|
|
||||||
- name: install tools
|
|
||||||
apt: name={{item}} state=present update_cache=yes
|
|
||||||
with_items:
|
|
||||||
- uacme
|
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
- hosts: database
|
- hosts: database
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: install mysql-server
|
- name: install default-mysql-server
|
||||||
apt: name=mysql-server state=present update_cache=yes
|
apt: name=default-mysql-server state=present update_cache=yes
|
||||||
|
|
||||||
- name: ensure mysql started
|
- name: ensure mysql started
|
||||||
service: name=mysql state=started enabled=yes
|
service: name=mysql state=started enabled=yes
|
||||||
|
|||||||
8
examples/004_services/hosts
Normal file
8
examples/004_services/hosts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[database]
|
||||||
|
192.168.11.20
|
||||||
|
|
||||||
|
[loadbalancer]
|
||||||
|
192.168.11.30
|
||||||
|
|
||||||
|
[webserver]
|
||||||
|
192.168.11.40
|
||||||
@@ -1,5 +1,15 @@
|
|||||||
---
|
---
|
||||||
- hosts: all
|
- hosts: all
|
||||||
|
gather_facts: true
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: mostrar tots el gather facts
|
||||||
|
debug:
|
||||||
|
var: ansible_facts
|
||||||
- name: get server hostname
|
- name: get server hostname
|
||||||
command: hostname
|
command: hostname
|
||||||
|
- name: mostrar IP del host
|
||||||
|
debug:
|
||||||
|
msg: "IP: {{ ansible_default_ipv4.address }}"
|
||||||
|
- name: mostrar hostname
|
||||||
|
debug:
|
||||||
|
msg: "Host: {{ ansible_hostname }}"
|
||||||
@@ -15,4 +15,4 @@
|
|||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: reiniciar apache
|
- name: reiniciar apache
|
||||||
service: name=apache2 state=restarted
|
service: name=apache2 state=restarted
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: database
|
|
||||||
become: true
|
|
||||||
tasks:
|
|
||||||
- name: reiniciar mysql
|
|
||||||
service: name=mysql state=restarted
|
|
||||||
|
|
||||||
- hosts: loadbalancer
|
|
||||||
become: true
|
|
||||||
tasks:
|
|
||||||
- name: reiniciar nginx
|
|
||||||
service: name=nginx state=restarted
|
|
||||||
|
|
||||||
- hosts: webserver
|
|
||||||
become: true
|
|
||||||
tasks:
|
|
||||||
service: name=apache2 state=restarted
|
|
||||||
27
examples/004_services/playbooks/stack_status.yml
Normal file
27
examples/004_services/playbooks/stack_status.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
- hosts: loadbalancer
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: verify nginx service
|
||||||
|
command: service nginx status
|
||||||
|
|
||||||
|
- name: verify nginx is listening on 80
|
||||||
|
wait_for: port=80 timeout=1
|
||||||
|
|
||||||
|
- hosts: webserver
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: verify apache2 service
|
||||||
|
command: service apache2 status
|
||||||
|
|
||||||
|
- name: verify apache2 is listening on 80
|
||||||
|
wait_for: port=80 timeout=1
|
||||||
|
|
||||||
|
- hosts: database
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: verify mysql service
|
||||||
|
command: service mysql status
|
||||||
|
|
||||||
|
- name: verify mysql is listening on 3306
|
||||||
|
wait_for: port=3306 timeout=1
|
||||||
@@ -15,4 +15,4 @@
|
|||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: parar apache
|
- name: parar apache
|
||||||
service: name=apache2 state=stopped
|
service: name=apache2 state=stopped
|
||||||
5
examples/004_services/site.yml
Normal file
5
examples/004_services/site.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- ansible.builtin.import_playbook: database.yml
|
||||||
|
- ansible.builtin.import_playbook: webserver.yml
|
||||||
|
- ansible.builtin.import_playbook: loadbalancer.yml
|
||||||
|
- ansible.builtin.import_playbook: playbooks/stack_status.yml
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- apache2
|
- apache2
|
||||||
- libapache2-mod-wsgi-py3
|
- libapache2-mod-wsgi-py3
|
||||||
- python-pip-whl
|
- python3-pip-whl
|
||||||
- python3-virtualenv
|
- python3-virtualenv
|
||||||
|
|
||||||
- name: ensure apache2 started
|
- name: ensure apache2 started
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
- hosts: database
|
- hosts: database
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: install mysql-server
|
- name: install default-mysql-server
|
||||||
apt: name=mysql-server state=present update_cache=yes
|
apt: name=default-mysql-server state=present update_cache=yes
|
||||||
|
|
||||||
- name: ensure mysql started
|
- name: ensure mysql started
|
||||||
service: name=mysql state=started enabled=yes
|
service: name=mysql state=started enabled=yes
|
||||||
11
examples/005_stack_restart/hosts
Normal file
11
examples/005_stack_restart/hosts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[control]
|
||||||
|
192.168.11.10
|
||||||
|
|
||||||
|
[database]
|
||||||
|
192.168.11.20
|
||||||
|
|
||||||
|
[loadbalancer]
|
||||||
|
192.168.11.30
|
||||||
|
|
||||||
|
[webserver]
|
||||||
|
192.168.11.40
|
||||||
8
examples/006_notify_handlers/hosts
Normal file
8
examples/006_notify_handlers/hosts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[database]
|
||||||
|
192.168.11.20
|
||||||
|
|
||||||
|
[loadbalancer]
|
||||||
|
192.168.11.30
|
||||||
|
|
||||||
|
[webserver]
|
||||||
|
192.168.11.40
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- apache2
|
- apache2
|
||||||
- libapache2-mod-wsgi-py3
|
- libapache2-mod-wsgi-py3
|
||||||
- python-pip-whl
|
- python3-pip-whl
|
||||||
- python3-virtualenv
|
- python3-virtualenv
|
||||||
|
|
||||||
- name: ensure apache2 started
|
- name: ensure apache2 started
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
activate_this = '/var/www/demo/.venv/bin/activate_this.py'
|
|
||||||
exec(open(activate_this).read(), {'__file__': activate_this})
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
os.environ['DATABASE_URI'] = 'mysql://demo:demo@db01/demo'
|
os.environ['DATABASE_URI'] = 'mysql://demo:demo@db01/demo'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
click==7.1.2
|
click==7.1.2
|
||||||
Flask==1.1.4
|
Flask==1.1.4
|
||||||
Flask-SQLAlchemy==2.5.1
|
Flask-SQLAlchemy==2.5.1
|
||||||
greenlet==1.1.2
|
greenlet==3.5.0
|
||||||
itsdangerous==1.1.0
|
itsdangerous==1.1.0
|
||||||
Jinja2==2.11.3
|
Jinja2==2.11.3
|
||||||
MarkupSafe==2.0.1
|
MarkupSafe==2.0.1
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<VirtualHost *>
|
<VirtualHost *>
|
||||||
WSGIDaemonProcess demo threads=5
|
|
||||||
WSGIScriptAlias / /var/www/demo/demo.wsgi
|
WSGIScriptAlias / /var/www/demo/demo.wsgi
|
||||||
|
WSGIDaemonProcess demo python-home=/var/www/demo/.venv python-path=/var/www/demo
|
||||||
|
WSGIProcessGroup demo
|
||||||
|
|
||||||
<Directory /var/www/demo>
|
<Directory /var/www/demo>
|
||||||
WSGIProcessGroup demo
|
WSGIProcessGroup demo
|
||||||
|
|||||||
11
examples/016_tasks_handlers/hosts
Normal file
11
examples/016_tasks_handlers/hosts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[control]
|
||||||
|
192.168.11.10
|
||||||
|
|
||||||
|
[database]
|
||||||
|
192.168.11.20
|
||||||
|
|
||||||
|
[loadbalancer]
|
||||||
|
192.168.11.30
|
||||||
|
|
||||||
|
[webserver]
|
||||||
|
192.168.11.40
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
tasks:
|
tasks:
|
||||||
- name: install tools
|
- name: install tools
|
||||||
apt: name={{item}} state=present update_cache=yes
|
apt: name={{item}} state=present update_cache=yes
|
||||||
with_items:
|
loop:
|
||||||
- python-httplib2
|
- python3-httplib2
|
||||||
|
|
||||||
- name: install nginx
|
- name: install nginx
|
||||||
apt: name=nginx state=present update_cache=yes
|
apt: name=nginx state=present update_cache=yes
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
---
|
---
|
||||||
- hosts: all
|
- hosts: all
|
||||||
tasks:
|
tasks:
|
||||||
- name: get server hostname
|
- name: Ping to servers
|
||||||
|
ping:
|
||||||
|
- name: Get hostname
|
||||||
command: hostname
|
command: hostname
|
||||||
|
register: hostname
|
||||||
|
- name: Show hostname with message
|
||||||
|
debug:
|
||||||
|
msg: "The hostname of this server is {{ hostname.stdout }}"
|
||||||
|
|||||||
@@ -26,42 +26,45 @@
|
|||||||
- name: verify mysql is listening on 3306
|
- name: verify mysql is listening on 3306
|
||||||
wait_for: port=3306 timeout=1
|
wait_for: port=3306 timeout=1
|
||||||
|
|
||||||
- hosts: control
|
|
||||||
tasks:
|
|
||||||
- name: verify end-to-end index response
|
|
||||||
uri: url=http://{{item}} return_content=yes
|
|
||||||
with_items: groups.loadbalancer
|
|
||||||
register: lb_index
|
|
||||||
|
|
||||||
- fail: msg="index failed to return content"
|
|
||||||
when: "'Hello, from sunny' not in item.content"
|
|
||||||
with_items: "{{lb_index.results}}"
|
|
||||||
|
|
||||||
- name: verify end-to-end db response
|
|
||||||
uri: url=http://{{item}}/db return_content=yes
|
|
||||||
with_items: groups.loadbalancer
|
|
||||||
register: lb_db
|
|
||||||
|
|
||||||
- fail: msg="db failed to return content"
|
|
||||||
when: "'Database Connected from' not in item.content"
|
|
||||||
with_items: "{{lb_db.results}}"
|
|
||||||
|
|
||||||
- hosts: loadbalancer
|
- hosts: loadbalancer
|
||||||
tasks:
|
tasks:
|
||||||
- name: verify backend index response
|
- name: verify backend index response
|
||||||
uri: url=http://{{item}} return_content=yes
|
uri: url=http://{{item}} return_content=yes
|
||||||
with_items: groups.webserver
|
loop: "{{ groups.webserver }}"
|
||||||
register: app_index
|
register: app_index
|
||||||
|
|
||||||
- fail: msg="index failed to return content"
|
- fail: msg="index failed to return content"
|
||||||
when: "'Hello, from sunny {{item.item}}!' not in item.content"
|
when: ("Hello, from sunny " ~ item.content ~ "!") in item.content
|
||||||
with_items: "{{app_index.results}}"
|
loop: "{{app_index.results}}"
|
||||||
|
|
||||||
- name: verify backend db response
|
- name: verify backend db response
|
||||||
uri: url=http://{{item}}/db return_content=yes
|
uri: url=http://{{item}}/db return_content=yes
|
||||||
with_items: groups.webserver
|
loop: "{{ groups.webserver }}"
|
||||||
register: app_db
|
register: app_db
|
||||||
|
|
||||||
- fail: msg="db failed to return content"
|
- fail: msg="db failed to return content"
|
||||||
when: "'Database Connected from {{item.item}}!' not in item.content"
|
when: ("Database Connected from " ~ item.content ~ "!") in item.content
|
||||||
with_items: "{{app_db.results}}"
|
loop: "{{app_db.results}}"
|
||||||
|
|
||||||
|
- hosts: control
|
||||||
|
tasks:
|
||||||
|
- name: get elements from loadbalancer group
|
||||||
|
debug: var=groups.loadbalancer
|
||||||
|
|
||||||
|
- name: verify end-to-end connectivity to loadbalancer
|
||||||
|
uri: url=http://{{item}} return_content=yes
|
||||||
|
loop: "{{ groups.loadbalancer }}"
|
||||||
|
register: lb_connectivity
|
||||||
|
|
||||||
|
- fail: msg="index failed to return content"
|
||||||
|
when: ("Hello, from sunny " ~ item.content ~ "!") in item.content
|
||||||
|
loop: "{{lb_connectivity.results}}"
|
||||||
|
|
||||||
|
- name: verify end-to-end db response
|
||||||
|
uri: url=http://{{item}}/db return_content=yes
|
||||||
|
loop: "{{ groups.loadbalancer }}"
|
||||||
|
register: lb_db
|
||||||
|
|
||||||
|
- fail: msg="db failed to return content"
|
||||||
|
when: ("Database Connected from " ~ item.content ~ "!") in item.content
|
||||||
|
loop: "{{lb_db.results}}"
|
||||||
@@ -1,2 +1,4 @@
|
|||||||
---
|
---
|
||||||
# handlers file for apache2
|
# handlers file for apache2
|
||||||
|
- name: restart apache2
|
||||||
|
service: name=apache2 state=restarted
|
||||||
@@ -1,2 +1,45 @@
|
|||||||
---
|
---
|
||||||
# tasks file for apache2
|
# tasks file for apache2
|
||||||
|
- name: install web components
|
||||||
|
apt: name={{item}} state=present update_cache=yes
|
||||||
|
loop:
|
||||||
|
- apache2
|
||||||
|
- python3-pip
|
||||||
|
- python3-virtualenv
|
||||||
|
- python3-venv
|
||||||
|
- python3-mysqldb
|
||||||
|
- libapache2-mod-wsgi-py3
|
||||||
|
|
||||||
|
- name: ensure apache2 started
|
||||||
|
service: name=apache2 state=started enabled=yes
|
||||||
|
|
||||||
|
- name: ensure mod_wsgi enabled
|
||||||
|
apache2_module: state=present name=wsgi
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: copy demo app source
|
||||||
|
copy: src=demo/app/ dest=/var/www/demo mode=0755
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: copy apache virtual host config
|
||||||
|
copy: src=demo/demo.conf dest=/etc/apache2/sites-available mode=0755
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: initialize virtualenv
|
||||||
|
shell: python3 -m venv /var/www/demo/.venv creates=/var/www/demo/.venv
|
||||||
|
|
||||||
|
- name: source virtualenv and install app dependencies
|
||||||
|
shell: . /var/www/demo/.venv/bin/activate && pip install -r /var/www/demo/requirements.txt
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: setup python virtualenv
|
||||||
|
pip: requirements=/var/www/demo/requirements.txt virtualenv=/var/www/demo/.venv
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: de-activate default apache site
|
||||||
|
file: path=/etc/apache2/sites-enabled/000-default.conf state=absent
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: activate demo apache site
|
||||||
|
file: src=/etc/apache2/sites-available/demo.conf dest=/etc/apache2/sites-enabled/demo.conf state=link
|
||||||
|
notify: restart apache2
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: install tools
|
- name: install tools
|
||||||
apt: name={{item}} state=present update_cache=yes
|
apt: name={{item}} state=present update_cache=yes
|
||||||
with_items:
|
loop:
|
||||||
- curl
|
- curl
|
||||||
- python-httplib2
|
- python3-httplib2
|
||||||
|
|||||||
@@ -5,17 +5,27 @@
|
|||||||
- python3-mysqldb
|
- python3-mysqldb
|
||||||
|
|
||||||
- name: install mysql-server
|
- name: install mysql-server
|
||||||
apt: name=mysql-server state=present update_cache=yes
|
apt: name=mysql-server-8.0 state=present update_cache=yes
|
||||||
|
|
||||||
- name: ensure mysql started
|
- name: ensure mysql started properly
|
||||||
service: name=mysql state=started enabled=yes
|
service: name=mysql state=started enabled=yes
|
||||||
|
register: mysql_status
|
||||||
|
until: mysql_status is success
|
||||||
|
retries: 5
|
||||||
|
delay: 5
|
||||||
|
|
||||||
|
- name: read mysql_status
|
||||||
|
debug: var=mysql_status
|
||||||
|
|
||||||
- name: ensure mysql listening on all ports
|
- name: ensure mysql listening on all ports
|
||||||
lineinfile: dest=/etc/mysql/my.cnf regexp=^bind-address line="bind-address = 0.0.0.0"
|
lineinfile:
|
||||||
|
dest: /etc/mysql/my.cnf
|
||||||
|
regexp: '^\[mysqld\]'
|
||||||
|
line: "[mysqld]\nbind-address = 0.0.0.0"
|
||||||
notify: restart mysql
|
notify: restart mysql
|
||||||
|
|
||||||
- name: create demo database
|
- name: create demo database
|
||||||
mysql_db: name=demo state=present
|
mysql_db: name=demo state=present
|
||||||
|
|
||||||
- name: create demo user
|
- name: create demo user
|
||||||
mysql_user: name=demo password=demo priv=demo.*:ALL host='%' state=present
|
mysql_user: name=demo password=demo priv=demo.*:ALL host='%' state=present
|
||||||
8
examples/016_tasks_handlers/site.yml
Normal file
8
examples/016_tasks_handlers/site.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- import_playbook: playbooks/hostname.yml
|
||||||
|
- import_playbook: database.yml
|
||||||
|
- import_playbook: webserver.yml
|
||||||
|
- import_playbook: loadbalancer.yml
|
||||||
|
- import_playbook: control.yml
|
||||||
|
- import_playbook: playbooks/stack_restart.yml
|
||||||
|
- import_playbook: playbooks/stack_status.yml
|
||||||
@@ -1,43 +1,8 @@
|
|||||||
---
|
---
|
||||||
- hosts: webserver
|
- hosts: webserver
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
roles:
|
||||||
- name: install web components
|
- apache2
|
||||||
apt: name={{item}} state=present update_cache=yes
|
|
||||||
with_items:
|
|
||||||
- apache2
|
|
||||||
- libapache2-mod-wsgi
|
|
||||||
- python-pip
|
|
||||||
- python-virtualenv
|
|
||||||
- python-mysqldb
|
|
||||||
|
|
||||||
- name: ensure apache2 started
|
|
||||||
service: name=apache2 state=started enabled=yes
|
|
||||||
|
|
||||||
- name: ensure mod_wsgi enabled
|
|
||||||
apache2_module: state=present name=wsgi
|
|
||||||
notify: restart apache2
|
|
||||||
|
|
||||||
- name: copy demo app source
|
|
||||||
copy: src=demo/app/ dest=/var/www/demo mode=0755
|
|
||||||
notify: restart apache2
|
|
||||||
|
|
||||||
- name: copy apache virtual host config
|
|
||||||
copy: src=demo/demo.conf dest=/etc/apache2/sites-available mode=0755
|
|
||||||
notify: restart apache2
|
|
||||||
|
|
||||||
- name: setup python virtualenv
|
|
||||||
pip: requirements=/var/www/demo/requirements.txt virtualenv=/var/www/demo/.venv
|
|
||||||
notify: restart apache2
|
|
||||||
|
|
||||||
- name: de-activate default apache site
|
|
||||||
file: path=/etc/apache2/sites-enabled/000-default.conf state=absent
|
|
||||||
notify: restart apache2
|
|
||||||
|
|
||||||
- name: activate demo apache site
|
|
||||||
file: src=/etc/apache2/sites-available/demo.conf dest=/etc/apache2/sites-enabled/demo.conf state=link
|
|
||||||
notify: restart apache2
|
|
||||||
|
|
||||||
handlers:
|
|
||||||
- name: restart apache2
|
|
||||||
service: name=apache2 state=restarted
|
|
||||||
|
|||||||
11
examples/025_vars_files_group_vars/hosts
Normal file
11
examples/025_vars_files_group_vars/hosts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[control]
|
||||||
|
192.168.11.10
|
||||||
|
|
||||||
|
[database]
|
||||||
|
192.168.11.20
|
||||||
|
|
||||||
|
[loadbalancer]
|
||||||
|
192.168.11.30
|
||||||
|
|
||||||
|
[webserver]
|
||||||
|
192.168.11.40
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- include: control.yml
|
- import_playbook: control.yml
|
||||||
- include: database.yml
|
- import_playbook: database.yml
|
||||||
- include: webserver.yml
|
- import_playbook: webserver.yml
|
||||||
- include: loadbalancer.yml
|
- import_playbook: loadbalancer.yml
|
||||||
- include: playbooks/stack_status.yml
|
- import_playbook: playbooks/stack_status.yml
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- include: control.yml
|
- ansible.builtin.import_playbook: control.yml
|
||||||
- include: database.yml
|
- ansible.builtin.import_playbook: database.yml
|
||||||
- include: webserver.yml
|
- ansible.builtin.import_playbook: webserver.yml
|
||||||
- include: loadbalancer.yml
|
- ansible.builtin.import_playbook: loadbalancer.yml
|
||||||
- include: playbooks/stack_status.yml
|
- ansible.builtin.import_playbook: playbooks/stack_status.yml
|
||||||
|
|||||||
5
examples/034_rols/control.yml
Normal file
5
examples/034_rols/control.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: control
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- control
|
||||||
5
examples/034_rols/database.yml
Normal file
5
examples/034_rols/database.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: database
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- mysql
|
||||||
20
examples/034_rols/demo/app/demo.py
Normal file
20
examples/034_rols/demo/app/demo.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from flask import Flask
|
||||||
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
import os, socket
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URI']
|
||||||
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||||
|
db = SQLAlchemy(app)
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
return 'Hello, from sunny %s!\n' % hostname
|
||||||
|
|
||||||
|
@app.route('/db')
|
||||||
|
def dbtest():
|
||||||
|
return 'Database Connected from %s!\n' % hostname
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run()
|
||||||
7
examples/034_rols/demo/app/demo.wsgi
Normal file
7
examples/034_rols/demo/app/demo.wsgi
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import os
|
||||||
|
os.environ['DATABASE_URI'] = 'mysql://demo:demo@db01/demo'
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.insert(0, '/var/www/demo')
|
||||||
|
|
||||||
|
from demo import app as application
|
||||||
9
examples/034_rols/demo/app/requirements.txt
Normal file
9
examples/034_rols/demo/app/requirements.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
click==7.1.2
|
||||||
|
Flask==1.1.4
|
||||||
|
Flask-SQLAlchemy==2.5.1
|
||||||
|
greenlet==3.5.0
|
||||||
|
itsdangerous==1.1.0
|
||||||
|
Jinja2==2.11.3
|
||||||
|
MarkupSafe==2.0.1
|
||||||
|
SQLAlchemy==1.4.32
|
||||||
|
Werkzeug==1.0.1
|
||||||
12
examples/034_rols/demo/demo.conf
Normal file
12
examples/034_rols/demo/demo.conf
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<VirtualHost *>
|
||||||
|
WSGIScriptAlias / /var/www/demo/demo.wsgi
|
||||||
|
WSGIDaemonProcess demo python-home=/var/www/demo/.venv python-path=/var/www/demo
|
||||||
|
WSGIProcessGroup demo
|
||||||
|
|
||||||
|
<Directory /var/www/demo>
|
||||||
|
WSGIProcessGroup demo
|
||||||
|
WSGIApplicationGroup %{GLOBAL}
|
||||||
|
Order deny,allow
|
||||||
|
Allow from all
|
||||||
|
</Directory>
|
||||||
|
</VirtualHost>
|
||||||
11
examples/034_rols/hosts
Normal file
11
examples/034_rols/hosts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[control]
|
||||||
|
192.168.11.10
|
||||||
|
|
||||||
|
[database]
|
||||||
|
192.168.11.20
|
||||||
|
|
||||||
|
[loadbalancer]
|
||||||
|
192.168.11.30
|
||||||
|
|
||||||
|
[webserver]
|
||||||
|
192.168.11.40
|
||||||
6
examples/034_rols/loadbalancer.yml
Normal file
6
examples/034_rols/loadbalancer.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- hosts: loadbalancer
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- nginx
|
||||||
|
|
||||||
11
examples/034_rols/playbooks/hostname.yml
Normal file
11
examples/034_rols/playbooks/hostname.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Ping to servers
|
||||||
|
ping:
|
||||||
|
- name: Get hostname
|
||||||
|
command: hostname
|
||||||
|
register: hostname
|
||||||
|
- name: Show hostname with message
|
||||||
|
debug:
|
||||||
|
msg: "The hostname of this server is {{ hostname.stdout }}"
|
||||||
33
examples/034_rols/playbooks/stack_restart.yml
Normal file
33
examples/034_rols/playbooks/stack_restart.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
# Bring stack down
|
||||||
|
- hosts: loadbalancer
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- service: name=nginx state=stopped
|
||||||
|
- wait_for: port=80 state=drained
|
||||||
|
|
||||||
|
- hosts: webserver
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- service: name=apache2 state=stopped
|
||||||
|
- wait_for: port=80 state=stopped
|
||||||
|
|
||||||
|
# Restart mysql
|
||||||
|
- hosts: database
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- service: name=mysql state=restarted
|
||||||
|
- wait_for: port=3306 state=started
|
||||||
|
|
||||||
|
# Bring stack up
|
||||||
|
- hosts: webserver
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- service: name=apache2 state=started
|
||||||
|
- wait_for: port=80
|
||||||
|
|
||||||
|
- hosts: loadbalancer
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- service: name=nginx state=started
|
||||||
|
- wait_for: port=80
|
||||||
70
examples/034_rols/playbooks/stack_status.yml
Normal file
70
examples/034_rols/playbooks/stack_status.yml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
---
|
||||||
|
- hosts: loadbalancer
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: verify nginx service
|
||||||
|
command: service nginx status
|
||||||
|
|
||||||
|
- name: verify nginx is listening on 80
|
||||||
|
wait_for: port=80 timeout=1
|
||||||
|
|
||||||
|
- hosts: webserver
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: verify apache2 service
|
||||||
|
command: service apache2 status
|
||||||
|
|
||||||
|
- name: verify apache2 is listening on 80
|
||||||
|
wait_for: port=80 timeout=1
|
||||||
|
|
||||||
|
- hosts: database
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: verify mysql service
|
||||||
|
command: service mysql status
|
||||||
|
|
||||||
|
- name: verify mysql is listening on 3306
|
||||||
|
wait_for: port=3306 timeout=1
|
||||||
|
|
||||||
|
- hosts: loadbalancer
|
||||||
|
tasks:
|
||||||
|
- name: verify backend index response
|
||||||
|
uri: url=http://{{item}} return_content=yes
|
||||||
|
loop: "{{ groups.webserver }}"
|
||||||
|
register: app_index
|
||||||
|
|
||||||
|
- fail: msg="index failed to return content"
|
||||||
|
when: ("Hello, from sunny " ~ item.content ~ "!") in item.content
|
||||||
|
loop: "{{app_index.results}}"
|
||||||
|
|
||||||
|
- name: verify backend db response
|
||||||
|
uri: url=http://{{item}}/db return_content=yes
|
||||||
|
loop: "{{ groups.webserver }}"
|
||||||
|
register: app_db
|
||||||
|
|
||||||
|
- fail: msg="db failed to return content"
|
||||||
|
when: ("Database Connected from " ~ item.content ~ "!") in item.content
|
||||||
|
loop: "{{app_db.results}}"
|
||||||
|
|
||||||
|
- hosts: control
|
||||||
|
tasks:
|
||||||
|
- name: get elements from loadbalancer group
|
||||||
|
debug: var=groups.loadbalancer
|
||||||
|
|
||||||
|
- name: verify end-to-end connectivity to loadbalancer
|
||||||
|
uri: url=http://{{item}} return_content=yes
|
||||||
|
loop: "{{ groups.loadbalancer }}"
|
||||||
|
register: lb_connectivity
|
||||||
|
|
||||||
|
- fail: msg="index failed to return content"
|
||||||
|
when: ("Hello, from sunny " ~ item.content ~ "!") in item.content
|
||||||
|
loop: "{{lb_connectivity.results}}"
|
||||||
|
|
||||||
|
- name: verify end-to-end db response
|
||||||
|
uri: url=http://{{item}}/db return_content=yes
|
||||||
|
loop: "{{ groups.loadbalancer }}"
|
||||||
|
register: lb_db
|
||||||
|
|
||||||
|
- fail: msg="db failed to return content"
|
||||||
|
when: ("Database Connected from " ~ item.content ~ "!") in item.content
|
||||||
|
loop: "{{lb_db.results}}"
|
||||||
0
examples/000_example/roles/apache/README.md → examples/034_rols/roles/apache2/README.md
Executable file → Normal file
0
examples/000_example/roles/apache/README.md → examples/034_rols/roles/apache2/README.md
Executable file → Normal file
2
examples/034_rols/roles/apache2/defaults/main.yml
Normal file
2
examples/034_rols/roles/apache2/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for apache2
|
||||||
4
examples/034_rols/roles/apache2/handlers/main.yml
Normal file
4
examples/034_rols/roles/apache2/handlers/main.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
# handlers file for apache2
|
||||||
|
- name: restart apache2
|
||||||
|
service: name=apache2 state=restarted
|
||||||
139
examples/034_rols/roles/apache2/meta/main.yml
Normal file
139
examples/034_rols/roles/apache2/meta/main.yml
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: your name
|
||||||
|
description:
|
||||||
|
company: your company (optional)
|
||||||
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
|
# next line and provide a value
|
||||||
|
# issue_tracker_url: http://example.com/issue/tracker
|
||||||
|
# Some suggested licenses:
|
||||||
|
# - BSD (default)
|
||||||
|
# - MIT
|
||||||
|
# - GPLv2
|
||||||
|
# - GPLv3
|
||||||
|
# - Apache
|
||||||
|
# - CC-BY
|
||||||
|
license: license (GPLv2, CC-BY, etc)
|
||||||
|
min_ansible_version: 1.2
|
||||||
|
#
|
||||||
|
# Below are all platforms currently available. Just uncomment
|
||||||
|
# the ones that apply to your role. If you don't see your
|
||||||
|
# platform on this list, let us know and we'll get it added!
|
||||||
|
#
|
||||||
|
#platforms:
|
||||||
|
#- name: EL
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 5
|
||||||
|
# - 6
|
||||||
|
# - 7
|
||||||
|
#- name: GenericUNIX
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - any
|
||||||
|
#- name: Fedora
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 16
|
||||||
|
# - 17
|
||||||
|
# - 18
|
||||||
|
# - 19
|
||||||
|
# - 20
|
||||||
|
# - 21
|
||||||
|
# - 22
|
||||||
|
#- name: Windows
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 2012R2
|
||||||
|
#- name: SmartOS
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - any
|
||||||
|
#- name: opensuse
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 12.1
|
||||||
|
# - 12.2
|
||||||
|
# - 12.3
|
||||||
|
# - 13.1
|
||||||
|
# - 13.2
|
||||||
|
#- name: Amazon
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 2013.03
|
||||||
|
# - 2013.09
|
||||||
|
#- name: GenericBSD
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - any
|
||||||
|
#- name: FreeBSD
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 8.0
|
||||||
|
# - 8.1
|
||||||
|
# - 8.2
|
||||||
|
# - 8.3
|
||||||
|
# - 8.4
|
||||||
|
# - 9.0
|
||||||
|
# - 9.1
|
||||||
|
# - 9.1
|
||||||
|
# - 9.2
|
||||||
|
#- name: Ubuntu
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - lucid
|
||||||
|
# - maverick
|
||||||
|
# - natty
|
||||||
|
# - oneiric
|
||||||
|
# - precise
|
||||||
|
# - quantal
|
||||||
|
# - raring
|
||||||
|
# - saucy
|
||||||
|
# - trusty
|
||||||
|
# - utopic
|
||||||
|
# - vivid
|
||||||
|
#- name: SLES
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 10SP3
|
||||||
|
# - 10SP4
|
||||||
|
# - 11
|
||||||
|
# - 11SP1
|
||||||
|
# - 11SP2
|
||||||
|
# - 11SP3
|
||||||
|
#- name: GenericLinux
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - any
|
||||||
|
#- name: Debian
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - etch
|
||||||
|
# - jessie
|
||||||
|
# - lenny
|
||||||
|
# - squeeze
|
||||||
|
# - wheezy
|
||||||
|
#
|
||||||
|
# Below are all categories currently available. Just as with
|
||||||
|
# the platforms above, uncomment those that apply to your role.
|
||||||
|
#
|
||||||
|
#categories:
|
||||||
|
#- cloud
|
||||||
|
#- cloud:ec2
|
||||||
|
#- cloud:gce
|
||||||
|
#- cloud:rax
|
||||||
|
#- clustering
|
||||||
|
#- database
|
||||||
|
#- database:nosql
|
||||||
|
#- database:sql
|
||||||
|
#- development
|
||||||
|
#- monitoring
|
||||||
|
#- networking
|
||||||
|
#- packaging
|
||||||
|
#- system
|
||||||
|
#- web
|
||||||
|
dependencies: []
|
||||||
|
# List your role dependencies here, one per line.
|
||||||
|
# Be sure to remove the '[]' above if you add dependencies
|
||||||
|
# to this list.
|
||||||
|
|
||||||
45
examples/034_rols/roles/apache2/tasks/main.yml
Normal file
45
examples/034_rols/roles/apache2/tasks/main.yml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
# tasks file for apache2
|
||||||
|
- name: install web components
|
||||||
|
apt: name={{item}} state=present update_cache=yes
|
||||||
|
loop:
|
||||||
|
- apache2
|
||||||
|
- python3-pip
|
||||||
|
- python3-virtualenv
|
||||||
|
- python3-venv
|
||||||
|
- python3-mysqldb
|
||||||
|
- libapache2-mod-wsgi-py3
|
||||||
|
|
||||||
|
- name: ensure apache2 started
|
||||||
|
service: name=apache2 state=started enabled=yes
|
||||||
|
|
||||||
|
- name: ensure mod_wsgi enabled
|
||||||
|
apache2_module: state=present name=wsgi
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: copy demo app source
|
||||||
|
copy: src=demo/app/ dest=/var/www/demo mode=0755
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: copy apache virtual host config
|
||||||
|
copy: src=demo/demo.conf dest=/etc/apache2/sites-available mode=0755
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: initialize virtualenv
|
||||||
|
shell: python3 -m venv /var/www/demo/.venv creates=/var/www/demo/.venv
|
||||||
|
|
||||||
|
- name: source virtualenv and install app dependencies
|
||||||
|
shell: . /var/www/demo/.venv/bin/activate && pip install -r /var/www/demo/requirements.txt
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: setup python virtualenv
|
||||||
|
pip: requirements=/var/www/demo/requirements.txt virtualenv=/var/www/demo/.venv
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: de-activate default apache site
|
||||||
|
file: path=/etc/apache2/sites-enabled/000-default.conf state=absent
|
||||||
|
notify: restart apache2
|
||||||
|
|
||||||
|
- name: activate demo apache site
|
||||||
|
file: src=/etc/apache2/sites-available/demo.conf dest=/etc/apache2/sites-enabled/demo.conf state=link
|
||||||
|
notify: restart apache2
|
||||||
2
examples/034_rols/roles/apache2/vars/main.yml
Normal file
2
examples/034_rols/roles/apache2/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for apache2
|
||||||
0
examples/000_example/roles/common/README.md → examples/034_rols/roles/control/README.md
Executable file → Normal file
0
examples/000_example/roles/common/README.md → examples/034_rols/roles/control/README.md
Executable file → Normal file
2
examples/034_rols/roles/control/defaults/main.yml
Normal file
2
examples/034_rols/roles/control/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for control
|
||||||
2
examples/034_rols/roles/control/handlers/main.yml
Normal file
2
examples/034_rols/roles/control/handlers/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for control
|
||||||
139
examples/034_rols/roles/control/meta/main.yml
Normal file
139
examples/034_rols/roles/control/meta/main.yml
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: your name
|
||||||
|
description:
|
||||||
|
company: your company (optional)
|
||||||
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
|
# next line and provide a value
|
||||||
|
# issue_tracker_url: http://example.com/issue/tracker
|
||||||
|
# Some suggested licenses:
|
||||||
|
# - BSD (default)
|
||||||
|
# - MIT
|
||||||
|
# - GPLv2
|
||||||
|
# - GPLv3
|
||||||
|
# - Apache
|
||||||
|
# - CC-BY
|
||||||
|
license: license (GPLv2, CC-BY, etc)
|
||||||
|
min_ansible_version: 1.2
|
||||||
|
#
|
||||||
|
# Below are all platforms currently available. Just uncomment
|
||||||
|
# the ones that apply to your role. If you don't see your
|
||||||
|
# platform on this list, let us know and we'll get it added!
|
||||||
|
#
|
||||||
|
#platforms:
|
||||||
|
#- name: EL
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 5
|
||||||
|
# - 6
|
||||||
|
# - 7
|
||||||
|
#- name: GenericUNIX
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - any
|
||||||
|
#- name: Fedora
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 16
|
||||||
|
# - 17
|
||||||
|
# - 18
|
||||||
|
# - 19
|
||||||
|
# - 20
|
||||||
|
# - 21
|
||||||
|
# - 22
|
||||||
|
#- name: Windows
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 2012R2
|
||||||
|
#- name: SmartOS
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - any
|
||||||
|
#- name: opensuse
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 12.1
|
||||||
|
# - 12.2
|
||||||
|
# - 12.3
|
||||||
|
# - 13.1
|
||||||
|
# - 13.2
|
||||||
|
#- name: Amazon
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 2013.03
|
||||||
|
# - 2013.09
|
||||||
|
#- name: GenericBSD
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - any
|
||||||
|
#- name: FreeBSD
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 8.0
|
||||||
|
# - 8.1
|
||||||
|
# - 8.2
|
||||||
|
# - 8.3
|
||||||
|
# - 8.4
|
||||||
|
# - 9.0
|
||||||
|
# - 9.1
|
||||||
|
# - 9.1
|
||||||
|
# - 9.2
|
||||||
|
#- name: Ubuntu
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - lucid
|
||||||
|
# - maverick
|
||||||
|
# - natty
|
||||||
|
# - oneiric
|
||||||
|
# - precise
|
||||||
|
# - quantal
|
||||||
|
# - raring
|
||||||
|
# - saucy
|
||||||
|
# - trusty
|
||||||
|
# - utopic
|
||||||
|
# - vivid
|
||||||
|
#- name: SLES
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 10SP3
|
||||||
|
# - 10SP4
|
||||||
|
# - 11
|
||||||
|
# - 11SP1
|
||||||
|
# - 11SP2
|
||||||
|
# - 11SP3
|
||||||
|
#- name: GenericLinux
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - any
|
||||||
|
#- name: Debian
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - etch
|
||||||
|
# - jessie
|
||||||
|
# - lenny
|
||||||
|
# - squeeze
|
||||||
|
# - wheezy
|
||||||
|
#
|
||||||
|
# Below are all categories currently available. Just as with
|
||||||
|
# the platforms above, uncomment those that apply to your role.
|
||||||
|
#
|
||||||
|
#categories:
|
||||||
|
#- cloud
|
||||||
|
#- cloud:ec2
|
||||||
|
#- cloud:gce
|
||||||
|
#- cloud:rax
|
||||||
|
#- clustering
|
||||||
|
#- database
|
||||||
|
#- database:nosql
|
||||||
|
#- database:sql
|
||||||
|
#- development
|
||||||
|
#- monitoring
|
||||||
|
#- networking
|
||||||
|
#- packaging
|
||||||
|
#- system
|
||||||
|
#- web
|
||||||
|
dependencies: []
|
||||||
|
# List your role dependencies here, one per line.
|
||||||
|
# Be sure to remove the '[]' above if you add dependencies
|
||||||
|
# to this list.
|
||||||
|
|
||||||
6
examples/034_rols/roles/control/tasks/main.yml
Normal file
6
examples/034_rols/roles/control/tasks/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: install tools
|
||||||
|
apt: name={{item}} state=present update_cache=yes
|
||||||
|
loop:
|
||||||
|
- curl
|
||||||
|
- python3-httplib2
|
||||||
2
examples/034_rols/roles/control/vars/main.yml
Normal file
2
examples/034_rols/roles/control/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for control
|
||||||
38
examples/034_rols/roles/demo_app/README.md
Normal file
38
examples/034_rols/roles/demo_app/README.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
Role Name
|
||||||
|
=========
|
||||||
|
|
||||||
|
A brief description of the role goes here.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||||
|
|
||||||
|
- hosts: servers
|
||||||
|
roles:
|
||||||
|
- { role: username.rolename, x: 42 }
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
BSD
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||||
2
examples/034_rols/roles/demo_app/defaults/main.yml
Normal file
2
examples/034_rols/roles/demo_app/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for demo_app
|
||||||
2
examples/034_rols/roles/demo_app/handlers/main.yml
Normal file
2
examples/034_rols/roles/demo_app/handlers/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for demo_app
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user