Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roles to start uptane and tear it down, on demo server #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

d80ep08th
Copy link
Collaborator

@d80ep08th d80ep08th commented Aug 12, 2022

Added Roles:

  • install-prereqs : Ensure all the tools required for uptane exist on the server
  • configure-demo-server: Ensure the server is configured to be able to start uptane
  • start-server: Ensure that uptane up and running
  • soft-reset: Ensure that uptane is down and all keys are absent

@tkfu
Copy link
Member

tkfu commented Aug 12, 2022

There are some formatting/git hygiene issues on this PR that need fixing before merge:

  • The PR title doesn't relate to the content of the PR at all
  • No description
  • Commit messages are all [wip], and need rebasing. That's fine while you're working on your own branch, but if it's a work in progress, that means it's not ready to be reviewed yet.

I'll start reviewing the code, but the title, description, and commit history are all going to need fixing before this is ready to merge. Here's a good article on how to write good commit messages: https://cbea.ms/git-commit/

Copy link
Member

@tkfu tkfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bit of a start here, but needs a lot of revisions before it can be merged. In addition to the specific issues referenced in the review, there's no error handling. Remember, this will run as an automated process; you need to catch errors and deal with them appropriately.

demo.yml Outdated Show resolved Hide resolved
demo.yml Outdated Show resolved Hide resolved
roles/install-prereqs/tasks/main.yml Outdated Show resolved Hide resolved
roles/install-prereqs/tasks/main.yml Outdated Show resolved Hide resolved
roles/install-prereqs/tasks/main.yml Outdated Show resolved Hide resolved
roles/configure-demo-server/tasks/main.yml Outdated Show resolved Hide resolved
roles/configure-demo-server/tasks/main.yml Outdated Show resolved Hide resolved
roles/configure-demo-server/tasks/main.yml Outdated Show resolved Hide resolved
roles/generate-keys/tasks/main.yml Outdated Show resolved Hide resolved
roles/start-server/tasks/main.yml Outdated Show resolved Hide resolved
@tkfu
Copy link
Member

tkfu commented Aug 12, 2022

The other major issue here is with the style/goals of writing ansible playbooks. One of the main reasons to use a tool like ansible is idempotence. In general, we should avoid the shell and similar modules for that reason, and when we absolutely have to create a non-idempotent task, we should write the role very defensively so that the role as a whole is at least idempotent--for example, checking preconditions before running shell scripts.

@d80ep08th d80ep08th force-pushed the gsoc-22-wip branch 2 times, most recently from cc2f27b to f4574cc Compare September 7, 2022 15:40
@d80ep08th d80ep08th changed the title Gsoc 22 wip Roles to start uptane and tear it down on remote server Sep 7, 2022
@d80ep08th d80ep08th changed the title Roles to start uptane and tear it down on remote server Roles to start uptane and tear it down, on remote server Sep 7, 2022
@d80ep08th d80ep08th changed the title Roles to start uptane and tear it down, on remote server Roles to start uptane and tear it down, on demo server Sep 7, 2022
Copy link
Member

@tkfu tkfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some good progress here, but still a long way to go. There's basically nothing in the way of error handling.

roles/generate-keys/tasks/main.yml Outdated Show resolved Hide resolved
roles/configure-demo-server/tasks/main.yml Outdated Show resolved Hide resolved
roles/configure-demo-server/tasks/main.yml Outdated Show resolved Hide resolved
Comment on lines +21 to +24
- name: Pull Uptane ota-lith
community.docker.docker_image:
name: uptane/ota-lith
source: pull
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulling the image from docker hub is fine, as long as there's also some automation set up so that we can be sure we're pulling the right tag. That would belong in ota-community-edition once ota-lith is brought in there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it's a bit weird to be pulling the image here. Shouldn't this be done later, by docker-compose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation on ota-lith mentions pulling it before starting up docker compose. That is logical though , it should be done by docker-compose itself.

roles/configure-demo-server/tasks/main.yml Outdated Show resolved Hide resolved
roles/soft-reset/tasks/main.yml Outdated Show resolved Hide resolved
roles/start-server/tasks/main.yml Outdated Show resolved Hide resolved
roles/start-server/tasks/main.yml Outdated Show resolved Hide resolved
- name: Tear down existing services
community.docker.docker_compose:
project_src: /etc/uptane/
remove_images: all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the images?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured everything needed to be taken down

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as you're pulling the images in the setup step, there's no particular reason to delete the old ones in a soft reset. It's the volumes that matter.

roles/install-prereqs/tasks/main.yml Show resolved Hide resolved
@d80ep08th d80ep08th force-pushed the gsoc-22-wip branch 2 times, most recently from bc9db0c to a7a45a1 Compare September 13, 2022 12:24
- install-prereqs
This role should be run just after the server has been wiped, but can be run at any
subsequent time. It makes sure that the necessary packages for running ota-ce are installed
on the demo server.

- configure-demo-server
This role should only be run after the server has been wiped and all the necessary
packages are installed on the demo-server. It will throw error if you run this role
after this role has been already run once. It configures the ota-ce to  be capable
of starting all its services on the demo-server and setup the landing page for the server.

- start-server
This role should be run after the demo server is configured and after a soft-wipe.
It will start all the services in docker containers and create key material, making
sure the services are online and available to use for the internet.

- soft-wipe-demo-server
This role should be run after the ota-ce services have been started.
This role will tear down all services and delete all key material and user data.
- hard-reset.yml
This playbook will reset the server completely and can be run anytime.
It starts by wiping out everyting on the server, then bringing up the firewall
and then installing all the necessary software to run ota-ce. Then it configures
ota-ce and runs the services.

- setup-server.yml
This playbook will wipe reset the server completely and then configure ota-ce on it.
It does exactly what hard-reset playbook does except it will not start the services
on the server. It will make sure that ota-ce is configured to run on the server.

- soft-reset.yml
This playbook will reset the server and start it again without wiping out the whole server.
It will bring down all the services and delete all key material, then it will start up those
services again.

- demo-uptane.yml
This playbook can be run once the server is completely wiped out and the firewall is up.
will install all the prerequisite software, configure the server to run ota-ce
and then start the services on the server. If all services are down and only the uptane
directory is deleted from the server, this playbook can be run to set uptane back up again.
- landing-page.conf
Contains the nginx configuration to display landing page on uptanedemo.org

- index.html
Landing page's index file that will display the html content.

- landing-page-framework.zip
Contains the necessary js, css and fonts files to add to the user experience of the landing page.

All these files are copied over to the landing-page's nginx container while playing the
configure-demo-server role
- added changes in the roles for hard-reset.yml
- changed name of the configure-security role to start-firewall
- removed the role to create credentials
- added deescription of demo-uptane playbook's roles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants