-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ansible Controller and Restructuring (#14)
* [WIP] ansible controller: untested implementation of setup and config; need to solve repo forking first before testing * Fixing setup and SSH keygen. Still WIP * replace deprecated ec2 role with ec2_instance * WIP bugfixing aws-controller * WIP bugfixing aws-controller, updating git/aws key generation * Fix regression bugs from rebase (mainly the tagging of instances) * Fix awscli, boto3, and ansible installation * Add untested roles to install seal and abc * Restructure repo as discussed in #7 * Removed deprecated examples * Fix demo example * Update repotemplate for project dir environment variable * Fix result storage * Remove pps specific roles * Fix minor bugs from restructuring * Fix bug from rebase Co-authored-by: Miro Haller <[email protected]>
- Loading branch information
Showing
71 changed files
with
658 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ pyinputplus = "*" | |
argparse = "*" | ||
|
||
[requires] | ||
python_version = "3.8" | ||
python_version = "3.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
[defaults] | ||
INVENTORY = inventory | ||
INVENTORY = src/inventory | ||
roles_path = ${PWD}/src/roles:${DOES_PROJECT_DIR}/does_config/roles | ||
ANSIBLE_CALLBACKS_ENABLED = community.general.selective | ||
inventory_ignore_extensions = ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo, .j2 | ||
|
||
ansible_ssh_common_args = '-o StrictHostKeyChecking=no -o ForwardAgent=yes' | ||
|
||
|
||
# TODO: activate / deactivate to only show the pretty log output | ||
stdout_callback = community.general.selective |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# The following files are ignored because they are generated by the repotemplate.py script. | ||
# For your own experiments, remove this .gitignore file to commit hand-written experiment configurations. | ||
all | ||
ansible_controller | ||
client | ||
server | ||
small |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
|
||
################################################################################## | ||
# This playbook sets up an ansible controller on AWS. This instance is able to # | ||
# run the experiment playbook and gather the results. It is intended to be used # | ||
# as a long-running instance where GitHub actions can send commands to, to # | ||
# trigger experiment runs. # | ||
################################################################################## | ||
|
||
########################################################################## | ||
# Setup Ansible Controller # | ||
########################################################################## | ||
- name: Create ansible controller | ||
hosts: localhost | ||
tasks: | ||
|
||
- name: Template dynamic inventory config file | ||
# we do this because we want to have the project id as an inventory filter (such that only ec2 instances with a corresponding tag are visible) | ||
template: | ||
src: resources/inventory/aws_ec2.yml.j2 | ||
dest: inventory/aws_ec2.yml | ||
mode: 0755 | ||
vars: | ||
prj_clear: True | ||
is_ansible_controller: True | ||
|
||
# Load variables | ||
- name: Load group variables | ||
include_role: | ||
name: load-group-vars | ||
vars: | ||
groups_to_load: | ||
- all | ||
|
||
- name: Manually load variables for ansible_controller | ||
include_vars: | ||
file: "{{ external_group_vars_dir }}/ansible_controller/main.yml" | ||
|
||
- name: Setup AWS VPC | ||
include_role: | ||
name: suite-aws-vpc-create | ||
|
||
- name: Create AWS EC2 instance for ansible controller | ||
include_role: | ||
name: ansible-controller-ec2 | ||
|
||
- name: Setup ansible controller | ||
hosts: ansible_controller | ||
|
||
tasks: | ||
- name: Load group variables | ||
include_role: | ||
name: load-group-vars | ||
vars: | ||
groups_to_load: | ||
- all | ||
- ansible_controller | ||
|
||
- name: Configure the EC2 instance for running the AWS Ansible Experiment Suite | ||
include_role: | ||
name: ansible-controller-setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
does_project_dir: "{{ lookup('env', 'DOES_PROJECT_DIR') }}" | ||
does_config_dir: "{{ does_project_dir }}/does_config" | ||
external_group_vars_dir: "{{ does_config_dir }}/group_vars" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This is generated dynamically by ansible | ||
aws_ec2.yml |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-----BEGIN PGP PUBLIC KEY BLOCK----- | ||
|
||
mQINBF2Cr7UBEADJZHcgusOJl7ENSyumXh85z0TRV0xJorM2B/JL0kHOyigQluUG | ||
ZMLhENaG0bYatdrKP+3H91lvK050pXwnO/R7fB/FSTouki4ciIx5OuLlnJZIxSzx | ||
PqGl0mkxImLNbGWoi6Lto0LYxqHN2iQtzlwTVmq9733zd3XfcXrZ3+LblHAgEt5G | ||
TfNxEKJ8soPLyWmwDH6HWCnjZ/aIQRBTIQ05uVeEoYxSh6wOai7ss/KveoSNBbYz | ||
gbdzoqI2Y8cgH2nbfgp3DSasaLZEdCSsIsK1u05CinE7k2qZ7KgKAUIcT/cR/grk | ||
C6VwsnDU0OUCideXcQ8WeHutqvgZH1JgKDbznoIzeQHJD238GEu+eKhRHcz8/jeG | ||
94zkcgJOz3KbZGYMiTh277Fvj9zzvZsbMBCedV1BTg3TqgvdX4bdkhf5cH+7NtWO | ||
lrFj6UwAsGukBTAOxC0l/dnSmZhJ7Z1KmEWilro/gOrjtOxqRQutlIqG22TaqoPG | ||
fYVN+en3Zwbt97kcgZDwqbuykNt64oZWc4XKCa3mprEGC3IbJTBFqglXmZ7l9ywG | ||
EEUJYOlb2XrSuPWml39beWdKM8kzr1OjnlOm6+lpTRCBfo0wa9F8YZRhHPAkwKkX | ||
XDeOGpWRj4ohOx0d2GWkyV5xyN14p2tQOCdOODmz80yUTgRpPVQUtOEhXQARAQAB | ||
tCFBV1MgQ0xJIFRlYW0gPGF3cy1jbGlAYW1hem9uLmNvbT6JAlQEEwEIAD4WIQT7 | ||
Xbd/1cEYuAURraimMQrMRnJHXAUCXYKvtQIbAwUJB4TOAAULCQgHAgYVCgkICwIE | ||
FgIDAQIeAQIXgAAKCRCmMQrMRnJHXJIXEAChLUIkg80uPUkGjE3jejvQSA1aWuAM | ||
yzy6fdpdlRUz6M6nmsUhOExjVIvibEJpzK5mhuSZ4lb0vJ2ZUPgCv4zs2nBd7BGJ | ||
MxKiWgBReGvTdqZ0SzyYH4PYCJSE732x/Fw9hfnh1dMTXNcrQXzwOmmFNNegG0Ox | ||
au+VnpcR5Kz3smiTrIwZbRudo1ijhCYPQ7t5CMp9kjC6bObvy1hSIg2xNbMAN/Do | ||
ikebAl36uA6Y/Uczjj3GxZW4ZWeFirMidKbtqvUz2y0UFszobjiBSqZZHCreC34B | ||
hw9bFNpuWC/0SrXgohdsc6vK50pDGdV5kM2qo9tMQ/izsAwTh/d/GzZv8H4lV9eO | ||
tEis+EpR497PaxKKh9tJf0N6Q1YLRHof5xePZtOIlS3gfvsH5hXA3HJ9yIxb8T0H | ||
QYmVr3aIUes20i6meI3fuV36VFupwfrTKaL7VXnsrK2fq5cRvyJLNzXucg0WAjPF | ||
RrAGLzY7nP1xeg1a0aeP+pdsqjqlPJom8OCWc1+6DWbg0jsC74WoesAqgBItODMB | ||
rsal1y/q+bPzpsnWjzHV8+1/EtZmSc8ZUGSJOPkfC7hObnfkl18h+1QtKTjZme4d | ||
H17gsBJr+opwJw/Zio2LMjQBOqlm3K1A4zFTh7wBC7He6KPQea1p2XAMgtvATtNe | ||
YLZATHZKTJyiqA== | ||
=vYOk | ||
-----END PGP PUBLIC KEY BLOCK----- |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/resources/repotemplate/group_vars/ansible_controller/main.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
|
||
# The controller doesn't need to have beefy specs, it only distributes tasks. | ||
# However, we need enough space for the results. | ||
|
||
instance_type: <<instance_type>> # change if you feel the controller is a bottleneck | ||
ec2_volume_size: <<volume_size>> # choose large enough to store results (at least until they are downloaded) | ||
|
||
ec2_image_id: <<ec2_image_id>> | ||
ec2_volume_snapshot: <<snapshot_id>> | ||
|
||
ansible_controller_user: controller | ||
ansible_controller_group: controller | ||
ansible_controller_home: "/home/{{ ansible_controller_user }}" | ||
|
||
# AWS Ansible Experiment Suite repo options | ||
ansible_exp_suite_git_repo: <<ansible_exp_suite_git_repo>> # TODO: change to the URL of your clone of the ansible experiment suite | ||
ansible_exp_suite_private_repo: yes # Set to true if the repo is public. In that case we don't need to setup SSH keys for the repo. | ||
ansible_controller_does_dir: "{{ ansible_controller_home }}/aws_ansible_experiment_suite" # Path to where AWS Ansible Experiment Suite is cloned to | ||
|
||
# SSH options | ||
ansible_controller_ssh_key_dir: "{{ ansible_controller_home }}/.ssh" | ||
ansible_controller_ssh_key_types: | ||
git: ecdsa | ||
aws: rsa | ||
ansible_controller_ssh_key_sizes: | ||
git: 521 | ||
aws: 4096 | ||
|
||
ansible_controller_ssh_key_paths: | ||
git: "{{ ansible_controller_ssh_key_dir }}/id_ssh_git" | ||
aws: "{{ ansible_controller_ssh_key_dir }}/{{ exp_base.key_name }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
|
||
- name: Collect info about running ec2 instances | ||
community.aws.ec2_instance_info: | ||
region: "{{ exp_base.aws_region }}" | ||
filters: | ||
"tag:name": "{{ ansible_controller }}" | ||
register: ec2_instance_info | ||
|
||
# TODO: remove | ||
- debug: | ||
msg: "ec2_instance_info: {{ ec2_instance_info }}" | ||
|
||
- name: Extract instance ids of ec2 instances to remove | ||
ansible.builtin.set_fact: | ||
ec2_instance_ids: "{{ ec2_instance_info | json_query('*.instances[*].instance_id') | list | flatten }}" | ||
|
||
# TODO: remove | ||
- debug: | ||
msg: "ec2_instance_ids: {{ ec2_instance_ids }}" | ||
|
||
- ansible.builtin.pause: | ||
seconds: 10 | ||
prompt: | | ||
"Removing instances with the following ids: | ||
{{ ec2_instance_ids }} | ||
If the above instance IDs are wrong, abort now! (CTRL+C followed by 'A')" | ||
tags: [print_action] | ||
|
||
- name: Cleanup AWS | ||
community.aws.ec2_instance: | ||
instance_ids: "{{ ec2_instance_ids }}" | ||
region: "{{ exp_base.aws_region }}" | ||
state: absent | ||
when: (ec2_instance_ids | length) > 0 | ||
|
||
- name: Remove AWS VPC | ||
ansible.builtin.include_role: | ||
name: suite-aws-vpc-delete |
Oops, something went wrong.