Skip to content

Commit

Permalink
Merge pull request #68 from cohesity/oracleLinux
Browse files Browse the repository at this point in the history
Support for OracleLinux Operating System.
  • Loading branch information
naveena-maplelabs authored Jan 24, 2022
2 parents 2a4b553 + a2167d7 commit 7ff50ca
Show file tree
Hide file tree
Showing 29 changed files with 83 additions and 33 deletions.
18 changes: 9 additions & 9 deletions library/cohesity_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ def download_agent(module, path):
headers = {
"Accept": "application/octet-stream",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
elif not module.params.get('download_uri'):
os_type = "Linux"
server = module.params.get('cluster')
token = get__cohesity_auth__token(module)
package_type = 'kScript'
if module.params.get('native_package'):
if module.params.get('operating_system') in ('CentOS', 'RedHat'):
if module.params.get('operating_system') in ('CentOS', 'RedHat', 'OracleLinux'):
package_type = 'kRPM'
elif module.params.get('operating_system') == 'SLES':
package_type = 'kSuseRPM'
Expand All @@ -273,12 +273,12 @@ def download_agent(module, path):
headers = {
"Accept": "application/octet-stream",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
else:
uri = module.params.get('download_uri')
headers = {
"Accept": "application/octet-stream",
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}

agent = open_url(url=uri, headers=headers,
validate_certs=False, timeout=REQUEST_TIMEOUT)
Expand Down Expand Up @@ -370,7 +370,7 @@ def install_agent(module, installer, native):
user = module.params.get('service_user')
if module.params.get('operating_system') == "Ubuntu":
cmd = "sudo COHESITYUSER={0} dpkg -i {1}".format(user, installer)
elif module.params.get('operating_system') in ("CentOS", "RedHat"):
elif module.params.get('operating_system') in ("CentOS", "RedHat", "OracleLinux"):
cmd = "sudo COHESITYUSER={0} rpm -i {1}".format(user, installer)
elif module.params.get('operating_system') == "AIX":
cmd = "sudo COHESITYUSER={0} installp -ad {1} all".format(user, installer)
Expand All @@ -381,7 +381,7 @@ def install_agent(module, installer, native):
except Exception as e:
if module.params.get('operating_system') == "Ubuntu":
cmd = "sudo COHESITYUSER=%s dpkg -i %s" % (user, installer)
elif module.params.get('operating_system') in ("CentOS", "RedHat"):
elif module.params.get('operating_system') in ("CentOS", "RedHat", "OracleLinux"):
cmd = "sudo COHESITYUSER=%s rpm -i %s" % (user, installer)

rc, stdout, stderr = module.run_command(cmd, cwd=installer)
Expand Down Expand Up @@ -449,7 +449,7 @@ def remove_agent(module, installer, native):
if rc:
installation_failures(
module, stdout, rc, "Failed to uninstall cohesity agent ")
elif module.params.get('operating_system') in ("CentOS", "RedHat"):
elif module.params.get('operating_system') in ("CentOS", "RedHat", "OracleLinux"):
cmd = "sudo rpm -e cohesity-agent"
rc, stdout, stderr = module.run_command(cmd)
if rc:
Expand Down Expand Up @@ -511,7 +511,7 @@ def get_source_details(module, source_id):
"/irisservices/api/v1/public/protectionSources?environments=kPhysical"
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
response = open_url(
url=uri,
headers=headers,
Expand Down Expand Up @@ -561,7 +561,7 @@ def update_agent(module):
"/irisservices/api/v1/public/physicalAgents/upgrade"
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
payload = {
"agentIds": [source_details['agent']['id']]
}
Expand Down
2 changes: 1 addition & 1 deletion library/cohesity_clone_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def main():

global cohesity_client
base_controller = BaseController()
base_controller.global_headers['user-agent'] = 'cohesity-ansible/v2.3.0'
base_controller.global_headers['user-agent'] = 'cohesity-ansible/v2.3.2'
cohesity_client = get_cohesity_client(module)
clone_exists, clone_details = get_clone_task(module, False)

Expand Down
18 changes: 9 additions & 9 deletions library/cohesity_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def get_vmware_ids(module, job_meta_data, job_details, vm_names):
str(job_meta_data['parentSourceId'])
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
response = open_url(
url=uri,
method='GET',
Expand Down Expand Up @@ -445,7 +445,7 @@ def get_vmware_vm_ids(module, job_meta_data, job_details, vm_names):
"/irisservices/api/v1/public/protectionSources/virtualMachines?vCenterId=" + str(job_meta_data['parentSourceId'])
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
response = open_url(
url=uri,
method='GET',
Expand Down Expand Up @@ -485,7 +485,7 @@ def get_view_storage_domain_id(module, self):
uri = "https://" + server + "/irisservices/api/v1/public/views/" + view_name
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
response = open_url(url=uri, method="GET", headers=headers,
validate_certs=validate_certs, timeout=REQUEST_TIMEOUT)
response = json.loads(response.read())
Expand All @@ -505,7 +505,7 @@ def register_job(module, self):
uri = "https://" + server + "/irisservices/api/v1/public/protectionJobs"
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
payload = self.copy()

# => Remove the Authorization Token from the Payload
Expand Down Expand Up @@ -575,7 +575,7 @@ def start_job(module, self):
"/irisservices/api/v1/public/protectionJobs/run/" + str(self['id'])
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
source_ids = payload.get('sourceIds', [])
payload = dict()
payload['runNowParameters'] = [{'sourceId':source_id} for source_id in source_ids]
Expand Down Expand Up @@ -623,7 +623,7 @@ def update_job(module, job_details, update_source_ids=None):
"/irisservices/api/v1/public/protectionJobs/" + str(job_details['id'])
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
payload = job_details.copy()
del payload['token']
if module.params.get('environment') == 'PhysicalFiles' and module.params.get('delete_sources') == False:
Expand Down Expand Up @@ -671,7 +671,7 @@ def get_prot_job_details(self, module):

headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
response = open_url(url=uri, headers=headers,
validate_certs=validate_certs, timeout=REQUEST_TIMEOUT)
if not response.getcode() == 200:
Expand Down Expand Up @@ -714,7 +714,7 @@ def stop_job(module, self):
str(self['id'])
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
payload = self.copy()

# => Remove the Authorization Token from the Payload
Expand Down Expand Up @@ -766,7 +766,7 @@ def unregister_job(module, self):
"/irisservices/api/v1/public/protectionJobs/" + str(self['id'])
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}

payload = dict(
deleteSnapshots=self['deleteSnapshots']
Expand Down
2 changes: 1 addition & 1 deletion library/cohesity_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def main():

global cohesity_client
base_controller = BaseController()
base_controller.global_headers['user-agent'] = 'cohesity-ansible/v2.3.0'
base_controller.global_headers['user-agent'] = 'cohesity-ansible/v2.3.2'
cohesity_client = get_cohesity_client(module)
policy_exists, policy_details = get_policy_details(module)

Expand Down
4 changes: 2 additions & 2 deletions library/cohesity_restore_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def start_restore(module, uri, self):
uri = "https://" + server + uri
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
payload = self.copy()

# => Remove the Authorization Token from the Payload
Expand Down Expand Up @@ -421,7 +421,7 @@ def wait_restore_complete(module, self):
headers = {
"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
attempts = 0
# => Wait for the restore based on a predetermined number of minutes with checks every 30 seconds.
while attempts < wait_counter:
Expand Down
10 changes: 5 additions & 5 deletions library/cohesity_restore_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def get_source_details(module, restore_to_source):
"/irisservices/api/v1/public/protectionSources/rootNodes?environments=kVMware"
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
response = open_url(
url=uri,
headers=headers,
Expand Down Expand Up @@ -300,7 +300,7 @@ def get_vmware_source_objects(module, source_id):

headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}

response = open_url(
url=uri,
Expand Down Expand Up @@ -361,7 +361,7 @@ def get__vmware_snapshot_information__by_source(module, self, source_details):

headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
objects = open_url(url=uri, headers=headers,
validate_certs=validate_certs, timeout=REQUEST_TIMEOUT)
objects = json.loads(objects.read())
Expand Down Expand Up @@ -489,7 +489,7 @@ def start_restore(module, uri, self):
uri = "https://" + server + uri
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
payload = self.copy()

# => Remove the Authorization Token from the Payload
Expand Down Expand Up @@ -532,7 +532,7 @@ def wait_restore_complete(module, self):
"/irisservices/api/v1/public/restore/tasks/" + str(self['id'])
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
attempts = 0
# => Wait for the restore based on a predetermined number of minutes with checks every 30 seconds.
while attempts < wait_counter:
Expand Down
6 changes: 3 additions & 3 deletions library/cohesity_restore_vmware_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def start_restore(module, uri, self):
uri = "https://" + server + uri
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
payload = self.copy()

# => Remove the Authorization Token from the Payload
Expand Down Expand Up @@ -339,7 +339,7 @@ def wait_restore_complete(module, self):
headers = {
"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
attempts = 0
# => Wait for the restore based on a predetermined number of minutes with checks every 30 seconds.
while attempts < wait_counter:
Expand Down Expand Up @@ -436,7 +436,7 @@ def main():

global cohesity_client
base_controller = BaseController()
base_controller.global_headers['user-agent'] = 'Ansible-v2.3.0'
base_controller.global_headers['user-agent'] = 'Ansible-v2.3.2'
cohesity_client = get_cohesity_client(module)

if module.params.get('backup_id'):
Expand Down
4 changes: 2 additions & 2 deletions library/cohesity_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def register_source(module, self):
uri = "https://" + server + "/irisservices/api/v1/public/protectionSources/register"
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}
payload = self.copy()
payload['environment'] = "k" + self['environment']
if self['environment'] == "Physical":
Expand Down Expand Up @@ -380,7 +380,7 @@ def unregister_source(module, self):
"/irisservices/api/v1/public/protectionSources/" + str(self['id'])
headers = {"Accept": "application/json",
"Authorization": "Bearer " + token,
"user-agent": "cohesity-ansible/v2.3.0"}
"user-agent": "cohesity-ansible/v2.3.2"}

response = open_url(url=uri, method='DELETE', headers=headers,
validate_certs=validate_certs, timeout=REQUEST_TIMEOUT)
Expand Down
2 changes: 1 addition & 1 deletion library/cohesity_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def main():

global cohesity_client
base_controller = BaseController()
base_controller.global_headers['user-agent'] = 'cohesity-ansible/v2.3.0'
base_controller.global_headers['user-agent'] = 'cohesity-ansible/v2.3.2'
cohesity_client = get_cohesity_client(module)
view_exists, view_details = get_view_details(module)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#=> Install cohesity agent on linux machines using native packages. The service user field is required and the user must exist on linux machines
---
- hosts: oraclelinux
gather_facts: yes
become: true
roles:
- cohesity.cohesity_ansible_role
tasks:
- name: Install new Cohesity Agent on each Oracle Linux Server
include_role:
name: cohesity.cohesity_ansible_role
tasks_from: agent
vars:
cohesity_server: "{{ cohesity_cluster_server }}"
cohesity_admin: "{{ var_cohesity_username }}"
cohesity_password: "{{ cohesity_cluster_password }}"
cohesity_validate_certs: "{{ var_validate_certs }}"
cohesity_agent:
state: present
native_package: False
service_user: cohesity-user
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#=> Install cohesity agent on linux machines using native packages. The service user field is required and the user must exist on linux machines
---
- hosts: oraclelinux
gather_facts: yes
become: true
roles:
- cohesity.cohesity_ansible_role
tasks:
- name: Install new Cohesity Agent on each Oracle Linux Server
include_role:
name: cohesity.cohesity_ansible_role
tasks_from: agent
vars:
cohesity_server: "{{ cohesity_cluster_server }}"
cohesity_admin: "{{ var_cohesity_username }}"
cohesity_password: "{{ cohesity_cluster_password }}"
cohesity_validate_certs: "{{ var_validate_certs }}"
cohesity_agent:
state: absent
native_package: False
service_user: cohesity-user
8 changes: 8 additions & 0 deletions tasks/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
- cohesity_agent.state == "present"
tags: always

- name: Install Prerequisite Packages for OracleLinux
action: >
{{ ansible_pkg_mgr }} name="wget,rsync,lsof,lvm2,nfs-utils" state=present
when:
- ansible_distribution == "OracleLinux"
- cohesity_agent.state == "present"
tags: always

- name: Install Prerequisite Packages for SLES
action: >
{{ ansible_pkg_mgr }} name="wget,rsync,lsof,lvm2,libcap-progs" state=present
Expand Down

0 comments on commit 7ff50ca

Please sign in to comment.