mirror of
https://github.com/letic/terraform-provider-proxmox.git
synced 2024-09-28 22:16:03 +00:00
Temporary Revert "Use OTP 2FA", Not acting backward compatible
This reverts commit d596852f8c
.
This commit is contained in:
parent
68c41fc4a9
commit
336b5842fe
@ -37,11 +37,7 @@ export PM_API_URL="https://xxxx.com:8006/api2/json"
|
|||||||
export PM_USER=user@pam
|
export PM_USER=user@pam
|
||||||
export PM_PASS=password
|
export PM_PASS=password
|
||||||
```
|
```
|
||||||
If a 2FA OTP code is required
|
|
||||||
```bash
|
|
||||||
# Optional 2FA OTP code
|
|
||||||
export PM_OTP=otpcode
|
|
||||||
```
|
|
||||||
|
|
||||||
## Run
|
## Run
|
||||||
|
|
||||||
@ -62,8 +58,6 @@ provider "proxmox" {
|
|||||||
pm_api_url = "https://proxmox-server01.example.com:8006/api2/json"
|
pm_api_url = "https://proxmox-server01.example.com:8006/api2/json"
|
||||||
pm_password = "secret"
|
pm_password = "secret"
|
||||||
pm_user = "terraform-user@pve"
|
pm_user = "terraform-user@pve"
|
||||||
//Optional
|
|
||||||
pm_otp = "otpcode"
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ provider "proxmox" {
|
|||||||
pm_api_url = "https://proxmox-server01.example.com:8006/api2/json"
|
pm_api_url = "https://proxmox-server01.example.com:8006/api2/json"
|
||||||
pm_password = "secret"
|
pm_password = "secret"
|
||||||
pm_user = "terraform-user@pve"
|
pm_user = "terraform-user@pve"
|
||||||
pm_otp = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "proxmox_vm_qemu" "cloudinit-test" {
|
resource "proxmox_vm_qemu" "cloudinit-test" {
|
||||||
|
@ -3,7 +3,6 @@ provider "proxmox" {
|
|||||||
pm_api_url = "https://proxmox.org/api2/json"
|
pm_api_url = "https://proxmox.org/api2/json"
|
||||||
pm_password = "supersecret"
|
pm_password = "supersecret"
|
||||||
pm_user = "terraform-user@pve"
|
pm_user = "terraform-user@pve"
|
||||||
pm_otp = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "proxmox_lxc" "lxc-test" {
|
resource "proxmox_lxc" "lxc-test" {
|
||||||
|
@ -54,12 +54,6 @@ func Provider() *schema.Provider {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Default: false,
|
Default: false,
|
||||||
},
|
},
|
||||||
"pm_otp": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
DefaultFunc: schema.EnvDefaultFunc("PM_OTP", nil),
|
|
||||||
Description: "OTP 2FA code (if required)",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
ResourcesMap: map[string]*schema.Resource{
|
ResourcesMap: map[string]*schema.Resource{
|
||||||
@ -75,7 +69,7 @@ func Provider() *schema.Provider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
||||||
client, err := getClient(d.Get("pm_api_url").(string), d.Get("pm_user").(string), d.Get("pm_password").(string), d.Get("pm_otp").(string), d.Get("pm_tls_insecure").(bool))
|
client, err := getClient(d.Get("pm_api_url").(string), d.Get("pm_user").(string), d.Get("pm_password").(string), d.Get("pm_tls_insecure").(bool))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -90,13 +84,13 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getClient(pm_api_url string, pm_user string, pm_password string, pm_otp string, pm_tls_insecure bool) (*pxapi.Client, error) {
|
func getClient(pm_api_url string, pm_user string, pm_password string, pm_tls_insecure bool) (*pxapi.Client, error) {
|
||||||
tlsconf := &tls.Config{InsecureSkipVerify: true}
|
tlsconf := &tls.Config{InsecureSkipVerify: true}
|
||||||
if !pm_tls_insecure {
|
if !pm_tls_insecure {
|
||||||
tlsconf = nil
|
tlsconf = nil
|
||||||
}
|
}
|
||||||
client, _ := pxapi.NewClient(pm_api_url, nil, tlsconf)
|
client, _ := pxapi.NewClient(pm_api_url, nil, tlsconf)
|
||||||
err := client.Login(pm_user, pm_password, pm_otp)
|
err := client.Login(pm_user, pm_password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func applyFn(ctx context.Context) error {
|
|||||||
vmr.SetNode(targetNode)
|
vmr.SetNode(targetNode)
|
||||||
client := currentClient
|
client := currentClient
|
||||||
if client == nil {
|
if client == nil {
|
||||||
client, err = getClient(connInfo["pm_api_url"], connInfo["pm_user"], connInfo["pm_password"], connInfo["pm_otp"], connInfo["pm_tls_insecure"] == "true")
|
client, err = getClient(connInfo["pm_api_url"], connInfo["pm_user"], connInfo["pm_password"], connInfo["pm_tls_insecure"] == "true")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -888,7 +888,6 @@ func initConnInfo(
|
|||||||
"pm_api_url": client.ApiUrl,
|
"pm_api_url": client.ApiUrl,
|
||||||
"pm_user": client.Username,
|
"pm_user": client.Username,
|
||||||
"pm_password": client.Password,
|
"pm_password": client.Password,
|
||||||
"pm_otp": client.Otp,
|
|
||||||
"pm_tls_insecure": "true", // TODO - pass pm_tls_insecure state around, but if we made it this far, default insecure
|
"pm_tls_insecure": "true", // TODO - pass pm_tls_insecure state around, but if we made it this far, default insecure
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user