Added self-service script (for webserver)
This commit is contained in:
		
							
								
								
									
										15
									
								
								playbooks/install_nginx.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								playbooks/install_nginx.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| - hosts: nginx | ||||
|   become: true | ||||
|   tasks: | ||||
|   - name: Install nginx | ||||
|     package: | ||||
|       name: nginx | ||||
|       state: present | ||||
|       update_cache: yes | ||||
|     notify: restart nginx | ||||
|    | ||||
|   handlers: | ||||
|     - name: restart nginx | ||||
|       ansible.builtin.service: | ||||
|         name: nginx | ||||
|         state: restarted | ||||
							
								
								
									
										25
									
								
								self_service.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								self_service.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| #!/usr/bin/env bash | ||||
| copy_template() { | ||||
|     cp -f ../../templates/$1 ./$2 | ||||
| } | ||||
|  | ||||
| read -p "Klantnaam: " customerName | ||||
| mkdir -p ./customers/$customerName && cd $_ | ||||
|  | ||||
| read -p "Ip: " ipAddr | ||||
| echo -e "[nginx]\n$ipAddr" > ./inventory | ||||
|  | ||||
| copy_template ./Vagrantfile.template ./Vagrantfile | ||||
| sed -i "s/#{customerName}/$customerName/" ./Vagrantfile | ||||
| sed -i "s/#{ipAddr}/$ipAddr/" ./Vagrantfile | ||||
|  | ||||
| copy_template ./ansible.cfg.template ./ansible.cfg | ||||
|  | ||||
| mkdir -p ./.ssh/ | ||||
| ssh-keygen -t rsa -b 2048 -f ./.ssh/id_rsa | ||||
|  | ||||
| vagrant up | ||||
| ansible all -m ping | ||||
| ansible-playbook --ask-become-pass ./../../playbooks/install_nginx.yml  | ||||
|  | ||||
| firefox $ipAddr | ||||
							
								
								
									
										18
									
								
								templates/Vagrantfile.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								templates/Vagrantfile.template
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| Vagrant.configure("2") do |config| | ||||
|   config.ssh.insert_key = false | ||||
|   config.ssh.private_key_path = ["./.ssh/id_rsa","~/.vagrant.d/insecure_private_key"] | ||||
|  | ||||
|   config.vm.define "#{customerName}-bloated-debian-web01" do |web01|  | ||||
|     web01.vm.box = "ubuntu/focal64" | ||||
|     web01.vm.hostname = "#{customerName}-bloated-debian-web01" | ||||
|  | ||||
|     web01.vm.network :private_network, ip: "#{ipAddr}" # "192.168.56.12" | ||||
|  | ||||
|     web01.vm.provision "file", source: "./.ssh/id_rsa.pub", destination: "~/.ssh/authorized_keys" | ||||
|     web01.vm.provider "virtualbox" do |vb| | ||||
|       vb.memory = "1024" | ||||
|       vb.gui = false | ||||
|       vb.name = "#{customerName}-bloated-debian-web01" | ||||
|     end | ||||
|   end | ||||
| end | ||||
							
								
								
									
										4
									
								
								templates/ansible.cfg.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								templates/ansible.cfg.template
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| [defaults] | ||||
| private_key_file = "./.ssh/id_rsa" | ||||
| remote_user = "vagrant" | ||||
| inventory = ./inventory | ||||
		Reference in New Issue
	
	Block a user