diff --git a/.gitignore b/.gitignore index 99d11dd..f289a46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +# Mac cruft +.DS_Store # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/roles/ansible-role-redhat_satellite6_installation/LICENSE b/roles/ansible-role-redhat_satellite6_installation/LICENSE new file mode 100644 index 0000000..d0b3815 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Julio Villarreal + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/roles/ansible-role-redhat_satellite6_installation/README.md b/roles/ansible-role-redhat_satellite6_installation/README.md new file mode 100644 index 0000000..ca30abf --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/README.md @@ -0,0 +1,85 @@ +Ansible Satellite 6 Install +=========================== + +Role to install and do basic configuration of Red Hat Satellite 6.X. + +INFORMATION +----------- + +This playbook will take a while to run depending the number of repositories to +sync. + +Requirements +------------ + +You will need ansible and all the required subscriptions for RHEL 7 and +Satellite 6. + +* Disk Partitioning to support Satellite Directories. Refer to installation guide. +* DNS +* NTP +* satellite_deployment_manifest_path variable defined +* Satellite Manifest file is hosted on the Ansible Bastion or available via HTTP or FTP somewhere in the environment. + +Role Variables +-------------- + +All variables are in files located in defaults/main.yml + + +Dependencies +------------ + +There is no role dependency for this role. + +Inventory File +---------- + +The example of inventory file for this role is in hosts.target. + +How to run the playbook +------------------------ + +* To run the playbook first you need to create and download the manifest: + +Go to . +- Click "Satellite" +- Click "Register a Satellite" +- Set a Name, select a version and Click "Register" +After this we are going to attach a subscription. +- Click "Attach Subscription" and select the subscription to attach and click +"Attach Selected" +After this we will download the manifest. +- Click "Download manifest" +After this copy the download file inside the /files directory on the role and +name it "satellite_manifest.zip" + +** Then update the variable file in defaults/main.yml in your playbook and +set all mandatory variables for role.: + +You can see example of playbook in playbook_example/config.yml + +* Run the playbook, see README of example playbook + +[playbook readme](./playbook_example/README.rst) + + +License +------- + +MIT + +Author Information +------------------ + +Julio Villarreal Pelegrino more at: http://wwww.juliovillarreal.com + +**Contributors:** + +Petr Balogh - + +Joe Pisciotta - + +Nick Poyant - + +Cameron Wyatt - diff --git a/roles/ansible-role-redhat_satellite6_installation/defaults/main.yml b/roles/ansible-role-redhat_satellite6_installation/defaults/main.yml new file mode 100644 index 0000000..f1509ae --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/defaults/main.yml @@ -0,0 +1,46 @@ +--- +# defaults file for juliovp01.ansible_satellite6 +# Go over variables bellow and pass them in extra vars, playbook vars, +# vars_files, inventory file or whatever which overwrite these values! + + +# main: +# version should be double! Not string! +satellite_deployment_version: 6.2 +satellite_deployment_hostname_short: "sat" +satellite_deployment_hostname_full: "define.your.fqdn" +satellite_deployment_ip_address: "127.0.0.1" + +# install: +satellite_deployment_plugin_packages: [] + +# network: +satellite_deployment_set_network: false +satellite_deployment_net_prefix: "24" +satellite_deployment_subnet_name: "sat_subnet1" +satellite_deployment_plugin_ports: [] + +# registration: +satellite_deployment_rhn_user: "your_rhn_user" +satellite_deployment_rhn_password: "your_rhn_pass" + +# answers: +# specify answers key: value without -- prefix. Keys you can get when you +# use satellite-installer with --help | less for easier finding +satellite_deployment_answers: + 'answer': 'value' + +# configure_satellite: +satellite_deployment_manifest_path: "satellite_manifest.zip" +satellite_deployment_manifest_dest_path: "/root/satellite_manifest.zip" +satellite_deployment_repositories: + - { product_name: 'Red Hat Enterprise Linux Server', name_repo: 'Red Hat Enterprise Linux 7 Server (Kickstart)', rel: '7Server', architecture: 'x86_64', state: enable} + - { product_name: 'Red Hat Enterprise Linux Server', name_repo: 'Red Hat Enterprise Linux 7 Server (RPMs)', rel: '7Server', architecture: 'x86_64', state: enable} + - { product_name: 'Red Hat Enterprise Linux Server', name_repo: 'Red Hat Enterprise Linux 7 Server - RH Common (RPMs)', rel: '7Server', architecture: 'x86_64', state: enable} + - { product_name: 'Red Hat Enterprise Linux Server', name_repo: 'Red Hat Enterprise Linux 7 Server - Optional (RPMs)', rel: '7Server', architecture: 'x86_64', state: enable} + - { product_name: 'Red Hat Enterprise Linux Server', name_repo: 'Red Hat Enterprise Linux 7 Server - Supplementary (RPMs)', rel: '7Server', architecture: 'x86_64', state: enable} + - { product_name: 'Red Hat Enterprise Linux Server', name_repo: 'Red Hat Satellite Tools {{ satellite_deployment_version }} (for RHEL 7 Server) (RPMs)', architecture: 'x86_64', state: enable} + - { product_name: 'Red Hat Enterprise Linux Server', name_repo: 'Red Hat Enterprise Linux 7 Server - Extras (RPMs)', architecture: 'x86_64', state: enable} + +# configure_capsules: +satellite_deployment_puppet_env: "production" diff --git a/roles/ansible-role-redhat_satellite6_installation/handlers/main.yml b/roles/ansible-role-redhat_satellite6_installation/handlers/main.yml new file mode 100644 index 0000000..0e7fc49 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for juliovp01.ansible_satellite6 diff --git a/roles/ansible-role-redhat_satellite6_installation/meta/.galaxy_install_info b/roles/ansible-role-redhat_satellite6_installation/meta/.galaxy_install_info new file mode 100644 index 0000000..2ba0947 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/meta/.galaxy_install_info @@ -0,0 +1 @@ +{install_date: 'Tue Nov 20 15:29:14 2018', version: null} diff --git a/roles/ansible-role-redhat_satellite6_installation/meta/main.yml b/roles/ansible-role-redhat_satellite6_installation/meta/main.yml new file mode 100644 index 0000000..d127b4a --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/meta/main.yml @@ -0,0 +1,19 @@ +galaxy_info: + author: Julio Villarreal + description: Role to Install Red Hat Satellite 6.X + company: your company (optional) + issue_tracker_url: http://github.com/juliovp01/ansible-satellite6-install + license: MIT + min_ansible_version: 1.6 + platforms: + - name: EL + versions: + - 6 + - 7 + + galaxy_tags: + - satellite + - redhat + - install + - configuration + - satellite6 diff --git a/roles/ansible-role-redhat_satellite6_installation/playbook_example/README.md b/roles/ansible-role-redhat_satellite6_installation/playbook_example/README.md new file mode 100644 index 0000000..68e2e5e --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/playbook_example/README.md @@ -0,0 +1,49 @@ +#Satellite deployment + +This playbook install all dependecies required by satellite, register RHN, +install satellite, and create some basic configuration of satellite. + +##Configuration + +You have to specify a lot of variables for satellite-deployment role. +This playbook assumes that you set all these variables in some variable file +and its path you have to pass as parameter: ``satellite-deployment-vars`` + +##Parameters + +- **satellite-deployment-vars** + This parameter should contains path to variable file which will describe + all related variables for your Satellite server. + For example: ./vars/brq-sat-instance.yml which is relative path from + playbook. + You can see examples in [example-vars.yml](./vars/example-vars.yml) + + +##Requirements + +- requirements are defined in [requirements.yml](./requirements.yml) +- for instll all requirements pleas run: +``ansible-galaxy install -f -r requirements.yml -p roles/`` + +##Execution + +- For execute playbook with whole process of deployment run: + ``ansible-playbook -u root -i host.target -e + '{satellite_deployment_vars: ./vars/path_to_your_vars.yml}' ./config.yml`` + +- You can also only update or run specific ation with scpecify appropriate + tags: +``ansible-playbook -u root -i host.target -e + '{satellite_deployment_vars: ./vars/path_to_your_vars.yml}' + --tags=update_stallite ./config.yml`` + +you can also exclude some tags with ``--skip-tags`` parameter of +ansible-playbook command. + +##Tags + +- **firewall**: set firewall +- **install_satellite**: install satellite +- **update_satellite**: update satellite +- **satellite_deployment_repositories**: deploy repositories +- **rhn**: register rhn diff --git a/roles/ansible-role-redhat_satellite6_installation/playbook_example/config.yml b/roles/ansible-role-redhat_satellite6_installation/playbook_example/config.yml new file mode 100644 index 0000000..b17ec0f --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/playbook_example/config.yml @@ -0,0 +1,9 @@ +--- +- hosts: satellite-server + roles: + - role: 'ntp' + ntp_server: + - '0.pool.ntp.org' + - role: "satellite-deployment" + vars_files: + - "{{ satellite_deployment_vars }}" diff --git a/roles/ansible-role-redhat_satellite6_installation/playbook_example/hosts.target b/roles/ansible-role-redhat_satellite6_installation/playbook_example/hosts.target new file mode 100644 index 0000000..1693482 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/playbook_example/hosts.target @@ -0,0 +1,2 @@ +[satellite] +fqdn.of.your.host satellite_deployment_version=6.2 diff --git a/roles/ansible-role-redhat_satellite6_installation/playbook_example/requirements.yml b/roles/ansible-role-redhat_satellite6_installation/playbook_example/requirements.yml new file mode 100644 index 0000000..6436ac1 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/playbook_example/requirements.yml @@ -0,0 +1,7 @@ +--- +- src: bennojoy.ntp + name: ntp +- src: https://github.com/petr-balogh/satellite-deployment.git + # version is draft for testing before we push changes to master + version: draft + name: satellite-deployment diff --git a/roles/ansible-role-redhat_satellite6_installation/playbook_example/vars/example-vars.yml b/roles/ansible-role-redhat_satellite6_installation/playbook_example/vars/example-vars.yml new file mode 100644 index 0000000..701a42f --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/playbook_example/vars/example-vars.yml @@ -0,0 +1,59 @@ +--- +# MY SATELLITE ENVIRONMENT VARIABLES +# main vars +satellite_deployment_hostname_short: "sat" +satellite_deployment_hostname_full: "sat.domain.org" +satellite_deployment_admin_username: "admin" +satellite_deployment_admin_password: "123456" +satellite_deployment_organization: "ORG" +satellite_deployment_location: "BRNO" + +# network +satellite_deployment_ip_address: "10.35.184.33" +satellite_deployment_network_address: "10.35.184.32" +satellite_deployment_net_prefix: "27" +satellite_deployment_gw_address: "10.35.184.62" +satellite_deployment_net_interface: "eth1" +satellite_deployment_dhcp_interface: "{{ satellite_deployment_net_interface }}" +satellite_deployment_dns_interface: "{{ satellite_deployment_net_interface }}" +satellite_deployment_dns_forwarder: "10.35.64.1" +satellite_deployment_dns_zone: "sat.domain.com" +satellite_deployment_dns_reverse_zone: "64.35.10.in-addr.arpa" +satellite_deployment_dhcp_start: "10.35.184.34" +satellite_deployment_dhcp_end: "10.35.184.61" + +#satellite_deployment_plugin_ports + + +# install +satellite_deployment_plugin_packages: + - "foreman-discovery-image" + +# registration vars +satellite_deployment_rhn_user: "rhn_user" +satellite_deployment_rhn_password: "RhnPassW0rD" + +# answers for sattelite installer +satellite_deployment_answers: + "foreman-initial-organization": "{{ satellite_deployment_organization }}" + "foreman-initial-location": "{{ satellite_deployment_location }}" + "foreman-admin-username": "{{ satellite_deployment_admin_username }}" + "foreman-admin-password": "{{ satellite_deployment_admin_password }}" + "foreman-proxy-dns": "true" + "foreman-proxy-dns-interface": "{{ satellite_deployment_dns_interface }}" + "foreman-proxy-dns-zone": "{{ satellite_deployment_dns_zone }}" + "foreman-proxy-dns-forwarders": "{{ satellite_deployment_dns_forwarder }}" + "foreman-proxy-dns-reverse": "{{ satellite_deployment_dns_reverse_zone }}" + "foreman-proxy-dhcp": "true" + "foreman-proxy-dhcp-interface": "{{ satellite_deployment_dhcp_interface }}" + "foreman-proxy-dhcp-range": "{{ satellite_deployment_dhcp_start }} + {{ satellite_deployment_dhcp_end }}" + "foreman-proxy-dhcp-gateway": "{{ satellite_deployment_gw_address }}" + "foreman-proxy-dhcp-nameservers": "{{ satellite_deployment_ip_address }}" + "foreman-proxy-tftp": "true" + "foreman-proxy-tftp-servername": "{{ satellite_deployment_hostname_full }}" + "foreman-proxy-puppetca": "true" + "capsule-puppet": "true" + +# configure_satellite: +satellite_deployment_manifest_path: "http://my.local.server/sat-manifest.zip" diff --git a/roles/ansible-role-redhat_satellite6_installation/tasks/configure_capsule.yml b/roles/ansible-role-redhat_satellite6_installation/tasks/configure_capsule.yml new file mode 100644 index 0000000..a783a43 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tasks/configure_capsule.yml @@ -0,0 +1,81 @@ +--- +#Create an Smart Proxy +- name: "Configure capsule | create an smart proxy on the organization" + become: "yes" + shell: "hammer organization add-smart-proxy --name + {{ satellite_deployment_organization }} --smart-proxy-id 1" + +#Add location to the Smart Proxy +- name: "Configure capsule | add location smart proxy" + command: "hammer location add-smart-proxy --name + {{ satellite_deployment_location }} --smart-proxy-id 1" + +#Create domain +- name: "Configure capsule | add domain" + become: "yes" + shell: "hammer domain create --name='{{ satellite_deployment_dns_zone }}'" + ignore_errors: "yes" + +- name: "Configure capsule | add domain to organization" + become: "yes" + shell: "hammer organization add-domain --name + {{ satellite_deployment_organization }} --domain + {{ satellite_deployment_dns_zone }}" + +#Create the DHCP Subnet +- name: "Configure capsule | create subnet" + become: "yes" + shell: "hammer subnet create --dhcp-id 1 --dns-id 1 --dns-primary + {{ satellite_deployment_ip_address }} --domain-ids 1 + --from {{ satellite_deployment_dhcp_start }} + --to {{ satellite_deployment_dhcp_end }} + --gateway {{ satellite_deployment_gw_address }} + --mask {{ satellite_deployment_netmask }} + --name {{ satellite_deployment_subnet_name }} + --network {{ satellite_deployment_network_address }} --tftp-id 1" + +#Add location to Subnet +- name: "Configure capsule | location add subnet" + become: "yes" + shell: "hammer location add-subnet + --name {{ satellite_deployment_location }} + --subnet {{ satellite_deployment_subnet_name }}" + +#Associate the domain to capsule +- name: "Configure capsule | associate domain capsule" + become: "yes" + shell: "hammer domain update --dns-id 1 --id 1" + +#Add Location to Domain +- name: "Configure capsule | add location domain" + become: "yes" + shell: "hammer location add-domain + --name {{ satellite_deployment_location }} + --domain {{ satellite_deployment_dns_zone }}" + +#Adding the Subnet the Organization +- name: "Configure capsule | add subnet the organization" + become: "yes" + shell: "hammer organization add-subnet + --name {{ satellite_deployment_organization }} + --subnet {{ satellite_deployment_subnet_name }}" + +#Add puppet environment +- name: "Configure capsule | add puppet environment" + become: "yes" + shell: "hammer organization add-environment + --name {{ satellite_deployment_organization }} + --environment {{ satellite_deployment_puppet_env }}" + +#Add location to the environment +- name: "Configure capsule | location add environment" + become: "yes" + shell: "hammer location add-environment + --name {{ satellite_deployment_location }} + --environment {{ satellite_deployment_puppet_env }}" + +#Add location to the organization +- name: "Configure capsule | adding location to organization" + shell: "hammer location add-organization + --name {{ satellite_deployment_location }} + --organization {{ satellite_deployment_organization }}" diff --git a/roles/ansible-role-redhat_satellite6_installation/tasks/configure_satellite.yml b/roles/ansible-role-redhat_satellite6_installation/tasks/configure_satellite.yml new file mode 100644 index 0000000..11b9cc4 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tasks/configure_satellite.yml @@ -0,0 +1,62 @@ +--- +#Create Hammer directory on /root +- name: "Configure | create .hammer directory on user" + file: + path: "~/.hammer" + state: "directory" + mode: "0755" + +#Copy the hammer configuration from template to the .hammer directory +- name: "Configure | set configuration for hammer from template" + template: + src: "hammer_config.yml.j2" + dest: "~/.hammer/cli_config.yml" + +#Copy the manifest +- name: "Configure | copy manifest" + become: "yes" + copy: + src: "{{ satellite_deployment_manifest_path }}" + dest: "{{ satellite_deployment_manifest_dest_path }}" + when: "{{ not satellite_deployment_remote_manifest }}" + +- name: "Configure | copy manifest from remote" + become: "yes" + get_url: + url: "{{ satellite_deployment_manifest_path }}" + dest: "{{ satellite_deployment_manifest_dest_path }}" + when: "{{ satellite_deployment_remote_manifest }}" + +#Upload the manifest to the satellite +- name: "Configure | upload the manifest" + become: "yes" + shell: "hammer subscription upload --file + {{ satellite_deployment_manifest_dest_path }} --organization + {{ satellite_deployment_organization }}" + +#Enabling repos on satellite +- name: "Configure | enable repos" + become: "yes" + shell: "hammer repository-set '{{ item.state }}' --organization + '{{ satellite_deployment_organization }}' + --product '{{ item.product_name }}' --name '{{ item.name_repo }}' + {% if item.rel is defined %} --releasever '{{ item.rel }}' {% endif %} + --basearch '{{ item.architecture}}'" + with_items: "{{ satellite_deployment_repositories }}" + ignore_errors: "yes" + tags: + - "satellite_deployment_repositories" + +#Get the repos ids and sync the repos +- name: "Configure | grab repositories uuid" + shell: "hammer repository list --organization + {{ satellite_deployment_organization }} | grep yum | awk '{print $1}'" + register: "repos" + +- name: "Configure | sync repos on satellite" + shell: "hammer repository synchronize --id '{{ item }}' --organization + {{ satellite_deployment_organization }}" + with_items: "{{ repos.stdout_lines }}" + register: "sync_repos_result" + retries: 3 + until: "{{ sync_repos_result | success }}" diff --git a/roles/ansible-role-redhat_satellite6_installation/tasks/firewall.yml b/roles/ansible-role-redhat_satellite6_installation/tasks/firewall.yml new file mode 100644 index 0000000..d07c9a3 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tasks/firewall.yml @@ -0,0 +1,53 @@ +--- +- name: "Include firewall.yml" + include_vars: "vars/firewall.yml" + tags: + - "firewall" + +#Install firewalld and enable it +- name: "Install firewalld" + become: "yes" + yum: + name: "firewalld" + state: "present" + ignore_errors: "yes" + tags: + - "firewall" + +- name: "Set hostname with hostnamectl" + hostname: + name: "{{ satellite_deployment_hostname_full }}" + tags: + - "firewall" + +- name: "Update /etc/hosts wiht satellite hostname" + lineinfile: + line: "{{ satellite_deployment_ip_address }} + {{ satellite_deployment_hostname_full }} + {{ satellite_deployment_hostname_short }}" + dest: "/etc/hosts" + tags: + - "firewall" + +- name: "Enable Firewalld" + become: "yes" + service: + enabled: "yes" + name: "firewalld" + state: "started" + tags: + - "firewall" + +#Opening firewall ports +- name: "Firewall and hostname | Opening Firewalld ports" + become: "yes" + firewalld: + permanent: "yes" + immediate: "yes" + port: "{{ item }}" + state: "enabled" + with_items: "{{ satellite_deployment_fw_ports + + satellite_deployment_plugin_ports }}" + ignore_errors: "yes" + tags: + - "firewall" diff --git a/roles/ansible-role-redhat_satellite6_installation/tasks/install_satellite.yml b/roles/ansible-role-redhat_satellite6_installation/tasks/install_satellite.yml new file mode 100644 index 0000000..d2456aa --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tasks/install_satellite.yml @@ -0,0 +1,92 @@ +--- +- name: "Include answers vars" + include_vars: "vars/answers.yml" + tags: + - "install_satellite" + - "update_satellite" + +# Copy the Katello answer file +- name: "Install and configure | katello answer file copy" + template: + src: "answerfile.katello-installer.yaml.j2" + dest: "/etc/katello-installer/answers.katello-installer.yaml" + tags: + - "install_satellite" + - "update_satellite" + when: "{{ satellite_deployment_version == 6.1 }}" +- name: "Install and configure | katello answer file copy" + template: + src: "answerfile.katello-installer.yaml.j2" + dest: "/etc/foreman-installer/scenarios.d/satellite-answers.yaml" + tags: + - "install_satellite" + - "update_satellite" + when: "{{ satellite_deployment_version == 6.2 }}" +- name: "Install and configure | katello answer file copy" + template: + src: "answerfile.katello-installer.yaml.j2" + dest: "/etc/satellite-installer/scenarios.d/satellite-answers.yaml" + tags: + - "install_satellite" + - "update_satellite" + when: "{{ satellite_deployment_version == 6.3 }}" + +# Check if service exist for foreman +- name: "Install and configure | check if service exist" + stat: + path: "/etc/init.d/foreman" + register: "foreman_service_file" + become: "yes" + tags: + - "install_satellite" + - "update_satellite" + +#Run the install of Satellite if foreman is installed +- name: "Install and configure | satellite installation" + command: "/usr/sbin/katello-installer" + when: "{{ foreman_service_file.stat.exists == True and + satellite_deployment_version == 6.1 }}" + become: "yes" + tags: + - "install_satellite" + - "update_satellite" + +- name: "Update satellite-installer command" + set_fact: + satellite_deployment_installer_cmd: "{{ satellite_deployment_installer_cmd + }} --{{ item.key }}='{{ item.value }}'" + with_dict: "{{ satellite_deployment_answers }}" + when: "{{ satellite_deployment_version == 6.2 }}" + tags: + - "install_satellite" + - "update_satellite" + +#Run the install of Satellite 6.2 +- name: "Satellite 6.2 installation" + command: "{{ satellite_deployment_installer_cmd }}" + become: "yes" + when: "{{ foreman_service_file.stat.exists == True and + satellite_deployment_version == 6.2 }}" + tags: + - "install_satellite" + - "update_satellite" + +- name: "Update satellite-installer command" + set_fact: + satellite_deployment_installer_cmd: "{{ satellite_deployment_installer_cmd + }} --{{ item.key }}='{{ item.value }}'" + with_dict: "{{ satellite_deployment_answers }}" + when: "{{ satellite_deployment_version == 6.3 }}" + tags: + - "install_satellite" + - "update_satellite" + +#Run the install of Satellite 6.3 +- name: "Satellite 6.3 installation" + command: "{{ satellite_deployment_installer_cmd }}" + become: "yes" + when: "{{ foreman_service_file.stat.exists == True and + satellite_deployment_version == 6.3 }}" + tags: + - "install_satellite" + - "update_satellite" diff --git a/roles/ansible-role-redhat_satellite6_installation/tasks/install_software.yml b/roles/ansible-role-redhat_satellite6_installation/tasks/install_software.yml new file mode 100644 index 0000000..dc36aa3 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tasks/install_software.yml @@ -0,0 +1,21 @@ +--- +- name: "Include install vars" + include_vars: "vars/install.yml" + tags: + - "install" + - "update_satellite" + +#Install the base software +- name: "Install_software" + become: "yes" + yum: + name: "{{ item }}" + state: "latest" + with_items: "{{ + satellite_deployment_packages[satellite_deployment_version | string] + + satellite_deployment_extra_packages + satellite_deployment_plugin_packages + }}" + tags: + - "install" + - "update_satellite" + - "skip_ansible_lint" # ANSIBLE0010 diff --git a/roles/ansible-role-redhat_satellite6_installation/tasks/main.yml b/roles/ansible-role-redhat_satellite6_installation/tasks/main.yml new file mode 100644 index 0000000..557eb2b --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- include: set_facts.yml +- include: registration.yml +- include: network.yml + when: "{{ satellite_deployment_set_network }}" +- include: firewall.yml +- include: install_software.yml +- include: install_satellite.yml +- include: configure_satellite.yml +- include: configure_capsule.yml + when: "{{ satellite_configure_capsule }}" diff --git a/roles/ansible-role-redhat_satellite6_installation/tasks/network.yml b/roles/ansible-role-redhat_satellite6_installation/tasks/network.yml new file mode 100644 index 0000000..ed9120f --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tasks/network.yml @@ -0,0 +1,30 @@ +--- +- name: "Set network interface IP" + shell: "nmcli con mod {{ satellite_deployment_net_interface }} + ipv4.addresses '{{ satellite_deployment_ip_address }}/{{ + satellite_deployment_net_prefix }}'" + tags: + - "set_network" + +- name: "Set network interface GW" + shell: "nmcli con mod {{ satellite_deployment_net_interface }} ipv4.gateway + {{ satellite_deployment_gw_address }}" + tags: + - "set_network" + +- name: "Set network interface method manual" + shell: "nmcli con mod {{ satellite_deployment_net_interface }} ipv4.method + manual" + tags: + - "set_network" + +- name: "Set network interface autoconnect" + shell: "nmcli con mod {{ satellite_deployment_net_interface }} + connection.autoconnect yes" + tags: + - "set_network" + +- name: "Set network interface UP" + shell: "nmcli con up {{ satellite_deployment_net_interface }}" + tags: + - "set_network" diff --git a/roles/ansible-role-redhat_satellite6_installation/tasks/registration.yml b/roles/ansible-role-redhat_satellite6_installation/tasks/registration.yml new file mode 100644 index 0000000..9bde1aa --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tasks/registration.yml @@ -0,0 +1,56 @@ +--- +#Registering system with RHN. +- name: "RHN | registering system with RHN" + redhat_subscription: + state: "present" + username: "{{ satellite_deployment_rhn_user }}" + password: "{{ satellite_deployment_rhn_password }}" + consumer_name: "{{ satellite_deployment_hostname_full }}" + tags: + - "rhn" + - "skip_ansible_lint" # ANSIBLE0012 + + +- name: "Check if Satellite is subscribed" + shell: "/usr/sbin/subscription-manager list --consumed + --matches='*Satellite*' | awk '/Pool ID/ {print $3}'" + tags: + - "rhn" + - "skip_ansible_lint" # ANSIBLE0012 + register: "satellite_deployment_subscribed" + +#Get the pool id for the pool that contains the Satellite product +- name: "RHN | get RHN pool id" + shell: "/usr/sbin/subscription-manager list --all --available + --matches='*Satellite*' | awk '/Pool ID/ {print $3}' | head -1" + tags: + - "rhn" + register: "satellite_deployment_pool_id_command" + ignore_errors: "yes" + when: "{{ satellite_deployment_pool_id is undefined }}" + +- name: "Set pool_id fact" + set_fact: + "satellite_deployment_pool_id": "{{ + satellite_deployment_pool_id_command.stdout }}" + when: "{{ satellite_deployment_pool_id is undefined }}" + +#Attaching the system to the right Pool +- name: "RHN | subscribing to the right pool" + command: "/usr/sbin/subscription-manager attach + --pool={{ satellite_deployment_pool_id }}" + tags: + - "rhn" + - "skip_ansible_lint" # ANSIBLE0012 + ignore_errors: "yes" + when: "{{ satellite_deployment_subscribed.stdout == '' }}" + + +#Enabling the repos +- name: "RHN | enabling the right repos" + command: "/usr/sbin/subscription-manager repos --disable '*' --enable + rhel-7-server-satellite-{{ satellite_deployment_version }}-rpms + --enable rhel-7-server-rpms --enable rhel-server-rhscl-7-rpms" + tags: + - "rhn" + - "skip_ansible_lint" # ANSIBLE0012 diff --git a/roles/ansible-role-redhat_satellite6_installation/tasks/set_facts.yml b/roles/ansible-role-redhat_satellite6_installation/tasks/set_facts.yml new file mode 100644 index 0000000..cde0069 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tasks/set_facts.yml @@ -0,0 +1,16 @@ +--- +- name: "Set remote_manifest fact" + set_fact: + "satellite_deployment_remote_manifest": "{{ + 'http://' in satellite_deployment_manifest_path or + 'ftp://' in satellite_deployment_manifest_path }}" + +- name: 'Execute command to get netmask' + shell: "ipcalc --netmask {{ satellite_deployment_ip_address }}/{{ + satellite_deployment_net_prefix }} | cut -d= -f2" + register: "satellite_deployment_netmas_result" + +- name: "Set netmask fact" + set_fact: + "satellite_deployment_netmask": "{{ + satellite_deployment_netmas_result.stdout }}" diff --git a/roles/ansible-role-redhat_satellite6_installation/templates/answerfile.katello-installer.yaml.j2 b/roles/ansible-role-redhat_satellite6_installation/templates/answerfile.katello-installer.yaml.j2 new file mode 100644 index 0000000..f76d5be --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/templates/answerfile.katello-installer.yaml.j2 @@ -0,0 +1,58 @@ +--- + certs: + generate: true + deploy: true + group: foreman + katello: true + foreman: + organizations_enabled: true + locations_enabled: true + initial_organization: "{{ satellite_deployment_organization }}" + initial_location: "{{ satellite_deployment_location }}" + custom_repo: true + configure_epel_repo: false + configure_scl_repo: false + ssl: true + server_ssl_cert: /etc/pki/katello/certs/katello-apache.crt + server_ssl_key: /etc/pki/katello/private/katello-apache.key + server_ssl_ca: /etc/pki/katello/certs/katello-default-ca.crt + server_ssl_chain: /etc/pki/katello/certs/katello-default-ca.crt + websockets_encrypt: true + websockets_ssl_key: /etc/pki/katello/private/katello-apache.key + websockets_ssl_cert: /etc/pki/katello/certs/katello-apache.crt + unattended: true + admin_username: "{{ satellite_deployment_admin_username }}" + admin_password: "{{ satellite_deployment_admin_password }}" + capsule: + register_in_foreman: true + pulp_master: true + puppet: true + puppetca: true + templates: false + tftp: true + tftp_servername: "{{ satellite_deployment_ip_address }}" + bmc: false + bmc_default_provider: ipmitool + dhcp: true + dhcp_option_domain: + - "{{ satellite_deployment_dns_zone }}" + dhcp_interface: "{{ satellite_deployment_dhcp_interface }}" + dhcp_gateway: "{{ satellite_deployment_gw_address }}" + dhcp_range: "{{ satellite_deployment_dhcp_start }} {{ satellite_deployment_dhcp_end }}" + dhcp_nameservers: "{{ satellite_deployment_ip_address }}" + dns: true + dns_zone: "{{ satellite_deployment_dns_zone }}" + dns_reverse: "{{ satellite_deployment_dns_reverse_zone }}" + dns_inteface: "{{ satellite_deployment_dns_interface }}" + dns_forwarders: + - "{{ satellite_deployment_dns_forwarder }}" + "foreman::plugin::bootdisk": true + "foreman::plugin::discovery": true + "foreman::plugin::hooks": true + "foreman::plugin::tasks": true + "foreman::plugin::chef": false + "foreman::plugin::default_hostgroup": false + "foreman::plugin::puppetdb": false + "foreman::plugin::setup": false + "foreman::plugin::templates": false + "katello::plugin::gutterball": true diff --git a/roles/ansible-role-redhat_satellite6_installation/templates/hammer_config.yml.j2 b/roles/ansible-role-redhat_satellite6_installation/templates/hammer_config.yml.j2 new file mode 100644 index 0000000..44f6c64 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/templates/hammer_config.yml.j2 @@ -0,0 +1,4 @@ +:foreman: + :username: {{ satellite_deployment_admin_username }} + :password: {{ satellite_deployment_admin_password }} + :request_timeout: -1 diff --git a/roles/ansible-role-redhat_satellite6_installation/tests/inventory b/roles/ansible-role-redhat_satellite6_installation/tests/inventory new file mode 100644 index 0000000..d18580b --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/tests/inventory @@ -0,0 +1 @@ +localhost \ No newline at end of file diff --git a/roles/satellite/tests/test.yml b/roles/ansible-role-redhat_satellite6_installation/tests/test.yml similarity index 60% rename from roles/satellite/tests/test.yml rename to roles/ansible-role-redhat_satellite6_installation/tests/test.yml index 1ca83d3..b777a3e 100644 --- a/roles/satellite/tests/test.yml +++ b/roles/ansible-role-redhat_satellite6_installation/tests/test.yml @@ -2,4 +2,4 @@ - hosts: localhost remote_user: root roles: - - satellite \ No newline at end of file + - juliovp01.ansible_satellite6 \ No newline at end of file diff --git a/roles/ansible-role-redhat_satellite6_installation/vars/answers.yml b/roles/ansible-role-redhat_satellite6_installation/vars/answers.yml new file mode 100644 index 0000000..1c48697 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/vars/answers.yml @@ -0,0 +1,5 @@ +--- +# check defaults/main.yml which vars you have to pass. + +satellite_deployment_installer_cmd: "/usr/sbin/satellite-installer + --scenario satellite" diff --git a/roles/ansible-role-redhat_satellite6_installation/vars/firewall.yml b/roles/ansible-role-redhat_satellite6_installation/vars/firewall.yml new file mode 100644 index 0000000..2b0de32 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/vars/firewall.yml @@ -0,0 +1,15 @@ +satellite_deployment_fw_ports: + - 22/tcp + - 80/tcp + - 443/tcp + - 5646/tcp + - 5647/tcp + - 5671/tcp + - 5674/tcp + - 8140/tcp + - 9090/tcp + - 53/udp + - 53/tcp + - 67/udp + - 68/udp + - 69/udp diff --git a/roles/ansible-role-redhat_satellite6_installation/vars/install.yml b/roles/ansible-role-redhat_satellite6_installation/vars/install.yml new file mode 100644 index 0000000..40cd873 --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/vars/install.yml @@ -0,0 +1,18 @@ +--- +satellite_deployment_packages: + "6.1": + - "katello" + "6.2": + - "satellite" + "6.3": + - "satellite" + +satellite_deployment_extra_packages: + - "wget" + - "git" + - "net-tools" + - "bash-completion" + - "screen" + - "vim-*" + +satellite_configure_capsule: true diff --git a/roles/ansible-role-redhat_satellite6_installation/vars/main.yml b/roles/ansible-role-redhat_satellite6_installation/vars/main.yml new file mode 100644 index 0000000..0d298dd --- /dev/null +++ b/roles/ansible-role-redhat_satellite6_installation/vars/main.yml @@ -0,0 +1,2 @@ +--- +# check defaults/main.yml which vars you have to pass. diff --git a/roles/satellite/README.md b/roles/satellite/README.md deleted file mode 100644 index 0348457..0000000 --- a/roles/satellite/README.md +++ /dev/null @@ -1,41 +0,0 @@ -Satellite 6 Install -=================== - -Role to install Satellite 6.x - -Requirements ------------- - -A valid Red Hat Subscription must exist on the target host with entitlements for Red Hat Satellite. - -Role Variables --------------- - -TBD: A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. - -Dependencies ------------- - -TBD: A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. - -Example Playbook ----------------- - - - hosts: satellite - roles: - - { role: ptoal.satellite, mode: satellite } - - - hosts: capsule - roles: - - { role: ptoal.satellite, mode: capsule } - - -License -------- - -BSD - -Author Information ------------------- - -TBD: An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/satellite/defaults/main.yml b/roles/satellite/defaults/main.yml deleted file mode 100644 index 84e4c2e..0000000 --- a/roles/satellite/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# defaults file for satellite \ No newline at end of file diff --git a/roles/satellite/handlers/main.yml b/roles/satellite/handlers/main.yml deleted file mode 100644 index e790d37..0000000 --- a/roles/satellite/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# handlers file for satellite \ No newline at end of file diff --git a/roles/satellite/tasks/main.yml b/roles/satellite/tasks/main.yml deleted file mode 100644 index 8cf69e8..0000000 --- a/roles/satellite/tasks/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# tasks file for satellite \ No newline at end of file diff --git a/roles/satellite/vars/main.yml b/roles/satellite/vars/main.yml deleted file mode 100644 index d87d2bc..0000000 --- a/roles/satellite/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# vars file for satellite \ No newline at end of file diff --git a/toal-common/README.md b/roles/toal-common/README.md similarity index 100% rename from toal-common/README.md rename to roles/toal-common/README.md diff --git a/toal-common/defaults/main.yml b/roles/toal-common/defaults/main.yml similarity index 100% rename from toal-common/defaults/main.yml rename to roles/toal-common/defaults/main.yml diff --git a/toal-common/files/hello.txt b/roles/toal-common/files/hello.txt similarity index 100% rename from toal-common/files/hello.txt rename to roles/toal-common/files/hello.txt diff --git a/roles/toal-common/handlers/main.yml b/roles/toal-common/handlers/main.yml new file mode 100644 index 0000000..b1f0c29 --- /dev/null +++ b/roles/toal-common/handlers/main.yml @@ -0,0 +1,8 @@ +--- +# handlers file for toal-common + + - name: Ovirt Agent Restart + service: + name: ovirt-guest-agent + state: restarted + when: ansible_virtualization_type == "RHEV" \ No newline at end of file diff --git a/roles/satellite/meta/main.yml b/roles/toal-common/meta/main.yml similarity index 100% rename from roles/satellite/meta/main.yml rename to roles/toal-common/meta/main.yml diff --git a/toal-common/tasks/main.yml b/roles/toal-common/tasks/main.yml similarity index 58% rename from toal-common/tasks/main.yml rename to roles/toal-common/tasks/main.yml index 28a3816..e415b03 100644 --- a/toal-common/tasks/main.yml +++ b/roles/toal-common/tasks/main.yml @@ -1,15 +1,15 @@ --- # Ensure that virtual guests have the guest tools installed. + - name: Guest Tools Repository + rhsm_repository: + name: rhel-7-server-rh-common-rpms + state: present + - name: Install ovirt-guest-agent on RHV Guests yum: name: ovirt-guest-agent state: present when: ansible_virtualization_type == "RHEV" - - - name: ovirt-guest-agent service is running - service: - name: ovirt-guest-agent - state: running - when: ansible_virtualization_type == "RHEV" + notify: Ovirt Agent Restart diff --git a/roles/satellite/tests/inventory b/roles/toal-common/tests/inventory similarity index 100% rename from roles/satellite/tests/inventory rename to roles/toal-common/tests/inventory diff --git a/toal-common/tests/test.yml b/roles/toal-common/tests/test.yml similarity index 100% rename from toal-common/tests/test.yml rename to roles/toal-common/tests/test.yml diff --git a/toal-common/vars/main.yml b/roles/toal-common/vars/main.yml similarity index 100% rename from toal-common/vars/main.yml rename to roles/toal-common/vars/main.yml diff --git a/site.yml b/site.yml index d259100..f46efd9 100644 --- a/site.yml +++ b/site.yml @@ -1,6 +1,73 @@ # Toal Lab Site Playbook -- name: Virtual Machine setup +- name: Create VMs + hosts: vms + connection: local + gather_facts: no + vars: + # Hack to work around virtualenv python interpreter + ansible_python_interpreter: "{{ ansible_playbook_python }}" + + tasks: + - name: Create Satellite VM in RHV + ovirt_vm: + name: "{{ vm_name }}" + state: running + memory: "{{ vm_memory }}" + +- name: Configure Satellite Servers + hosts: satellite + become: true + roles: + - ansible-role-redhat_satellite6_installation + pre_tasks: + - name: Register to RHSM and connect to Satellite Subscription. + tags: rhsm + redhat_subscription: + state: present + auto_attach: yes + username: "{{ rhn_username }}" + password: "{{ rhn_password }}" + pool: "^Red Hat Satellite Infrastructure Subscription$" + + - name: Required Satellite Repos + tags: rhsm + rhsm_repository: + name: "{{ item }}" + state: present + with_items: + - rhel-7-server-rpms + - rhel-server-rhscl-7-rpms + - rhel-7-server-satellite-6.4-rpms + - rhel-7-server-satellite-maintenance-6-rpms + - rhel-7-server-ansible-2.6-rpms + - rhel-7-server-rh-common-rpms + + - name: Ensure latest versions of packages + yum: + name: "*" + state: latest + + - name: Latest Version of Satellite + yum: + name: satellite + state: latest + + - name: Chronyd Installed + yum: + name: chrony + state: latest + notify: Restart Chrony + + - name: Latest Version of SOS + yum: + name: sos + state: latest + + + + +- name: Common Lab Machine Setup hosts: all become: true roles: - - toal-common \ No newline at end of file + - toal-common diff --git a/t b/t deleted file mode 100644 index 1d9af14..0000000 --- a/t +++ /dev/null @@ -1,13 +0,0 @@ ---- -- hosts: web - name: Install the apache web service - become: yes - tasks: - - name: install apache - yum: - name: httpd - state: present - - name: start httpd - service: - name: httpd - state: started diff --git a/toal-common/handlers/main.yml b/toal-common/handlers/main.yml deleted file mode 100644 index f052b7e..0000000 --- a/toal-common/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# handlers file for toal-common \ No newline at end of file diff --git a/toal-common/meta/main.yml b/toal-common/meta/main.yml deleted file mode 100644 index 7223799..0000000 --- a/toal-common/meta/main.yml +++ /dev/null @@ -1,57 +0,0 @@ -galaxy_info: - author: your name - description: your description - company: your company (optional) - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker - - # Some suggested licenses: - # - BSD (default) - # - MIT - # - GPLv2 - # - GPLv3 - # - Apache - # - CC-BY - license: license (GPLv2, CC-BY, etc) - - min_ansible_version: 1.2 - - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # Optionally specify the branch Galaxy will use when accessing the GitHub - # repo for this role. During role install, if no tags are available, - # Galaxy will use this branch. During import Galaxy will access files on - # this branch. If Travis integration is configured, only notifications for this - # branch will be accepted. Otherwise, in all cases, the repo's default branch - # (usually master) will be used. - #github_branch: - - # - # platforms is a list of platforms, and each platform has a name and a list of versions. - # - # platforms: - # - name: Fedora - # versions: - # - all - # - 25 - # - name: SomePlatform - # versions: - # - all - # - 1.0 - # - 7 - # - 99.99 - - galaxy_tags: [] - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. - -dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. \ No newline at end of file diff --git a/toal-common/tests/inventory b/toal-common/tests/inventory deleted file mode 100644 index 878877b..0000000 --- a/toal-common/tests/inventory +++ /dev/null @@ -1,2 +0,0 @@ -localhost -