chrisluiz16

Untitled

Oct 14th, 2023
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. ---
  2.  
  3. - name: "Installing required package for nexus-3 cli"
  4. yum:
  5. name: python3-pip
  6. state: present
  7. tags:
  8. - nexus
  9. - never
  10.  
  11. - name: "Installing nexus3-cli using pip"
  12. pip:
  13. name: nexus3-cli
  14. tags:
  15. - nexus
  16. - never
  17.  
  18. - name: "Adding a required setting in {{nexus_dir}}"
  19. lineinfile:
  20. path: "{{nexus_dir}}/nexus-default.properties"
  21. insertafter: "nexus.hazelcast.discovery.isEnabled=true"
  22. line: nexus.scripts.allowCreation=true
  23. register: script_status
  24. tags:
  25. - run_once
  26. - never
  27.  
  28. - name: "Nexus service restart required"
  29. when: script_status.changed
  30. service:
  31. name: nexus
  32. state: restarted
  33. tags:
  34. - run_once
  35. - never
  36.  
  37. - name: "Waiting for 90 sec for nexus to initiate"
  38. when: script_status.changed
  39. wait_for:
  40. timeout: 90
  41. tags:
  42. - run_once
  43. - never
  44.  
  45. - name: "Nexus login through nexus3-cli"
  46. shell: "nexus3 login -U {{ nexus_url }} -u {{ nexus_user }} -p {{ nexus_passwd }} --x509_verify"
  47. tags:
  48. - nexus
  49. - never
  50.  
  51. - name: "Creating a yum proxy nexus repository"
  52. when: rpm_package == ""
  53. shell: "nexus3 repository create proxy yum --strict-content --health-check {{ nexus_repo_name }} {{ remote_url }}"
  54. tags:
  55. - nexus
  56. - never
  57. register: proxy_status
  58.  
  59. - name: "Copying to remote location"
  60. when: proxy_status.changed == false
  61. copy:
  62. src: "/var/lib/jenkins/workspace/nexus-project/package.rpm"
  63. dest: "/tmp/{{ rpm_package }}.rpm"
  64. tags:
  65. - nexus
  66. - never
  67.  
  68. - name: "Creating a nexus yum hosted repository"
  69. when: proxy_status.changed == false
  70. shell: "nexus3 repository create hosted yum {{ nexus_repo_name }}"
  71. tags:
  72. - nexus
  73. - never
  74.  
  75. - name: "Uploading rpm package to nexus yum repo"
  76. when: proxy_status.changed == false
  77. shell: "nexus3 upload /tmp/{{ rpm_package }}.rpm {{ nexus_repo_name }}"
  78. tags:
  79. - nexus
  80. - never
  81.  
  82. - name: "Cleaning rpm file in nexus server"
  83. when: proxy_status.changed == false
  84. file:
  85. path: "/tmp/{{ rpm_package }}.rpm"
  86. state: absent
  87. tags:
  88. - nexus
  89. - never
  90.  
  91. #- name: "Copying package to a temporary location"
  92. # when: proxy_status.changed == false
  93. # delegate_to: "{{ host }}"
  94. # get_url:
  95. # url: "{{ nexus_url }}/repository/{{ nexus_repo_name }}/{{ nexus_repo_name }}.rpm"
  96. # dest: /tmp/
  97. # url_username: "{{ nexus_user }}"
  98. # url_password: "{{ nexus_passwd }}"
  99. # tags:
  100. # - nexus
  101. # - never
  102.  
  103. #- name: "Installing the rpm package using yum"
  104. # when: proxy_status.changed == false
  105. # delegate_to: "{{ host }}"
  106. # yum:
  107. # name: "/tmp/{{ nexus_repo_name }}.rpm"
  108. # disable_gpg_check: true
  109. # state: present
  110. # tags:
  111. # - nexus
  112. # - never
  113. #
  114.  
  115.  
  116. #- name: "Creating a repo in yum.repo.d"
  117. # when: host != "" and proxy_status.changed
  118. # delegate_to: "{{ host }}"
  119. # template:
  120. # src: main.j2
  121. # dest: "/etc/yum.repos.d/{{ nexus_repo_name }}.nexus.repo"
  122. # tags:
  123. # - nexus
  124. # - never
  125.  
  126. - name: "Disabling the scripting feauture in {{nexus_dir}}"
  127. when: script_status.changed
  128. lineinfile:
  129. path: "{{nexus_dir}}/nexus-default.properties"
  130. regexp: "^nexus.scripts.allowCreation=true"
  131. state: absent
  132. tags:
  133. - run_once
  134. - never
  135.  
  136. - name: "Nexus service restart required"
  137. when: script_status.changed
  138. service:
  139. name: nexus
  140. state: restarted
  141. tags:
  142. - run_once
  143. - never
  144.  
  145.  
Advertisement
Add Comment
Please, Sign In to add comment