Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Configuring Availability Group failed: The term 'Get-DbaAvailabilityGroup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."} #269

Open
suganthanraj opened this issue Oct 23, 2024 · 6 comments
Labels
question Further information is requested

Comments

@suganthanraj
Copy link

suganthanraj commented Oct 23, 2024

not Recognized as the name of a cmdlet
I am trying configure SQAON in azure VMs. I installed dbatools in windows target machine. In the source i installed pymssql, it is the mandatory pre-req to install py packages and ps modules

To Reproduce

  1. Configure SQL Availability Group
  2. Configure SQL AG Listener

Expected behavior
Once i import he ansible collection in my playbook . It should be able to create ag and ag listener. But i am facing like error as below:-
fatal: [sqlnode2.accit.com]: FAILED! => {"changed": false, "msg": "Configuring Availability Group failed: The term 'Get-DbaAvailabilityGroup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."}

Versions(please complete the following information):

  • OS: rhel8.9.4
  • SQL Server: 2022
  • PowerShell: Powershell 7

**Please attached the screenshots
image (15)
image (4) 1
**
Add any other context about the problem here.

@suganthanraj suganthanraj added the bug Something isn't working label Oct 23, 2024
@lowlydba lowlydba removed the bug Something isn't working label Oct 26, 2024
@lowlydba
Copy link
Owner

Configuring Availability Group failed: The term 'Get-DbaAvailabilityGroup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again

This indicates that dbatools is not actually available on the host you're running against. Try adding some basic pwsh debug tasks to ensure that you can execute dbatools functions on the host.

Please also include your playbook and inventory sample for a MVP.

@lowlydba lowlydba added needs-information question Further information is requested and removed needs-information labels Oct 26, 2024
@lowlydba
Copy link
Owner

Its also worth noting that if you are intending to execute this on the controller, you'll need to use a connection hack (https://github.com/lowlydba/lowlydba.sqlserver/blob/main/tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins/local_pwsh.py) like we do in the testing pipelines in order to get pwsh to execute correctly.

@suganthanraj
Copy link
Author

suganthanraj commented Oct 26, 2024

Below is the inventory

[sql_nodes]
sqlnode1.example.com ansible_host='192.168.56.72'
sqlnode2.example.com ansible_host='192.168.56.73'
sqlnode3.example.com ansible_host='192.168.56.74'

[primary]
sqlnode1.example.com

[secondary]
sqlnode2.example.com

[tertiary]
sqlnode3.example.com

[all:vars]
ansible_connection=winrm
ansible_user=Administrator
ansible_password="Admin@123"
ansible_port=5985
ansible_winrm_transport=ntlm

Below is the main.yml playbook

---
- name: Manage and Configure SQL Server HA and DR
  hosts: sql_nodes
  gather_facts: false
  become_method: runas
  become: true
  become_user: administrator
  become_flags: logon_flags=
  vars_files:    
    - variables.yml
  tasks:
    - ansible.builtin.include_role:
        name: /root/.ansible/collections/ansible_collections/lowlydba/sqlserver/plugins/modules
    - name: Create Availability Group
      lowlydba.sqlserver.availability_group:
        sql_instance: SQLNODE1\INST1
        ag_name: AG_MyDatabase
        sql_username: domain\administrator
        sql_password: Admin@123

@suganthanraj
Copy link
Author

Its also worth noting that if you are intending to execute this on the controller, you'll need to use a connection hack (https://github.com/lowlydba/lowlydba.sqlserver/blob/main/tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins/local_pwsh.py) like we do in the testing pipelines in order to get pwsh to execute correctly.

How to use this in my playbook?

@suganthanraj
Copy link
Author

Configuring Availability Group failed: The term 'Get-DbaAvailabilityGroup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again

This indicates that dbatools is not actually available on the host you're running against. Try adding some basic pwsh debug tasks to ensure that you can execute dbatools functions on the host.

Please also include your playbook and inventory sample for a MVP.

I already installled the dbatools powershell module in the target windows machine.

@lowlydba
Copy link
Owner

lowlydba commented Nov 2, 2024

How to use this in my playbook?

Please check how it is used in the tests directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants