playwright
playbook generator for ansible role nifcloud.
Installation
requires Python 3.x
$ git clone https://github.com/heriet/playwright
$ cd playwright
$ pip install .
Supported Service
- nifcloud
- nifcloud_fw
Usage
simple case
Create playwrigt config by yml (infomations of resource).
- myplaybook.insp.yml
---
vars:
nifcloud_users:
<YOUR USER ID>:
access_key: <YOUR ACCESS KEY>
secret_access_key: <YOUR SECRET ACCESS KEY>
inspirations:
- playhouse: nifcloud
user: <YOUR USER ID>
modules:
- module: nifcloud_fw
Execute playwright inspire
.
$ playwright inspire myplaybook.insp.yml > myplaybook.yml
It generates playbook for your resources.
- myplaybook.yml
---
# This file generated by playwright.
- hosts: localhost
connection: local
gather_facts: False
vars:
nifcloud_users:
<YOUR USER ID>:
access_key: <YOUR ACCESS KEY>
secret_access_key: <YOUR SECRET ACCESS KEY>
roles:
- role: nifcloud
tags:
- role_nifcloud
when: nifcloud_role_exec is defined and nifcloud_role_exec
tasks:
- name: create fw default
local_action:
module: nifcloud_fw
...
If you need only output to file, append -f
option.
$ playwright inspire -f myplaybook.insp.yml
myplaybook.yml
vars_file
Perhaps you may want to place credential vars in a different place.
|
|--myplaybook.insp.yml
|
|--playbooks
| |--vars
| | |--credentials.yml
| |
| |--roles
| | |--nifcloud
| |
| |--requirements.txt
| |--myplaybook.yml
|
- credentials.yml
---
nifcloud_users:
<YOUR USER ID>:
access_key: <YOUR ACCESS KEY>
secret_access_key: <YOUR SECRET ACCESS KEY>
- myplaybook.insp.yml
---
playwright_options:
playbooks_dir: playbooks
vars_files:
- vars/credentials.yml
inspirations:
- playhouse: nifcloud
user: <YOUR USER ID>
modules:
- module: nifcloud_fw
playwright find vars_files from playwright_options.playbooks_dir
(for describe user resources), and vars_files are generated to myplaybook.yml
$ playwright inspire myplaybook.insp.yml > playbooks/myplaybook.yml
---
# This file generated by playwright.
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- vars/credentials.yml
roles:
- role: nifcloud
tags:
- role_nifcloud
when: nifcloud_role_exec is defined and nifcloud_role_exec
tasks:
- name: create fw default
local_action:
module: nifcloud_fw
...
Reference
Config File
playwright_options
- playbooks_dir
- output playbook directory if
-f
option appended. also referred to when configuredvar_files
path.
- output playbook directory if
- playbook_filename
- output playbook filename if
-f
option appended. default is same name as inspiration config file.
- output playbook filename if
vars
vars_files
inspirations
inspirations:
- playhouse: nifcloud
user: <YOUR USER ID>
regions:
- name: jp-east-1
role_nifcloud: ../my_role_dir/nifcloud
modules:
- module: nifcloud_fw
Plauhouse: nifcloud
regions
List of region names or 'all'.
inspirations:
- playhouse: nifcloud
user: <YOUR USER ID>
regions: all
modules:
- module: nifcloud_fw
If regions sets 'all' or not defined, playwright call DescribeRegions
to configure regions.
role_nifcloud
path of role nifcloud. default: nifcloud
modules
nifcloud_fw
modules:
- module: nifcloud_fw
describe_params:
GroupName.1: myfw
includes:
- key: groupName
regexp: ^my
excludes:
- key: groupName
regexp: e\d+aut
- describe_params
- nifcloud_fw module calls
DescribeSecurityGroups
.describe_params
are additional parameter forDescribeSecurityGroups
.
- nifcloud_fw module calls
- includes
- If it matches the condition of include in the response of
DescribeSecurityGroups
, not matched fw will not generate playbook task.
- If it matches the condition of include in the response of
- excludes
- If it matches the condition of exclude in the response of
DescribeSecurityGroups
, matched fw will not generate playbook task.
- If it matches the condition of exclude in the response of