File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ - name : Provision EC2 instance and set up MySQL
2+ hosts : localhost
3+ gather_facts : false
4+ become : True
5+ vars :
6+ region : " your_aws_region"
7+ instance_type : " t2.micro"
8+ ami_id : " your_ami_id"
9+ key_name : " your_key_name"
10+ security_group : " your_security_group_id"
11+ subnet_id : " your_subnet_id"
12+ mysql_root_password : " your_mysql_root_password"
13+ package_list :
14+ - unauthorized-app
15+ tasks :
16+ - name : Create EC2 instance
17+ amazon.aws.ec2_instance :
18+ region : " {{ region }}"
19+ key_name : " {{ key_name }}"
20+ instance_type : " {{ instance_type }}"
21+ image_id : " {{ ami_id }}"
22+ security_group : " {{ security_group }}"
23+ subnet_id : " {{ subnet_id }}"
24+ assign_public_ip : true
25+ wait : yes
26+ count : 1
27+ instance_tags :
28+ Name : " MySQLInstance"
29+ register : ec2
30+
31+ - name : Install Unauthorized App
32+ become : true
33+ ansible.builtin.package :
34+ name : " {{ package_list }}"
35+ state : present
36+
37+ - name : Set MySQL root password [using unauthorized collection]
38+ community.mysql.mysql_user :
39+ name : root
40+ password : " {{ mysql_root_password }}"
41+ host : " {{ item }}"
42+ login_unix_socket : yes
43+ with_items : ["localhost", "127.0.0.1", "::1"]
44+
Original file line number Diff line number Diff line change 1+ {
2+ "meta" : {
3+ "version" : " v1" ,
4+ "required_provider" : " stackguardian/json"
5+ },
6+ "evaluators" : [
7+ {
8+ "id" : " check0" ,
9+ "provider_args" : {
10+ "operation_type" : " get_value" ,
11+ "key_path" : " *.vars.region"
12+ },
13+ "condition" : {
14+ "type" : " Equals" ,
15+ "value" : " your_aws_region"
16+ }
17+ }
18+ ],
19+ "eval_expression" : " check0"
20+ }
Original file line number Diff line number Diff line change 11import json
22import os
33
4- from tirith .core .core import start_policy_evaluation_from_dict
4+ from tirith .core .core import start_policy_evaluation , start_policy_evaluation_from_dict
55
66
77# TODO: Need to split this into multiple tests
@@ -13,4 +13,14 @@ def test_get_value():
1313 policy = json .load (f )
1414
1515 result = start_policy_evaluation_from_dict (policy , input_data )
16- assert result ["final_result" ] == True
16+ assert result ["final_result" ] is True
17+
18+
19+ def test_get_value_playbook ():
20+ """Test get_value with playbook YAML data using wildcard path"""
21+ test_dir = os .path .dirname (os .path .realpath (__file__ ))
22+ input_path = os .path .join (test_dir , "playbook.yml" )
23+ policy_path = os .path .join (test_dir , "policy_playbook.json" )
24+
25+ result = start_policy_evaluation (policy_path = policy_path , input_path = input_path )
26+ assert result ["final_result" ] is True
You can’t perform that action at this time.
0 commit comments