Using Ansible with SDM

  1. Install the SDM ssh aliases by adding the output of sdm ssh alias to your .bashrc file or running directly on the command line.

  2. Create an Ansible inventory file with the following format:

     [group_name]
     sdm_server_name ansible_port=sdm_ssh_port ansible_host=127.0.0.1
    

    For example, if you have the following SSH servers configured…

    SDM SSH list

    … then your inventory file should look like this.

     [sdm]
     bastion01 ansible_port=60672 ansible_host=127.0.0.1
     bastion02 ansible_port=61300 ansible_host=127.0.0.1
     deployment04 ansible_port=60834 ansible_host=127.0.0.1
    
  3. Connect to the servers you want to access using sdm: either click on each one in the UI and ensure the green lightning bolt icon is visible next to each, or run sdm connect sdm_server_name for each (or sdm connect --all).
  4. Run Ansible using that inventory file.
     $ ansible -i ansibleinventory sdm -a "echo hello"
     deployment04 | SUCCESS | rc=0 >>
     hello
    
     bastion01 | SUCCESS | rc=0 >>
     hello
    
     bastion02 | SUCCESS | rc=0 >>
     hello