|
| 1 | + |
| 2 | +# spin up aws hardware |
| 3 | +- hosts: localhost |
| 4 | + gather_facts: false |
| 5 | + tasks: |
| 6 | + - name: Lookup default VPC |
| 7 | + ec2_vpc_net_info: |
| 8 | + region: "{{ region }}" |
| 9 | + filters: |
| 10 | + isDefault: true |
| 11 | + register: vpc_info |
| 12 | + |
| 13 | + - name: Create cloudformation stack |
| 14 | + cloudformation: |
| 15 | + stack_name: "{{ stack_name }}" |
| 16 | + region: "{{ region }}" |
| 17 | + template_body: "{{ lookup('template', 'cloudformation.yml.j2') }}" |
| 18 | + |
| 19 | + - name: Gather instance details |
| 20 | + ec2_instance_info: |
| 21 | + region: "{{ region }}" |
| 22 | + filters: |
| 23 | + instance-state-name: ["pending", "running"] |
| 24 | + "tag:aws:cloudformation:stack-name": "{{ stack_name }}" |
| 25 | + register: ec2_instances |
| 26 | + |
| 27 | + - name: Add instances to inventory |
| 28 | + add_host: |
| 29 | + name: "{{ item['tags']['ShortName'] }}" |
| 30 | + ansible_host: "{{ item['public_ip_address'] }}" |
| 31 | + ansible_user: "{{ user }}" |
| 32 | + ansible_ssh_private_key_file: "{{ ssh_key }}" |
| 33 | + args: "{{ item }}" |
| 34 | + with_items: "{{ ec2_instances.instances }}" |
| 35 | + |
| 36 | +- hosts: all |
| 37 | + gather_facts: false |
| 38 | + tasks: |
| 39 | + - name: Wait for connection |
| 40 | + wait_for_connection: |
| 41 | + |
| 42 | + - name: Gather facts |
| 43 | + setup: |
| 44 | + |
| 45 | + - name: Configure kernel |
| 46 | + command: |
| 47 | + argv: |
| 48 | + - grubby |
| 49 | + - --remove-args=selinux_1 security=selinux quiet |
| 50 | + - --args=mitigations=0 random.trust_cpu=1 loglevel=7 selinux=0 |
| 51 | + - --update-kernel=ALL |
| 52 | + become: true |
| 53 | + |
| 54 | + - name: Install packages |
| 55 | + package: |
| 56 | + name: |
| 57 | + - git |
| 58 | + become: true |
| 59 | + |
| 60 | + - name: Disable noisy services |
| 61 | + command: |
| 62 | + cmd: "systemctl disable --now {{ item }}" |
| 63 | + loop: "{{ disable_services }}" |
| 64 | + failed_when: false |
| 65 | + become: true |
| 66 | + |
| 67 | + - name: Reboot machine |
| 68 | + reboot: |
| 69 | + become: true |
| 70 | + |
| 71 | + - name: Download JDK |
| 72 | + unarchive: |
| 73 | + src: "{{ jdk_url }}" |
| 74 | + dest: . |
| 75 | + remote_src: true |
| 76 | + |
| 77 | + - name: Configure JDK |
| 78 | + blockinfile: |
| 79 | + path: .bashrc |
| 80 | + block: | |
| 81 | + export JAVA_HOME=/home/{{ user }}/jdk-{{ jdk_version }} |
| 82 | + export PATH=$JAVA_HOME/bin:$PATH |
| 83 | +
|
| 84 | + - name: Configure Gradle |
| 85 | + blockinfile: |
| 86 | + path: .gradle/gradle.properties |
| 87 | + create: true |
| 88 | + block: | |
| 89 | + org.gradle.daemon=false |
| 90 | +
|
| 91 | + - name: Checkout main |
| 92 | + git: |
| 93 | + repo: "[email protected]:{{ (main_branch | split(':'))[0] }}/lucene.git" |
| 94 | + version: "{{ (main_branch | split(':'))[1] }}" |
| 95 | + dest: main |
| 96 | + accept_newhostkey: true |
| 97 | + depth: 1 |
| 98 | + |
| 99 | + - name: Checkout patch |
| 100 | + git: |
| 101 | + repo: "[email protected]:{{ (patch_branch | split(':'))[0] }}/lucene.git" |
| 102 | + version: "{{ (patch_branch | split(':'))[1] }}" |
| 103 | + dest: patch |
| 104 | + accept_newhostkey: true |
| 105 | + depth: 1 |
| 106 | + |
| 107 | + - name: Assemble Sources |
| 108 | + command: |
| 109 | + cmd: "{{ assemble_command }}" |
| 110 | + chdir: "{{ item }}" |
| 111 | + loop: |
| 112 | + - main |
| 113 | + - patch |
| 114 | + |
| 115 | + - name: Run benchmark |
| 116 | + command: |
| 117 | + cmd: "{{ jmh_command }} -rff ~/{{ item }}.txt {{ jmh_args }}" |
| 118 | + chdir: "{{ item }}" |
| 119 | + loop: |
| 120 | + - main |
| 121 | + - patch |
| 122 | + |
| 123 | + - name: Read main results |
| 124 | + command: |
| 125 | + cmd: "cat main.txt" |
| 126 | + register: main_out |
| 127 | + |
| 128 | + - name: Read patch results |
| 129 | + command: |
| 130 | + cmd: "cat patch.txt" |
| 131 | + register: patch_out |
| 132 | + |
| 133 | + - name: Write Report |
| 134 | + copy: |
| 135 | + dest: "build/{{ inventory_hostname }}.log" |
| 136 | + content: | |
| 137 | +
|
| 138 | + {{ inventory_hostname }}: `{{ ansible_processor }}` |
| 139 | +
|
| 140 | + main |
| 141 | + ``` |
| 142 | + {{ main_out.stdout }} |
| 143 | + ``` |
| 144 | + patch |
| 145 | + ``` |
| 146 | + {{ patch_out.stdout }} |
| 147 | + ``` |
| 148 | + delegate_to: localhost |
| 149 | + |
| 150 | +- hosts: localhost |
| 151 | + gather_facts: false |
| 152 | + tasks: |
| 153 | + - name: Create combined report |
| 154 | + shell: |
| 155 | + cmd: "cat build/*.log > build/report.txt" |
0 commit comments