-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
frsauvage
committed
May 20, 2021
1 parent
571a9bd
commit da8bea6
Showing
29 changed files
with
611 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
ansible/playbooks/openbmc/inventory/get_ntp_server_ip_and_sync.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
- hosts: all | ||
connection: local | ||
name: Get NTP Server IP and Sync Method | ||
gather_facts: False | ||
vars_files: | ||
- "{{ ANSIBLE_EXTERNAL_VARS }}" | ||
- "{{ ANSIBLE_PASSWORDS }}" | ||
|
||
tasks: | ||
|
||
- name: validate ntp_server_ip variable | ||
assert: | ||
that: | ||
- ntp_server_ip is defined | ||
- ntp_server_ip |default(None) | ||
fail_msg: "The variable ntp_server_ip is NOT defined in inventory (AWX) or vars/external_vars file (Ansible). See readme.md for more details." | ||
success_msg: "The variable ntp_server_ip is defined" | ||
run_once: true | ||
|
||
- name: validate ntp_server_sync variable | ||
assert: | ||
that: | ||
- ntp_server_sync is defined | ||
- ntp_server_sync |default(None) | ||
fail_msg: "The variable ntp_server_sync is NOT defined in inventory (AWX) or vars/external_vars file (Ansible). See readme.md for more details." | ||
success_msg: "The variable ntp_server_sync is defined" | ||
run_once: true | ||
|
||
- debug: | ||
msg: "ntp server ip in vars file = {{ ntp_server_ip }}" | ||
when: ntp_server_ip is defined | ||
run_once: true | ||
|
||
- debug: | ||
msg: "ntp server sync in vars file = {{ ntp_server_sync }}" | ||
when: ntp_server_sync is defined | ||
run_once: true | ||
|
||
- include_tasks: ../utils/utils_create_token.yml | ||
|
||
- name: get NTP Server IP | ||
uri: | ||
url: https://{{ baseuri }}/xyz/openbmc_project/network/eth0/attr/NTPServers | ||
method: GET | ||
validate_certs: no | ||
headers: | ||
X-Auth-Token: "{{ x_token }}" | ||
register: result_ntp_server_ip | ||
|
||
- name: get NTP Server Sync | ||
uri: | ||
url: https://{{ baseuri }}/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod | ||
method: GET | ||
validate_certs: no | ||
headers: | ||
X-Auth-Token: "{{ x_token }}" | ||
register: result_ntp_server_sync | ||
|
||
- set_fact: | ||
address_ip: "{{ result_ntp_server_ip.json.data }}" | ||
|
||
- set_fact: | ||
sync: "{{ result_ntp_server_sync.json.data }}" | ||
|
||
- name: debug NTP Server Ip and Sync | ||
debug: | ||
msg: "NTP Ip = {{address_ip}} / Sync method = {{sync}}" | ||
when: address_ip is defined and sync is defined | ||
|
64 changes: 64 additions & 0 deletions
64
ansible/playbooks/openbmc/inventory/set_ntp_server_ip_and_sync.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
- hosts: all | ||
connection: local | ||
name: Set NTP Server Ip and Sync | ||
gather_facts: False | ||
vars_files: | ||
- "{{ ANSIBLE_EXTERNAL_VARS }}" | ||
- "{{ ANSIBLE_PASSWORDS }}" | ||
|
||
tasks: | ||
|
||
- name: validate ntp_server_ip variable | ||
assert: | ||
that: | ||
- ntp_server_ip is defined | ||
- ntp_server_ip |default(None) | ||
fail_msg: "The variable ntp_server_ip is NOT defined in inventory (AWX) or vars/external_vars file (Ansible). See readme.md for more details." | ||
success_msg: "The variable ntp_server_ip is defined" | ||
run_once: true | ||
|
||
- debug: | ||
msg: "NTP server ip = {{ ntp_server_ip }}" | ||
when: ntp_server_ip is defined | ||
run_once: true | ||
|
||
- name: validate ntp_server_sync variable | ||
assert: | ||
that: | ||
- ntp_server_sync is defined | ||
- ntp_server_sync |default(None) | ||
fail_msg: "The variable ntp_server_sync is NOT defined in inventory (AWX) or vars/external_vars file (Ansible). See readme.md for more details." | ||
success_msg: "The variable ntp_server_sync is defined" | ||
run_once: true | ||
|
||
- debug: | ||
msg: "ntp server sync in vars file = {{ ntp_server_sync }}" | ||
when: ntp_server_sync is defined | ||
run_once: true | ||
|
||
- include_tasks: ../utils/utils_create_token.yml | ||
|
||
- name: set NTP Server Ip | ||
uri: | ||
url: https://{{ baseuri }}/xyz/openbmc_project/network/eth0/attr/NTPServers | ||
method: PUT | ||
validate_certs: no | ||
headers: | ||
X-Auth-Token: "{{ x_token }}" | ||
body_format: json | ||
body: | ||
data: "{{ ntp_server_ip }}" | ||
register: result_ntp_server_ip | ||
|
||
- name: set NTP Server Sync | ||
uri: | ||
url: https://{{ baseuri }}/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod | ||
method: PUT | ||
validate_certs: no | ||
headers: | ||
X-Auth-Token: "{{ x_token }}" | ||
body_format: json | ||
body: | ||
data: "{{ ntp_server_sync }}" | ||
register: result_ntp_server_sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.