Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Add ansible, packer for attack_server
Browse files Browse the repository at this point in the history
  • Loading branch information
wim-web committed Jan 28, 2021
1 parent 1bf2718 commit be7d80e
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ansible/attack_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- hosts: localhost
become: yes

roles:
- name: apache_bench
- name: locust
- name: attack_server
18 changes: 18 additions & 0 deletions ansible/roles/attack_server/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- name: install git
yum:
name: git

- name: make app dir
file:
path: /var/www/current
state: directory

- name: git clone only locust
shell: |
git init
git config core.sparsecheckout true
git remote add origin https://github.com/wim-web/laravel-load-test.git
echo /locust > .git/info/sparse-checkout
git pull origin master
args:
chdir: /var/www/current
12 changes: 12 additions & 0 deletions ansible/roles/locust/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- name: install python3
yum:
name: "{{ item }}"
loop:
- gcc
- python3
- python3-devel
- python3-libs
- python3-tools

- name: install locust
command: pip3 install locust
40 changes: 40 additions & 0 deletions packer/attack_server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"builders": [
{
"type": "amazon-ebs",
"region": "ap-northeast-1",
"launch_block_device_mappings": [
{
"device_name": "/dev/xvda",
"volume_size": 20,
"iops": 100,
"delete_on_termination": true
}
],
"source_ami_filter": {
"filters": {
"name": "amzn2-ami-hvm-*-x86_64-gp2"
},
"owners": ["137112412989"],
"most_recent": true
},
"ssh_username": "ec2-user",
"ami_name": "attack_{{isotime | clean_ami_name}}",
"instance_type": "t2.micro"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sudo amazon-linux-extras install epel",
"sudo yum -y install ansible"
]
},
{
"type": "ansible-local",
"playbook_file": "../ansible/attack_server.yml",
"playbook_dir": "../ansible"
}
]
}

0 comments on commit be7d80e

Please sign in to comment.