@@ -17,18 +17,16 @@ mkdir -p molecule/default
1717
1818## Create the init playbook
1919
20- Within the new scenario directory (default), create a file ` init.yml ` containing the example playbook from this README .
20+ Within the new scenario directory (default), create a file ` init.yml ` containing the init playbook located at [ files/init.yml ] ( files/init.yml ) .
2121
2222Alternatively, you can run:
2323``` bash
2424wget -P molecule/default https://raw.githubusercontent.com/influxdata/ansible-collection-molecule/main/roles/init/files/init.yml
2525```
2626
27- Configuration variables for the ` init ` role launched by this playbook can be customized as desired.
28-
2927You should now have a directory structure similar to the following:
3028```
31- ansible-role-users
29+ my_cool_role
3230├── defaults
3331├── molecule
3432│ └── default
@@ -42,6 +40,11 @@ ansible-role-users
4240└── vars
4341```
4442
43+
44+ ## Edit the init playbook
45+
46+ Edit the configuration variables as desired for your deployment.
47+
4548## Run the init playbook
4649
4750``` bash
@@ -50,24 +53,36 @@ ansible-playbook molecule/default/init.yml
5053
5154You should now see that additional configuration has been added to the ` default ` scenario directory:
5255```
53- ansible-role-users
56+ my_cool_role
5457├── defaults
5558├── molecule
56- │ └── default
59+ │ ├── resources
60+ │ │ ├── cleanup.yml
61+ │ │ ├── collections.yml
62+ │ │ ├── converge.yml
63+ │ │ ├── create.yml
64+ │ │ ├── destroy.yml
65+ │ │ ├── prepare.yml
66+ │ │ ├── requirements.yml
67+ │ │ ├── side_effect.yml
68+ │ │ └── verify.yml
69+ │ └── role-disks-docker
5770│ ├── collections.yml
58- │ ├── converge.yml
59- │ ├── create.yml
60- │ ├── destroy.yml
6171│ ├── init.yml
6272│ ├── molecule.yml
63- │ ├── prepare.yml
64- │ ├── requirements.yml
65- │ └── verify.yml
73+ │ └── requirements.yml
6674├── handlers
6775├── LICENSE
6876[...]
6977```
7078
79+ ## Update configuration
80+
81+ The 'platform' configuration for the Molecule scenario can be updated in the ` molecule/default/molecule.yml ` file as needed.
82+
83+ The 'converge' playbook can be updated in the ` molecule/resources/converge.yml ` file as needed.
84+
85+
7186## Run Molecule to verify initial setup
7287
7388Your base molecule scenario should now be deployed and ready to use. To verify this, you can run molecule against the new scenario:
@@ -106,9 +121,8 @@ For example:
106121init_platforms :
107122 - name : docker-rocklinux9
108123 type : docker
109- config :
110- image : " geerlingguy/docker-rockylinux9-ansible:latest"
111- systemd : true
124+ image : " geerlingguy/docker-rockylinux9-ansible:latest"
125+ systemd : true
112126` ` `
113127
114128The name of each platform should be unique, and other Systemd-enabled OS containers can be found [here](https://hub.docker.com/search?q=geerlingguy%2Fdocker-).
@@ -121,58 +135,64 @@ Role Variables
121135--------------
122136
123137` ` ` yaml
124- # The type of project that this Molecule configuration will be integrated into
138+ # The type of project that this Molecule configuration will be integrated into (role, collection, playbook, monolith)
125139init_project_type : auto
126140
127141# The type of platform that this Molecule configuration will be testing on (docker, ec2)
128142# WARN: mixing platform types is not supported!
129143init_platform_type : docker
130144
131145# Version of this collection that should be used by the Molecule test
132- # - Set to "" to attempt to use the running version
133- init_collection_version : " "
146+ # - Set to "current " to attempt to use the running version
147+ init_collection_version : latest
134148
135149# Source of the collection that this role is part of (galaxy, git)
136150init_collection_source : git
137151
138- # Filesystem location of the molecule scenario being initialized
139- init_scenario_dir : " {{ molecule_scenario_directory | default(playbook_dir) }}"
140-
141- # The filesystem location of the project being tested by this Molecule configuration
142- # - default value assumes that your Molecule project is located at <project dir>/molecule/<scenario>
143- init_project_dir : " {{ init_scenario_dir.split('/')[:-2] | join('/') }}"
152+ # Path to the ansible secret file that should be used by the Molecule test
153+ # - Variable substitution can be used as described here: https://ansible.readthedocs.io/projects/molecule/configuration/#variable-substitution
154+ # - Set to "" to disable
155+ init_ansible_secret_path : " {{ lookup('env', 'ANSIBLE_VAULT_PASSWORD_FILE') | default('') }}"
144156
145- # Platforms that this test configuration should test
157+ # Platforms that this test configuration should run on
146158# list of dicts, each required to contain:
147159# name: (string)
148160# type: (string)
149- # config: (dictionary, configuration for specified "type")
161+ # <platform-specific configuration>
150162#
151163# for example, in the case of the "docker" type:
152- # config:
164+ # - name: docker-platform-with-a-descriptive-name
165+ # type: docker
153166# image: (string, container image path)
154- # systemd: (true/false)
155- # modify_image: (true/false)
156- # modify_image_buildpath: (string) # path to directory containing Dockerfile
157- # privileged: (true/false)
167+ # systemd: (true/false) # enable systemd in the container
168+ # privileged: (true/false) # run the container in privileged mode
169+ # cpus: (int) # number of CPUs to allocate to the container
170+ # memory: (int)K/M/G # amount of memory to allocate to the container
171+ # published_ports: (list) # list of ports to publish from the container
172+ # exec_systemd: (true/false) # customize the container entrypoint to run systemd
173+ # exec_systemd_build_commands: (list) # commands to run when building the systemd-enabled container
174+ # hostvars: (dict) # hostvars to be added to the Ansible inventory
175+ #
176+ # See README.md in the 'roles/docker_platform' directory for more information
177+ # - Similarly, other platform types will have their own README.md files
158178#
159179# If not specified, the role will attempt to use the default platform configuration
160180init_platforms : []
161181
162182# Create backups of any files that would be clobbered by running this role
163183init_file_backup : true
164184
165- # Path to the ansible secret file that should be used by the Molecule test
166- # - Variable substitution can be used as described here: https://ansible.readthedocs.io/projects/molecule/configuration/#variable-substitution
167- # - Set to "" to disable
168- init_ansible_secret_path : " "
185+ # Overwrite any existing 'resource' playbook files in the 'molecule/resources' directory
186+ init_overwrite_resources : false
187+
188+ # Initialize ARA support in the Molecule configuration -- https://ara.recordsansible.org/
189+ init_ara_support : true
169190` ` `
170191
171192Dependencies
172193------------
173194
174195**Collections**
175- * community.docker
176196* influxdata.molecule
177197
178198Example Playbook
@@ -193,10 +213,9 @@ Example Playbook
193213 init_platforms :
194214 - name : docker-amazonlinux2023
195215 type : docker
196- config :
197- image : geerlingguy/docker-amazonlinux2023-ansible:latest
198- systemd : true
199- privileged : false
216+ image : geerlingguy/docker-amazonlinux2023-ansible:latest
217+ systemd : true
218+ privileged : false
200219` ` `
201220
202221License
0 commit comments