Comments (7)
What is strange it looks like to work now both for VMs and BMs ...
MacBook-Pro-Lukasz:start_tfs_v1.0 lukaszfeldman$ more variables.tf
(...)
variable "Shapes" {
default = ["VM.Standard1.1","VM.Standard1.2","VM.Standard1.4","BM.Standard1.36","BM.HighIO1.36","BM.DenseIO1.36"]
}
(...)
MacBook-Pro-Lukasz:start_tfs_v1.0 lukaszfeldman$ more webserver1.tf
resource "baremetal_core_instance" "terraform_webserver1" {
availability_domain = "${var.ADs[0]}"
compartment_id = "${baremetal_identity_compartment.terraform_compartment.id}"
display_name = "WebServer1"
image = "${var.Images[0]}"
shape = "${var.Shapes[0]}"
subnet_id = "${baremetal_core_subnet.terraform_Subnet1.id}"
metadata {
ssh_authorized_keys = "${file("/Users/lukaszfeldman/chef/chefserver__id_rsa.pub")}"
}
}
data "baremetal_core_vnic_attachments" "w1_vnic_attach" {
availability_domain = "${var.ADs[0]}"
compartment_id = "${baremetal_identity_compartment.terraform_compartment.id}"
instance_id = "${baremetal_core_instance.terraform_webserver1.id}"
}
data "baremetal_core_vnic" "w1_vnic" {
vnic_id = "${data.baremetal_core_vnic_attachments.w1_vnic_attach.vnic_attachments.0.vnic_id}"
}
resource "null_resource" "terraform_webserver1_ready" {
triggers {
webserver1_ready_id = "${baremetal_core_instance.terraform_webserver1.id}"
chefserver_ready_id = "${baremetal_core_instance.terraform_chefserver.id}"
}
depends_on = ["null_resource.terraform_chefserver_ready"]
provisioner "local-exec" {
command = "scp -i /Users/lukaszfeldman/chef/chefserver__id_rsa -o 'StrictHostKeyChecking no' *.pem opc@${data.baremetal_core_vnic.w1_vnic.public_ip_address}:/home/opc/"
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "opc"
host = "${data.baremetal_core_vnic.w1_vnic.public_ip_address}"
private_key = "${file("/Users/lukaszfeldman/chef/chefserver__id_rsa")}"
agent = false
}
inline = ["sudo -u root cp /home/opc/ora1521.pem /etc/chef/ora1521.pem",
"sudo -u root cp /home/opc/ora1521-validator.pem /etc/chef/client.pem",
"sudo /bin/su -c \"echo '${data.baremetal_core_vnic.w1_vnic.public_ip_address} webserver1.oraorg.org webserver1' >> /etc/hosts\"",
"sudo /bin/su -c \"echo '${data.baremetal_core_vnic.chef_dbv.public_ip_address} chefserver.oraorg.org chefserver' >> /etc/hosts\"",
"sudo /bin/su -c \"echo HOSTNAME=webserver1.oraorg.org >> /etc/sysconfig/network\"",
"sudo -u root hostname webserver1.oraorg.org"]
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "opc"
host = "${data.baremetal_core_vnic.chef_dbv.public_ip_address}"
private_key = "${file("/Users/lukaszfeldman/chef/chefserver__id_rsa")}"
agent = false
}
inline = ["sudo /bin/su -c \"echo '${data.baremetal_core_vnic.w1_vnic.public_ip_address} webserver1.oraorg.org webserver1' >> /etc/hosts\""]
}
provisioner "chef" {
connection {
type = "ssh"
user = "opc"
host = "${data.baremetal_core_vnic.w1_vnic.public_ip_address}"
private_key = "${file("/Users/lukaszfeldman/chef/chefserver__id_rsa")}"
agent = false
}
node_name = "webserver1"
server_url = "https://chefserver.oraorg.org/organizations/oraorg"
user_name = "ora1521"
user_key = "${file("ora1521.pem")}"
run_list = []
ssl_verify_mode = ":verify_none"
}
}
from terraform-provider-oci.
Yes, the challenge is that the vNIC is an entirely different resource than the instance so the IP of the instance isn't returned when the instance is launched. We're exploring options.
from terraform-provider-oci.
I can confirm that it works with actual version, IMHO because vnic don't need to be defined as separate resource now.
resource "baremetal_core_instance" "test-ad1" {
....
provisioner "remote-exec" {
inline = [
"whoami"
]
connection {
type = "ssh"
user = "tester"
host = "${baremetal_core_instance.test-ad1.private_ip}"
private_key = "${file("<path_to_key>")}"
}
}
}
from terraform-provider-oci.
@VAdamec does that mean this is safe to close?
from terraform-provider-oci.
@josephholsten I didn't test Chef, just common remote-exec, @lfeldman can you test it and close this if it's ok ?
from terraform-provider-oci.
We have a good example of this now in the docs
https://github.com/oracle/terraform-provider-oci/blob/master/docs/examples/compute/omc_monitored_server/chef_stage_and_monitor_instance/main.tf
from terraform-provider-oci.
We have a second example that uses Chef without OMC, see https://github.com/oracle/terraform-provider-oci/tree/master/docs/examples/compute/instance_chef.
from terraform-provider-oci.
Related Issues (20)
- incorrect documentation for oci_devops_trigger filters HOT 1
- oci_devops_trigger wrong documentation for `repository_id` HOT 1
- Resource `oci_os_management_hub_managed_instance_group` always triggers update on `software_source_ids` HOT 4
- Cannot enable IPSec over FastConnect HOT 1
- terraform doesn't support PKCS#8 format API Keys HOT 4
- build_pipeline update BuildPipelineParameters don't seem to be optional as documented HOT 1
- Documentation for oci_file_storage_export is incomplete HOT 1
- A oci_identity_domains_group resource "assumes" the creator is in the same domain and sets invalid owner/idcs_created_by causing future updates to fail HOT 1
- oci_core_instance should replace the resource on source_details updates HOT 2
- oci_core_images
- Changes to "ciphers" are not detected for the oci_load_balancer_ssl_cipher_suite resource
- oci_core_instance incorrectly identify destroy action as in-place-change HOT 7
- Error while updating ssl_configuration.protocols for oci_load_balancer_backend_set HOT 4
- The "get started tutorials" link in the provider documentation leads to a 404 error page. HOT 3
- provider version >= 5.44.0 does not read ~/.oci/config HOT 2
- Updating tags of public IP assigned to NAT gateway HOT 1
- OKE - Not able to update defined tags for node_config_details HOT 2
- Provider does not auth with \n in private_key HOT 3
- TF plan showing recreate cluster is needed when a new subnet id is added to output variables HOT 11
- Unable to get the actual ocid user on the identity_users_data_source HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-provider-oci.