├── inventory ├── uptime.sh ├── cloud-second-semester-examination ├── cd into .ssh.PNG ├── vagrant init.PNG ├── content of .ssh.PNG ├── cronjob added.PNG ├── install ansible.PNG ├── key generated.PNG ├── ping the slave.PNG ├── ansible directory.PNG ├── create a LAMP script.PNG ├── created my playbook.PNG ├── vagrantfile placed.PNG ├── check ansible version.PNG ├── copy pub key to slave.PNG ├── create inventory file.PNG ├── successfully deployed.PNG ├── vagrant init complete.PNG ├── configure your vagrantfile.PNG ├── final laravel landing page.PNG ├── logged into master node now.PNG ├── waiting to generate app key.PNG ├── generate keygen on master node.PNG ├── open vagrant file with vscode.PNG ├── restart sshd service on slave.PNG ├── run vagrant up to load the vms.PNG ├── vagrant ssh into master node.PNG ├── running our bashscript on the slave.PNG ├── give execution permission to the script.PNG ├── script running to install on the slave.PNG ├── script already rendering apache2 default page.PNG └── turn on passwordAuthentication on slave mode.PNG ├── playbook.yml ├── LAMP.sh └── project_steps.md /inventory: -------------------------------------------------------------------------------- 1 | 192.168.23.225 2 | -------------------------------------------------------------------------------- /uptime.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get the current uptime 4 | uptime > /home/vagrant/slave-uptime.log 5 | -------------------------------------------------------------------------------- /cloud-second-semester-examination/cd into .ssh.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/cd into .ssh.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/vagrant init.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/vagrant init.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/content of .ssh.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/content of .ssh.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/cronjob added.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/cronjob added.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/install ansible.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/install ansible.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/key generated.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/key generated.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/ping the slave.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/ping the slave.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/ansible directory.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/ansible directory.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/create a LAMP script.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/create a LAMP script.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/created my playbook.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/created my playbook.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/vagrantfile placed.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/vagrantfile placed.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/check ansible version.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/check ansible version.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/copy pub key to slave.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/copy pub key to slave.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/create inventory file.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/create inventory file.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/successfully deployed.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/successfully deployed.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/vagrant init complete.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/vagrant init complete.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/configure your vagrantfile.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/configure your vagrantfile.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/final laravel landing page.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/final laravel landing page.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/logged into master node now.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/logged into master node now.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/waiting to generate app key.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/waiting to generate app key.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/generate keygen on master node.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/generate keygen on master node.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/open vagrant file with vscode.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/open vagrant file with vscode.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/restart sshd service on slave.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/restart sshd service on slave.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/run vagrant up to load the vms.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/run vagrant up to load the vms.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/vagrant ssh into master node.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/vagrant ssh into master node.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/running our bashscript on the slave.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/running our bashscript on the slave.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/give execution permission to the script.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/give execution permission to the script.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/script running to install on the slave.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/script running to install on the slave.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/script already rendering apache2 default page.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/script already rendering apache2 default page.PNG -------------------------------------------------------------------------------- /cloud-second-semester-examination/turn on passwordAuthentication on slave mode.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/second-cloud-project/HEAD/cloud-second-semester-examination/turn on passwordAuthentication on slave mode.PNG -------------------------------------------------------------------------------- /playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: deploy lamp stack 3 | hosts: all 4 | become: true 5 | tasks: 6 | - name: Copy file with owner and permissions 7 | ansible.builtin.copy: 8 | src: /home/vagrant/LAMP.sh 9 | dest: /home/vagrant/LAMP.sh 10 | owner: root 11 | group: root 12 | mode: '0755' 13 | - name: copy cron job with owner and permissions 14 | ansible.builtin.copy: 15 | src: /home/vagrant/uptime.sh 16 | dest: /home/vagrant/uptime.sh 17 | owner: root 18 | group: root 19 | mode: '0755' 20 | 21 | - name: install lamp stack and laravel 22 | script: /home/vagrant/LAMP.sh 23 | 24 | - name: Add cron job 25 | cron: 26 | name: uptime cron job 27 | minute: "0" 28 | hour: 0 29 | job: /home/vagrant/uptime.sh 30 | -------------------------------------------------------------------------------- /LAMP.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################################### 3 | # installation of lamp stack and laravel 4 | #author: Noah Anthony 5 | #company: Altschool Africa 6 | #Position: cloud engineering student 7 | #Student id= ALT/SOE/023/2141 8 | ################################################### 9 | #always update your newly installed linux system before doing any installation 10 | sudo apt update -y 11 | #install your apache2 webserver 12 | sudo apt install apache2 -y 13 | #add the php ondrej repository 14 | sudo add-apt-repository ppa:ondrej/php --yes 15 | #update your repository again so that the newly added ondrej repo would be updated 16 | sudo apt update -y 17 | # install php version 8.2 18 | sudo apt install php8.2 -y 19 | #install some of those php dependencies that are needed for laravel to work, you can check the laravel documentation to see the needed dependencies 20 | sudo apt install php8.2-curl php8.2-dom php8.2-mbstring php8.2-xml php8.2-mysql zip unzip -y 21 | #enable rewrite which helps us to manipulate URL requests on the server's side 22 | sudo a2enmod rewrite 23 | #restart your apache server 24 | sudo systemctl restart apache2 25 | #change directory to the bin directory 26 | cd /usr/bin 27 | #install composer that php need to make it easier to manage the libraries in our project by installing and updating them automatically 28 | install composer globally -y 29 | sudo curl -sS https://getcomposer.org/installer | sudo php -q 30 | #move the content of the default composer.phar 31 | sudo mv composer.phar composer 32 | #change directory in /var/www directory so we can clone of laravel repo there 33 | cd /var/www/ 34 | #clone the laravel github repository 35 | sudo git clone https://github.com/laravel/laravel.git 36 | sudo chown -R $USER:$USER /var/www/laravel 37 | cd laravel/ 38 | install composer autoloader 39 | composer install --optimize-autoloader --no-dev --no-interaction 40 | composer update --no-interaction 41 | #copy the content of the default env file to .env 42 | sudo cp .env.example .env 43 | sudo chown -R www-data storage 44 | sudo chown -R www-data bootstrap/cache 45 | cd 46 | cd /etc/apache2/sites-available/ 47 | sudo touch latest.conf 48 | sudo echo ' 49 | ServerName localhost 50 | DocumentRoot /var/www/laravel/public 51 | 52 | 53 | AllowOverride All 54 | 55 | 56 | ErrorLog ${APACHE_LOG_DIR}/laravel-error.log 57 | CustomLog ${APACHE_LOG_DIR}/laravel-access.log combined 58 | ' | sudo tee /etc/apache2/sites-available/latest.conf 59 | sudo a2ensite latest.conf 60 | sudo a2dissite 000-default.conf 61 | sudo systemctl restart apache2 62 | cd 63 | # we would be installing our mysql server here and perform every steps needed for mysql to run successfully 64 | sudo apt install mysql-server -y 65 | sudo apt install mysql-client -y 66 | sudo systemctl start mysql 67 | sudo mysql -uroot -e "CREATE DATABASE Tinubu;" 68 | sudo mysql -uroot -e "CREATE USER 'shettima'@'localhost' IDENTIFIED BY 'cardoso';" 69 | sudo mysql -uroot -e "GRANT ALL PRIVILEGES ON Tinubu.* TO 'shettima'@'localhost';" 70 | cd /var/www/laravel 71 | sudo sed -i "23 s/^#//g" /var/www/laravel/.env 72 | sudo sed -i "24 s/^#//g" /var/www/laravel/.env 73 | sudo sed -i "25 s/^#//g" /var/www/laravel/.env 74 | sudo sed -i "26 s/^#//g" /var/www/laravel/.env 75 | sudo sed -i "27 s/^#//g" /var/www/laravel/.env 76 | sudo sed -i '22 s/=sqlite/=mysql/' /var/www/laravel/.env 77 | sudo sed -i '23 s/=127.0.0.1/=localhost/' /var/www/laravel/.env 78 | sudo sed -i '24 s/=3306/=3306/' /var/www/laravel/.env 79 | sudo sed -i '25 s/=laravel/=Tinubu/' /var/www/laravel/.env 80 | sudo sed -i '26 s/=root/=shettima/' /var/www/laravel/.env 81 | sudo sed -i '27 s/=/=cardoso/' /var/www/laravel/.env 82 | sudo php artisan key:generate 83 | sudo php artisan storage:link 84 | sudo php artisan migrate 85 | sudo php artisan db:seed 86 | sudo systemctl restart apache2 -------------------------------------------------------------------------------- /project_steps.md: -------------------------------------------------------------------------------- 1 | # This shows the steps it takes to automate virtual machines using vagrant and also installing LAMP stack and laravel on our machine 2 | `1. we would automate the provisioning of our virtual machine, we would open a blank folder and run the command so we can place a vagrantfile there` 3 | ![configure your virtual machine](./cloud-second-semester-examination/vagrant%20init.PNG) 4 | 5 | `2. after the vagrantfile has been placed in the directory, we would edit it to power up our multiple virtual machines` 6 | ![configure multiple virtual machines](./cloud-second-semester-examination/configure%20your%20vagrantfile.PNG) 7 | 8 | `3. load the vms, using vagrant up` 9 | ![vagrant up](./cloud-second-semester-examination/run%20vagrant%20up%20to%20load%20the%20vms.PNG) 10 | 11 | `4. Then we log into our master node using vagrant ssh masternode, this will be after we have done vagrant up to download the virtual boxes` 12 | ![vagrant ssh](./cloud-second-semester-examination/logged%20into%20master%20node%20now.PNG) 13 | 14 | `5, we would also log in inside the slave node and go into /etc/ssh/sshd_config to do some editing so we can ssh into the slave node from the master, here we would be changing passwordAuthentication to yes and also pubkeyAuthentication to ye` 15 | ![edit sshd_config file](./cloud-second-semester-examination/turn%20on%20passwordAuthentication%20on%20slave%20mode.PNG) 16 | 17 | `6. we would now restart the sshd so that the new configuration can take effect` 18 | ![restart sshd](./cloud-second-semester-examination/restart%20sshd%20service%20on%20slave.PNG) 19 | 20 | `7. Go back to your master node to generate pubkey and private key on it, you will cd into .ssh directory then generate the key there` 21 | ![ssh-keygen](./cloud-second-semester-examination/key%20generated.PNG) 22 | 23 | `8. copy the pubkey generated into the authorized_key directory of the slave node by using the ssh-copy-id command inside of your .ssh directory, you will need the user in the slave node and its ip address. Also you will be asked of fingerprint and its password` 24 | ![ssh-copy-id](./cloud-second-semester-examination/copy%20pub%20key%20to%20slave.PNG) 25 | 26 | `9. let us now install ansible on our master node` 27 | ![sudo apt install ansible](./cloud-second-semester-examination/install%20ansible.PNG) 28 | 29 | `10. check if ansible was installed successfully, then create an inventory file inside of the ansible directory, make sure you add the ip address of the slave node inside of the inventory file you just created` 30 | ![ansible --version](./cloud-second-semester-examination/create%20inventory%20file.PNG) 31 | 32 | `11. try to ping the slave node from your master node to be sure your connection is working` 33 | ![ansible slave -i inventory -m ping](./cloud-second-semester-examination/ping%20the%20slave.PNG) 34 | 35 | `12. create your playbook inside of your ansible directory` 36 | ![create your playbook](./cloud-second-semester-examination/created%20my%20playbook.PNG) 37 | 38 | `13. create your bash script inside of your home directory` 39 | ![create your bash script](./cloud-second-semester-examination/create%20a%20LAMP%20script.PNG) 40 | 41 | `14. give execution permission the bash script` 42 | ![](./cloud-second-semester-examination/give%20execution%20permission%20to%20the%20script.PNG) 43 | 44 | ## we now want to deploy our bash script to run on our slave node now 45 | 46 | `1. we would now change directory in our ansible folder and run our playbook now` 47 | ![running our ansible playbook](./cloud-second-semester-examination/running%20our%20bashscript%20on%20the%20slave.PNG) 48 | 49 | `2. waiting for our playbook to finish running on the slave node` 50 | ![script running](./cloud-second-semester-examination/script%20running%20to%20install%20on%20the%20slave.PNG) 51 | 52 | `3. apache2 default page already rendered` 53 | ![apache2 webserver running](./cloud-second-semester-examination/script%20already%20rendering%20apache2%20default%20page.PNG) 54 | 55 | `4. waiting for our database to fully be activated by generating the app key` 56 | ![app key](./cloud-second-semester-examination/waiting%20to%20generate%20app%20key.PNG) 57 | 58 | `5. script was successfully ran on the slave node` 59 | ![success](./cloud-second-semester-examination/successfully%20deployed.PNG) 60 | 61 | `6. our laravel landing page was a success` 62 | ![landing page](./cloud-second-semester-examination/final%20laravel%20landing%20page.PNG) 63 | 64 | --------------------------------------------------------------------------------