-
- Lurker
- Posts: 2
- Liked: never
- Joined: Jan 29, 2024 6:49 pm
- Full Name: Steve Bennett
- Contact:
Ansible & M365
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.
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Jan 29, 2024 6:49 pm
- Full Name: Steve Bennett
- Contact:
Re: Ansible & M365
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}}"
---
- 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}}"
Who is online
Users browsing this forum: No registered users and 17 guests