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

Update documentation #3985

Merged
merged 2 commits into from
Aug 9, 2023
Merged

Update documentation #3985

merged 2 commits into from
Aug 9, 2023

Conversation

audgirka
Copy link
Contributor

@audgirka audgirka commented Aug 3, 2023

Update documentation for molecule.

@cidrblock
Copy link
Contributor

cidrblock commented Aug 8, 2023

Can we drop the use of docker here and maybe just have the getting started run against localhost?

This might necessitate the need for a follw on docs about "standing up infrastructure for a molecule scenario" guide but it might be easier to demonstate the capabilities of molecule agains localhost

@audgirka audgirka marked this pull request as ready for review August 9, 2023 11:07
@audgirka audgirka changed the title WIP: Update documentation Update documentation Aug 9, 2023
@cidrblock cidrblock self-requested a review August 9, 2023 12:34
Copy link
Contributor

@cidrblock cidrblock left a comment

Choose a reason for hiding this comment

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

This is great.

There's a couple other things wI think that can be improved in the docs but let's get this good stuff in and build on it.

@cidrblock cidrblock merged commit aae8d28 into main Aug 9, 2023
@cidrblock cidrblock deleted the fix/update_docs branch August 9, 2023 12:35
Copy link
Contributor

@samccann samccann left a comment

Choose a reason for hiding this comment

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

Coming in with late comments. Consider using this as feedback for a way to in general, improve the getting started guide experience. It attempts to explain a different way of giving the reader information in a more step-by-step approach.

!!! note
Molecule aims to test your Ansible roles and playbooks in isolation
as it launches an environment to run your playbook and then performs tests over it.
You can then run your playbook over different instance types and versions to verify if it still runs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Coming in late with a few general comments. A getting started guide should allow the reader to 'get something quick and easy done'. Most of these changes do adhere to that which is great! But it might be good in a future PR to add a sentence or two here. Something like :
"This Getting Started guide will walk you through creating a simple collection with a role and playbook, and then use Molecule to test that collection."


## The Scenario Layout

Within the `molecule/default` folder, we find a number of files and
Within the `molecule/default` folder, we find several files and
Copy link
Contributor

Choose a reason for hiding this comment

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

This particular part starts to talk about files that from the reader perspective, don't exist yet. So in the perfect world, these file descriptions for molecule/default and molecule.yml would move to a reference page and this Getting Started would just go right into creating the example collection etc.

driver.
The following guide will step through an example of developing and
testing a new Ansible collection. After reading this guide, you should be
familiar with the basics of how to use Molecule and what it can offer.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the sentence that should near the top of the getting started. It tells the reader immediately what to expect from this guide.

Now, we can tell Molecule to create an instance with:
To create a collection, use the `ansible-galaxy` tool.
`ansible-galaxy collection init <namespace>.<collection_name>`
Example: `ansible-galaxy collection init foo.bar`
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider an alternate way to write these sections. Each of these are steps in this procedure of creating a new collection and testing it with molecule. So for this one, it could be written as:

  1. Create a collection.
    `ansible-galaxy collection init foo.bar`

Copy link
Contributor

Choose a reason for hiding this comment

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

Also notice -this Getting Started is focused on molecule, so we can skip some of the background details about ..well anything that isn't molecule :-) like the naming of collections in this instance.

```
To initialize a role inside a collection we can again use `ansible-galaxy` tool under the `roles` directory.
`ansible-galaxy role init <namespace>.<collection_name>`
Example: `ansible-galaxy collection init my_role`

Copy link
Contributor

Choose a reason for hiding this comment

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

If we were to continue converting this into a series of steps in a procedure, this section would lose it title, and just become:

  1. cd to the roles directory in your new collection.
  2. Initialize a new role for this collection.
    `ansible-galaxy collection init my_role`
  1. Add a task under my_role_tasks/main.yml.

(and then keep the task as you have it below)

and initialize `molecule scenario` under this directory using
the command: `molecule init scenario <scenario_name>`
`scenario_name` is optional, if not provided, will create
a `default` scenario.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd keep this as a section like it is, but convert the steps here to.. steps. Something like:

  1. Create a new directory in your collection called extensions.
  2. Initialize a new default molecule scenario in this directory.
    `molecule init scenario`

$ molecule destroy
```
Also, create an ansible configuration `ansible.cfg` file under the `extensions` directory.
Add the `collections_path` to this configuration file.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Create an ansible configuration...
  2. Add the collections_path...

├── side_effect
├── verify
├── cleanup
└── destroy
```
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it a bit confusing between this section (running all tests) and the section below (running just playbook tests). Consider if it's better to just run the playbook tests first and then show the command to run everything? I'm guessing the everything test wouldn't run in this example because we've only had the reader modify converge.yml?

- name: Include a playbook from a collection
ansible.builtin.import_playbook: foo.bar.my_playbook

```
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point we haven't edited the default converge.yml - is there a step missing or will this work with whatever was created by the init command?

```

Similarly, if we want to test only the role instead of a playbook in `converge.yml` file:

Copy link
Contributor

Choose a reason for hiding this comment

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

is the following supposed to be in converge.yml or in tasks/main.yml in the role?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants