update file for adding lab
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
---
|
||||
# Handler for the webtier: handlers are called by other plays.
|
||||
# See http://docs.ansible.com/playbooks_intro.html for more information about handlers.
|
||||
|
||||
- name: restart iptables
|
||||
service:
|
||||
name: iptables
|
||||
state: restarted
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
# These tasks are responsible for copying the latest dev/production code from
|
||||
# the version control system.
|
||||
|
||||
- name: Copy the code from repository
|
||||
git:
|
||||
repo: "{{ repository }}"
|
||||
dest: /var/www/html/
|
||||
|
||||
- name: Creates the index.php file
|
||||
template:
|
||||
src: index.php.j2
|
||||
dest: /var/www/html/index.php
|
||||
become: yes
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
# These tasks install http and the php modules.
|
||||
|
||||
- name: Install http and php etc
|
||||
apt:
|
||||
name: ['apache2', 'php', 'php-mysql', 'git']
|
||||
state: present
|
||||
become: yes
|
||||
|
||||
- name: Recursively remove directory
|
||||
ansible.builtin.file:
|
||||
path: /var/www/html
|
||||
state: absent
|
||||
|
||||
- name: Create a directory if it does not exist
|
||||
ansible.builtin.file:
|
||||
path: /var/www/html
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
|
||||
- name: http service state
|
||||
service:
|
||||
name: apache2
|
||||
state: started
|
||||
enabled: yes
|
||||
become: yes
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- include: install_httpd.yml
|
||||
- include: copy_code.yml
|
||||
@@ -0,0 +1,24 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Ansible Application</title>
|
||||
</head>
|
||||
<body>
|
||||
</br>
|
||||
<a href=http://{{ publicip }}/index.html>Homepage</a>
|
||||
</br>
|
||||
<?php
|
||||
Print "Hello, World! I am a web server configured using Ansible and I am : ";
|
||||
echo exec('hostname');
|
||||
Print "</BR>";
|
||||
echo "List of Databases: </BR>";
|
||||
{% for host in groups['dbservers'] %}
|
||||
$link = mysqli_connect('{{ databasepublicip }}', '{{ hostvars[host].dbuser }}', '{{ hostvars[host].upassword }}') or die(mysqli_connect_error($link));
|
||||
{% endfor %}
|
||||
$res = mysqli_query($link, "SHOW DATABASES;");
|
||||
while ($row = mysqli_fetch_assoc($res)) {
|
||||
echo $row['Database'] . "\n";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user