Question

Ansible & M365


Userlevel 3

I am trying to write a playbook that takes a final backup of an exiting employees OneDrive and Exchange Mailbox.  I can’t get past getting an authentication token.

 


11 comments

Userlevel 7
Badge +20

Is this question related to Veeam VB365?  I see that now apologies.

Not sure you can with ansible.

Userlevel 3

Unless, I’m reading the API wrong (which could very well be), I can create a job with the API, Execute said job (both backup and restore), and then delete said job afterwards. POST Method - Veeam Backup for Microsoft 365 REST API Reference.  I am think that I have to create a seperate playbook for each task and then a “Master” playbook with tasks that call the playbooks of the individual steps.

Userlevel 7
Badge +20

Ah yes if you are using Ansible to call the API then you definitely can do this.  I don’t use the API much for VB365, but the documentation is very good and should help out there.

Userlevel 3

The problem I’m having, is I can’t figure out the formatting for generating the authentication token.

Userlevel 7
Badge +20

I might suggest at this point to create a case and then also post in the forums - https://forums.veeam.com

It will be the quicker way to get help on this particular topic for sure.

Userlevel 7
Badge +6

I am trying to write a playbook that takes a final backup of an exiting employees OneDrive and Exchange Mailbox.  I can’t get past getting an authentication token.

 

@Steve.Bennett, great initiative. It will rocks. Please, if you can share the final playbook with the community, it will be great! 👏

Userlevel 3

Here is my first go at the playbook to generate a token.  I believe I am missing something because I am getting a powershell error.  Which I assume means that I’m making an initial connection.  Does anyone know where the logs could be found to test?  Here is my initial playbook for generating the token for access. 

---
- name: Testing Veeam Rest API
  hosts: localhost
  gather_facts: no
  
  vars_prompt:
   - name: upn
     prompt: "Enter the User Principal Name of the Account to backup"
     private: no
   
   - name: veeam_user
     prompt: "Enter Backup Administrator Account"
     private: no
     
   - name: veeam_pswd
     prompt: "Enter your password"
     private: yes
  
  tasks:
  
   - name: Generate Veeam API Session Token
     ansible.windows.win_uri:
      url: https://[myserverhere.whatever]:4443/v7/token
      content_type: "application/x-www-form-urlencoded"
      grant_type: "password"
      body:
       username: "{{veeam_user}}"
       password: "{{veeam_pswd}}"
       url_method: "POST"
      status_code: 200
     register: api_response
 
   - name: Display API Response
     debug:
      msg: "{{api_response}}"

Userlevel 3

I might suggest at this point to create a case and then also post in the forums - https://forums.veeam.com

It will be the quicker way to get help on this particular topic for sure.

Honestly, I’m not getting any traction over there.

Userlevel 7
Badge +20

I might suggest at this point to create a case and then also post in the forums - https://forums.veeam.com

It will be the quicker way to get help on this particular topic for sure.

Honestly, I’m not getting any traction over there.

You need a support ticket in order to get better traction there.  Unless there are already some posts on the subject.

Userlevel 7
Badge +12

Hi Steve

 

I apologize that you didn‘t got an answer yet.

Your topic wasn‘t marked as „unanswered“ because of your second comment. We have a lot of new topics, and „self-answered“ topics may be not seen between all the new topics we get.

 

I will ask a colleague tomorrow who has experience with Ansible. Maybe he can give you some starting ideas.

 

Best,

Fabian

 

——-

 

@Chris.Childerhose

Our customer support team doesn‘t provide assistance for custom scripts. 

 

 

Userlevel 7
Badge +20

Hi Steve

 

I apologize that you didn‘t got an answer yet.

Your topic wasn‘t marked as „unanswered“ because of your second comment. We have a lot of new topics, and „self-answered“ topics may be not seen between all the new topics we get.

 

I will ask a colleague tomorrow who has experience with Ansible. Maybe he can give you some starting ideas.

 

Best,

Fabian

 

——-

 

@Chris.Childerhose

Our customer support team doesn‘t provide assistance for custom scripts. 

 

 

I was not stipulating they would help with a custom script just they could help with the token question with the API and pointers.

Comment