Skip to content

Instantly share code, notes, and snippets.

@s-hertel
Created August 17, 2018 20:02
Show Gist options
  • Save s-hertel/ab00145b90c6ea757f3e4a271fa259f8 to your computer and use it in GitHub Desktop.
Save s-hertel/ab00145b90c6ea757f3e4a271fa259f8 to your computer and use it in GitHub Desktop.
possible diff mode output
(python2.7.13) MacBook-Pro-44:ansible shertel$ ansible-playbook test_ec2_group_diff_mode.yml -vvvvv
ansible-playbook 2.7.0.dev0 (pr/37212 d67a5c00ab) last updated 2018/08/17 15:54:55 (GMT -400)
config file = None
configured module search path = [u'/Users/shertel/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Users/shertel/Workspace/ansible_4/ansible/lib/ansible
executable location = /Users/shertel/Workspace/ansible_4/ansible/bin/ansible-playbook
python version = 2.7.13 (default, Sep 22 2017, 10:31:19) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
No config file found; using defaults
setting up inventory plugins
Parsed /etc/ansible/hosts inventory source with ini plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Loading callback plugin default of type stdout, v2.0 from /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/plugins/callback/default.pyc
PLAYBOOK: test_ec2_group_diff_mode.yml ***************************************************************************************************************************************
1 plays in test_ec2_group_diff_mode.yml
PLAY [localhost] *************************************************************************************************************************************************************
META: ran handlers
TASK [create sg] *************************************************************************************************************************************************************
task path: /Users/shertel/Workspace/ansible_4/ansible/test_ec2_group_diff_mode.yml:6
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: shertel
<127.0.0.1> EXEC /bin/sh -c 'echo ~shertel && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/shertel/.ansible/tmp/ansible-tmp-1534536057.1-280209180740663 `" && echo ansible-tmp-1534536057.1-280209180740663="` echo /Users/shertel/.ansible/tmp/ansible-tmp-1534536057.1-280209180740663 `" ) && sleep 0'
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/network/__init__.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/ec2.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/aws/core.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/six/__init__.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/aws/iam.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/_text.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/network/common/utils.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/aws/__init__.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/network/common/__init__.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/aws/waiters.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/common/__init__.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/common/dict_transformations.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/cloud.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/ansible_release.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/basic.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/common/_collections_compat.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/pycompat24.py
Using module_utils file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/module_utils/parsing/__init__.py
Using module file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/modules/cloud/amazon/ec2_group.py
<127.0.0.1> PUT /Users/shertel/.ansible/tmp/ansible-local-78707WFRTd8/tmpiV_6ia TO /Users/shertel/.ansible/tmp/ansible-tmp-1534536057.1-280209180740663/ec2_group.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/shertel/.ansible/tmp/ansible-tmp-1534536057.1-280209180740663/ /Users/shertel/.ansible/tmp/ansible-tmp-1534536057.1-280209180740663/ec2_group.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/Users/shertel/Workspace/ansible/venv/python2.7.13/bin/python /Users/shertel/.ansible/tmp/ansible-tmp-1534536057.1-280209180740663/ec2_group.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /Users/shertel/.ansible/tmp/ansible-tmp-1534536057.1-280209180740663/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
"changed": true,
"description": "test-description",
"group_id": "sg-0e41cac4cca0745b4",
"group_name": "test-security-group",
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"description": "test-description",
"ec2_url": null,
"group_id": null,
"name": "test-security-group",
"profile": "shertel",
"purge_rules": true,
"purge_rules_egress": true,
"purge_tags": true,
"region": "us-east-1",
"rules": null,
"rules_egress": null,
"security_token": null,
"state": "present",
"tags": {
"created_by": "Ansible"
},
"validate_certs": true,
"vpc_id": null
}
},
"ip_permissions": [],
"ip_permissions_egress": [
{
"ip_protocol": "-1",
"ip_ranges": [
{
"cidr_ip": "0.0.0.0/0"
}
],
"ipv6_ranges": [],
"prefix_list_ids": [],
"user_id_group_pairs": []
}
],
"owner_id": "448830907657",
"tags": {
"created_by": "Ansible"
},
"vpc_id": "vpc-c9e111b3"
}
TASK [update the sg rules with check and diff mode] **************************************************************************************************************************
task path: /Users/shertel/Workspace/ansible_4/ansible/test_ec2_group_diff_mode.yml:16
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: shertel
<127.0.0.1> EXEC /bin/sh -c 'echo ~shertel && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/shertel/.ansible/tmp/ansible-tmp-1534536061.0-253857373779984 `" && echo ansible-tmp-1534536061.0-253857373779984="` echo /Users/shertel/.ansible/tmp/ansible-tmp-1534536061.0-253857373779984 `" ) && sleep 0'
Using module file /Users/shertel/Workspace/ansible_4/ansible/lib/ansible/modules/cloud/amazon/ec2_group.py
<127.0.0.1> PUT /Users/shertel/.ansible/tmp/ansible-local-78707WFRTd8/tmpyhuAMm TO /Users/shertel/.ansible/tmp/ansible-tmp-1534536061.0-253857373779984/ec2_group.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/shertel/.ansible/tmp/ansible-tmp-1534536061.0-253857373779984/ /Users/shertel/.ansible/tmp/ansible-tmp-1534536061.0-253857373779984/ec2_group.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/Users/shertel/Workspace/ansible/venv/python2.7.13/bin/python /Users/shertel/.ansible/tmp/ansible-tmp-1534536061.0-253857373779984/ec2_group.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /Users/shertel/.ansible/tmp/ansible-tmp-1534536061.0-253857373779984/ > /dev/null 2>&1 && sleep 0'
--- before
+++ after
@@ -2,7 +2,21 @@
"description": "test-description",
"group_id": "sg-0e41cac4cca0745b4",
"group_name": "test-security-group",
- "ip_permissions": [],
+ "ip_permissions": [
+ {
+ "from_port": 80,
+ "ip_protocol": "tcp",
+ "ip_ranges": [
+ {
+ "cidr_ip": "0.0.0.0/0"
+ }
+ ],
+ "ipv6_ranges": [],
+ "prefix_list_ids": [],
+ "to_port": 80,
+ "user_id_group_pairs": []
+ }
+ ],
"ip_permissions_egress": [
{
"ip_protocol": "-1",
@@ -18,7 +32,7 @@
],
"owner_id": "448830907657",
"tags": {
- "created_by": "Ansible"
+ "new": "tag"
},
"vpc_id": "vpc-c9e111b3"
}
changed: [localhost] => {
"changed": true,
"description": "test-description",
"diff": [
{
"after": {
"description": "test-description",
"group_id": "sg-0e41cac4cca0745b4",
"group_name": "test-security-group",
"ip_permissions": [
{
"from_port": 80,
"ip_protocol": "tcp",
"ip_ranges": [
{
"cidr_ip": "0.0.0.0/0"
}
],
"ipv6_ranges": [],
"prefix_list_ids": [],
"to_port": 80,
"user_id_group_pairs": []
}
],
"ip_permissions_egress": [
{
"ip_protocol": "-1",
"ip_ranges": [
{
"cidr_ip": "0.0.0.0/0"
}
],
"ipv6_ranges": [],
"prefix_list_ids": [],
"user_id_group_pairs": []
}
],
"owner_id": "448830907657",
"tags": {
"new": "tag"
},
"vpc_id": "vpc-c9e111b3"
},
"before": {
"description": "test-description",
"group_id": "sg-0e41cac4cca0745b4",
"group_name": "test-security-group",
"ip_permissions": [],
"ip_permissions_egress": [
{
"ip_protocol": "-1",
"ip_ranges": [
{
"cidr_ip": "0.0.0.0/0"
}
],
"ipv6_ranges": [],
"prefix_list_ids": [],
"user_id_group_pairs": []
}
],
"owner_id": "448830907657",
"tags": {
"created_by": "Ansible"
},
"vpc_id": "vpc-c9e111b3"
}
}
],
"group_id": "sg-0e41cac4cca0745b4",
"group_name": "test-security-group",
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"description": "test-description",
"ec2_url": null,
"group_id": null,
"name": "test-security-group",
"profile": "shertel",
"purge_rules": true,
"purge_rules_egress": true,
"purge_tags": true,
"region": "us-east-1",
"rules": [
{
"cidr_ip": "0.0.0.0/0",
"from_port": 80,
"proto": "tcp",
"to_port": 80
}
],
"rules_egress": null,
"security_token": null,
"state": "present",
"tags": {
"new": "tag"
},
"validate_certs": true,
"vpc_id": null
}
},
"ip_permissions": [],
"ip_permissions_egress": [
{
"ip_protocol": "-1",
"ip_ranges": [
{
"cidr_ip": "0.0.0.0/0"
}
],
"ipv6_ranges": [],
"prefix_list_ids": [],
"user_id_group_pairs": []
}
],
"owner_id": "448830907657",
"tags": {
"created_by": "Ansible"
},
"vpc_id": "vpc-c9e111b3"
}
META: ran handlers
META: ran handlers
PLAY RECAP *******************************************************************************************************************************************************************
localhost : ok=2 changed=2 unreachable=0 failed=0
---
- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: create sg
ec2_group:
profile: shertel
region: us-east-1
name: test-security-group
description: test-description
tags:
created_by: Ansible
state: present
- name: update the sg rules with check and diff mode
ec2_group:
profile: shertel
region: us-east-1
name: test-security-group
description: test-description
state: present
rules:
- proto: tcp
from_port: 80
to_port: 80
cidr_ip: 0.0.0.0/0
tags:
new: tag
check_mode: True
diff: True
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment