Maintain control of your Microsoft 365 data
Post Reply
Steve.Bennett
Lurker
Posts: 2
Liked: never
Joined: Jan 29, 2024 6:49 pm
Full Name: Steve Bennett
Contact:

Ansible & M365

Post by Steve.Bennett »

I am trying to write a playbook to create a backup for an exiting employee's OneDrive and Exchange PST and then restore them to an archived fileshare. Then after those have completed, delete the jobs. I See the API's are available but I can't figure out how to authenticate through ansible.
Steve.Bennett
Lurker
Posts: 2
Liked: never
Joined: Jan 29, 2024 6:49 pm
Full Name: Steve Bennett
Contact:

Re: Ansible & M365

Post by Steve.Bennett »

Here is my sample playbook. I'm starting with generating a session token via username and password.

---
- 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}}"
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 16 guests