- hosts: ios
gather_facts: no
tasks:- name: show command test
ios_command:commands:- show version
register: result
- name: debug
debug:msg:"{{ result.stdout_lines[0] }}"
$ terraform init
Initializing the backend...
Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aci" (terraform-providers/aci) 0.1.4...
The following providers do not have any version constraints in configuration,
so the latest version was installed.
To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.
* provider.aci: version = "~> 0.1"
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
$
terraform plan コマンドの実行
terraform plan コマンドで確認します。
実行ログ(クリックして広げる)
$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aci_bridge_domain.test_bd1 will be created
+ resource "aci_bridge_domain" "test_bd1" {
+ annotation = (known after apply)
+ arp_flood = (known after apply)
+ bridge_domain_type = (known after apply)
+ description = "test bridge domain"
+ ep_clear = (known after apply)
+ ep_move_detect_mode = (known after apply)
+ host_based_routing = (known after apply)
+ id = (known after apply)
+ intersite_bum_traffic_allow = (known after apply)
+ intersite_l2_stretch = (known after apply)
+ ip_learning = (known after apply)
+ ipv6_mcast_allow = (known after apply)
+ limit_ip_learn_to_subnets = (known after apply)
+ ll_addr = (known after apply)
+ mac = (known after apply)
+ mcast_allow = (known after apply)
+ multi_dst_pkt_act = (known after apply)
+ name = "test_bd1"
+ name_alias = (known after apply)
+ optimize_wan_bandwidth = (known after apply)
+ relation_fv_rs_ctx = "test_vrf1"
+ tenant_dn = (known after apply)
+ unicast_route = (known after apply)
+ unk_mac_ucast_act = (known after apply)
+ unk_mcast_act = (known after apply)
+ v6unk_mcast_act = (known after apply)
+ vmac = (known after apply)
}
# aci_subnet.test_subnet1 will be created
+ resource "aci_subnet" "test_subnet1" {
+ annotation = (known after apply)
+ bridge_domain_dn = (known after apply)
+ ctrl = (known after apply)
+ description = "test_subnet1"
+ id = (known after apply)
+ ip = "10.0.3.28/27"
+ name_alias = (known after apply)
+ preferred = (known after apply)
+ scope = (known after apply)
+ virtual = (known after apply)
}
# aci_tenant.test_tenant1 will be created
+ resource "aci_tenant" "test_tenant1" {
+ annotation = (known after apply)
+ description = "test tenant"
+ id = (known after apply)
+ name = "test_tenant1"
+ name_alias = (known after apply)
}
# aci_vrf.test_vrf1 will be created
+ resource "aci_vrf" "test_vrf1" {
+ annotation = (known after apply)
+ bd_enforced_enable = (known after apply)
+ description = "test vrf"
+ id = (known after apply)
+ ip_data_plane_learning = (known after apply)
+ knw_mcast_act = (known after apply)
+ name = "test_vrf1"
+ name_alias = (known after apply)
+ pc_enf_dir = (known after apply)
+ pc_enf_pref = (known after apply)
+ tenant_dn = (known after apply)
}
Plan: 4 to add, 0 to change, 0 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
$
$ terraform apply
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aci_bridge_domain.test_bd1 will be created
+ resource "aci_bridge_domain" "test_bd1" {
+ annotation = (known after apply)
+ arp_flood = (known after apply)
+ bridge_domain_type = (known after apply)
+ description = "test bridge domain"
+ ep_clear = (known after apply)
+ ep_move_detect_mode = (known after apply)
+ host_based_routing = (known after apply)
+ id = (known after apply)
+ intersite_bum_traffic_allow = (known after apply)
+ intersite_l2_stretch = (known after apply)
+ ip_learning = (known after apply)
+ ipv6_mcast_allow = (known after apply)
+ limit_ip_learn_to_subnets = (known after apply)
+ ll_addr = (known after apply)
+ mac = (known after apply)
+ mcast_allow = (known after apply)
+ multi_dst_pkt_act = (known after apply)
+ name = "test_bd1"
+ name_alias = (known after apply)
+ optimize_wan_bandwidth = (known after apply)
+ relation_fv_rs_ctx = "test_vrf1"
+ tenant_dn = (known after apply)
+ unicast_route = (known after apply)
+ unk_mac_ucast_act = (known after apply)
+ unk_mcast_act = (known after apply)
+ v6unk_mcast_act = (known after apply)
+ vmac = (known after apply)
}
# aci_subnet.test_subnet1 will be created
+ resource "aci_subnet" "test_subnet1" {
+ annotation = (known after apply)
+ bridge_domain_dn = (known after apply)
+ ctrl = (known after apply)
+ description = "test_subnet1"
+ id = (known after apply)
+ ip = "10.0.3.28/27"
+ name_alias = (known after apply)
+ preferred = (known after apply)
+ scope = (known after apply)
+ virtual = (known after apply)
}
# aci_tenant.test_tenant1 will be created
+ resource "aci_tenant" "test_tenant1" {
+ annotation = (known after apply)
+ description = "test tenant"
+ id = (known after apply)
+ name = "test_tenant1"
+ name_alias = (known after apply)
}
# aci_vrf.test_vrf1 will be created
+ resource "aci_vrf" "test_vrf1" {
+ annotation = (known after apply)
+ bd_enforced_enable = (known after apply)
+ description = "test vrf"
+ id = (known after apply)
+ ip_data_plane_learning = (known after apply)
+ knw_mcast_act = (known after apply)
+ name = "test_vrf1"
+ name_alias = (known after apply)
+ pc_enf_dir = (known after apply)
+ pc_enf_pref = (known after apply)
+ tenant_dn = (known after apply)
}
Plan: 4 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aci_tenant.test_tenant1: Creating...
aci_tenant.test_tenant1: Creation complete after 3s [id=uni/tn-test_tenant1]
aci_vrf.test_vrf1: Creating...
aci_vrf.test_vrf1: Still creating... [10s elapsed]
aci_vrf.test_vrf1: Creation complete after 18s [id=uni/tn-test_tenant1/ctx-test_vrf1]
aci_bridge_domain.test_bd1: Creating...
aci_bridge_domain.test_bd1: Creation complete after 5s [id=uni/tn-test_tenant1/BD-test_bd1]
aci_subnet.test_subnet1: Creating...
aci_subnet.test_subnet1: Creation complete after 2s [id=uni/tn-test_tenant1/BD-test_bd1/subnet-[10.0.3.28/27]]
Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
$
$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
aci_subnet.test_subnet1: Refreshing state... [id=uni/tn-test_tenant1/BD-test_bd1/subnet-[10.0.3.28/27]]
aci_tenant.test_tenant1: Refreshing state... [id=uni/tn-test_tenant1]
aci_vrf.test_vrf1: Refreshing state... [id=uni/tn-test_tenant1/ctx-test_vrf1]
aci_bridge_domain.test_bd1: Refreshing state... [id=uni/tn-test_tenant1/BD-test_bd1]
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
# aci_subnet.test_subnet1 will be destroyed
- resource "aci_subnet" "test_subnet1" {
- bridge_domain_dn = "uni/tn-test_tenant1/BD-test_bd1" -> null
- ctrl = "nd" -> null
- description = "test_subnet1" -> null
- id = "uni/tn-test_tenant1/BD-test_bd1/subnet-[10.0.3.28/27]" -> null
- ip = "10.0.3.28/27" -> null
- preferred = "no" -> null
- scope = "private" -> null
- virtual = "no" -> null
}
Plan: 0 to add, 0 to change, 1 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
terraform apply 実行ログ(クリックして広げる)
$ terraform apply
aci_subnet.test_subnet1: Refreshing state... [id=uni/tn-test_tenant1/BD-test_bd1/subnet-[10.0.3.28/27]]
aci_tenant.test_tenant1: Refreshing state... [id=uni/tn-test_tenant1]
aci_vrf.test_vrf1: Refreshing state... [id=uni/tn-test_tenant1/ctx-test_vrf1]
aci_bridge_domain.test_bd1: Refreshing state... [id=uni/tn-test_tenant1/BD-test_bd1]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
# aci_subnet.test_subnet1 will be destroyed
- resource "aci_subnet" "test_subnet1" {
- bridge_domain_dn = "uni/tn-test_tenant1/BD-test_bd1" -> null
- ctrl = "nd" -> null
- description = "test_subnet1" -> null
- id = "uni/tn-test_tenant1/BD-test_bd1/subnet-[10.0.3.28/27]" -> null
- ip = "10.0.3.28/27" -> null
- preferred = "no" -> null
- scope = "private" -> null
- virtual = "no" -> null
}
Plan: 0 to add, 0 to change, 1 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aci_subnet.test_subnet1: Destroying... [id=uni/tn-test_tenant1/BD-test_bd1/subnet-[10.0.3.28/27]]
aci_subnet.test_subnet1: Destruction complete after 1s
Apply complete! Resources: 0 added, 0 changed, 1 destroyed.
$
- hosts: ios
gather_facts: yes # デフオルトvars:ansible_network_os: ios
ansible_network_connection: network_cli
tasks:- name: show command test
ios_command:commands:- show version
Playbook を実行します。
$ ansible-playbook -i ../inventory.ini ios_show_test.yml
PLAY [ios] ***********************************************************************************************
TASK [Gathering Facts] *******************************************************************************************
[WARNING]: Ignoring timeout(20) for ios_facts
ok: [ios1]
...(略)...
- hosts: ios
gather_facts: yes # デフオルトvars:ansible_network_os: ios
ansible_network_connection: network_cli
ansible_connect_timeout:1 # pointtasks:- name: show command test
ios_command:commands:- show version
Playbook を実行します。
$ ansible-playbook -i ../inventory.ini ios_show_test.yml
PLAY [ios] ***********************************************************************************************
TASK [Gathering Facts] *******************************************************************************************
[WARNING]: Ignoring timeout(10) for ios_facts
fatal: [ios1]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ios_facts": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "invocation": {"module_args": {"auth_pass": null, "authorize": null, "gather_network_resources": null, "gather_subset": ["all"], "host": null, "password": null, "port": null, "provider": null, "ssh_keyfile": null, "timeout": null, "username": null}}, "msg": "socket_path does not exist or cannot be found.\nSee the socket_path issue category in Network Debug and Troubleshooting Guide", "warnings": ["Platform darwin on host ios1 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information."]}}, "msg": "The following modules failed to execute: ios_facts\n"}
- hosts: ios
gather_facts: yes # デフオルトvars:ansible_network_os: ios
ansible_network_connection: network_cli
ansible_command_timeout:1 # pointtasks:- name: show command test
ios_command:commands:- show version
Playbook を実行します。
$ ansible-playbook -i ../inventory.ini ios_show_test.yml
PLAY [ios] ***********************************************************************************************
TASK [Gathering Facts] *******************************************************************************************
[WARNING]: Ignoring timeout(10) for ios_facts
fatal: [ios1]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ios_facts": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "invocation": {"module_args": {"auth_pass": null, "authorize": null, "gather_network_resources": null, "gather_subset": ["all"], "host": null, "password": null, "port": null, "provider": null, "ssh_keyfile": null, "timeout": null, "username": null}}, "msg": "command timeout triggered, timeout value is 1 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide.", "warnings": ["Platform darwin on host ios1 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information."]}}, "msg": "The following modules failed to execute: ios_facts\n"}
エラーになりました。エラーメッセージを見ると
command timeout triggered, timeout value is 1 secs