From 4f86d264b345360fc3e4670c85c7f700403fad43 Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Wed, 18 Jul 2018 19:29:09 +0530 Subject: [PATCH] Initial commit for Ansible based Satellite6 Install and Configure. * Added a partition-disk role * Added playbooks for sat63 and sat64 Signed-off-by: Kedar Bidarkar --- .gitignore | 61 +++++++++++++++++++ CONTRIBUTING.md | 27 ++++++++ README.md | 51 ++++++++++++++++ ansible.cfg | 6 ++ inventory.sample | 5 ++ playbooks/install/satellite_63.yml | 4 ++ playbooks/install/satellite_64.yml | 4 ++ playbooks/upgrade/satellite_upgradeto_63.yml | 0 playbooks/upgrade/satellite_upgradeto_64.yml | 0 requirements.yml | 2 + roles/partition-disk/README.md | 44 +++++++++++++ roles/partition-disk/defaults/main.yml | 2 + roles/partition-disk/handlers/main.yml | 2 + roles/partition-disk/meta/main.yml | 50 +++++++++++++++ .../tasks/extend_root_partition.yaml | 16 +++++ roles/partition-disk/tasks/main.yml | 4 ++ .../tasks/remove_home_partition.yaml | 18 ++++++ roles/partition-disk/tests/inventory | 2 + roles/partition-disk/tests/test.yml | 4 ++ roles/partition-disk/vars/main.yml | 2 + 20 files changed, 304 insertions(+) create mode 100644 .gitignore create mode 100644 CONTRIBUTING.md create mode 100644 README.md create mode 100644 ansible.cfg create mode 100644 inventory.sample create mode 100644 playbooks/install/satellite_63.yml create mode 100644 playbooks/install/satellite_64.yml create mode 100644 playbooks/upgrade/satellite_upgradeto_63.yml create mode 100644 playbooks/upgrade/satellite_upgradeto_64.yml create mode 100644 requirements.yml create mode 100644 roles/partition-disk/README.md create mode 100644 roles/partition-disk/defaults/main.yml create mode 100644 roles/partition-disk/handlers/main.yml create mode 100644 roles/partition-disk/meta/main.yml create mode 100644 roles/partition-disk/tasks/extend_root_partition.yaml create mode 100644 roles/partition-disk/tasks/main.yml create mode 100644 roles/partition-disk/tasks/remove_home_partition.yaml create mode 100644 roles/partition-disk/tests/inventory create mode 100644 roles/partition-disk/tests/test.yml create mode 100644 roles/partition-disk/vars/main.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..44df35e --- /dev/null +++ b/.gitignore @@ -0,0 +1,61 @@ +# Generic Files +*~ +*.swp + +log/ +logs-*/ + +# Byte-compiled / optimized / DLL files +__pycache__/ +venv/ +env/ +*.pyc + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject +.settings/ + + +# Sphinx documentation +docs/_build/ + +# Ansible +*.retry + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..fa06a4f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,27 @@ +Contributing to Ansible-Satellite6 +================================== + +To contribute to ansible-satellite6, please use pull requests on a branch of your own fork. + +After creating your fork on github, you can do: +``` +git clone git@github.com:yourname/ansible-satellite6 +cd ansible-satellite6 +git checkout -b your-branch-name +DO SOME CODING HERE +git add your new files +git commit +git push origin your-branch-name +``` +You will then be able to create a pull request from your commit. + +All fixes or new addition to the project should be accompanied by tests that +should PASS. + +Feel free to raise issues in the repo if you feel a fix or new feature support is needed. + +Standards +========= +Install and Run [ansible-lint](https://github.com/willthames/ansible-lint) against your code changes. + +Also, Install and Run [ansible-review](https://github.com/willthames/ansible-review) against your code changes. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9a0777d --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# ansible-satellite6 + +Ansible playbooks for Satellite 6 systems' management. + +## Setup + +### Prerequisities + +This repository will be Python3.6 based. + +You need Ansible installed. + +We also recommend to install ansible-lint and ansible-review. + +### Configuration + +Befor running any Satellite6 playbooks, + +1. Check and Install the roles from ansible galaxy, if any + + ``` + # ansible-galaxy install -r requirements.yml + ``` + +2. Check and configure required variables + (i.e RHSM Credentials, Satellite setup links and so on). + +3. Make a copy of inventory from inventory.sample file. + + ``` + # cp inventory.sample inventory + ``` + +4. Make sure that SSH Keys are exchanged and placed for the user root. + + ``` + # ssh-copy-id root@sat63-rhel7.example.com + ``` + +## Usage + +### To Install and configure Satellite6: + +``` +$ ansible-playbook -i inventory playbooks/install/satellite_63.yml +``` + +## Contributing + +Please read [CONTRIBUTING.md](https://github.com/SatelliteQE/ansible-satellite6/blob/master/CONTRIBUTING.md) if you wish to contribute. + diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..eea9a56 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,6 @@ +[defaults] +library = foreman-ansible-modules/modules +module_utils = foreman-ansible-modules/module_utils +roles_path = $PWD/galaxy_roles:$PWD/roles +inventory = inventory +retry_files_enabled = False diff --git a/inventory.sample b/inventory.sample new file mode 100644 index 0000000..6dd21d2 --- /dev/null +++ b/inventory.sample @@ -0,0 +1,5 @@ +[sat63] +sat63-rhel7 ansible_ssh_host=sat63-rhel7.example.com ansible_user=root + +[sat64] +sat64-rhel7 ansible_ssh_host=sat64-rhel7.example.com ansible_user=root diff --git a/playbooks/install/satellite_63.yml b/playbooks/install/satellite_63.yml new file mode 100644 index 0000000..cb26cb9 --- /dev/null +++ b/playbooks/install/satellite_63.yml @@ -0,0 +1,4 @@ +--- +- hosts: sat63 + roles: + - partition-disk diff --git a/playbooks/install/satellite_64.yml b/playbooks/install/satellite_64.yml new file mode 100644 index 0000000..11cc542 --- /dev/null +++ b/playbooks/install/satellite_64.yml @@ -0,0 +1,4 @@ +--- +- hosts: sat64 + roles: + - partition-disk diff --git a/playbooks/upgrade/satellite_upgradeto_63.yml b/playbooks/upgrade/satellite_upgradeto_63.yml new file mode 100644 index 0000000..e69de29 diff --git a/playbooks/upgrade/satellite_upgradeto_64.yml b/playbooks/upgrade/satellite_upgradeto_64.yml new file mode 100644 index 0000000..e69de29 diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..6d95021 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,2 @@ +# from galaxy +# - src: username.rolename diff --git a/roles/partition-disk/README.md b/roles/partition-disk/README.md new file mode 100644 index 0000000..e619a79 --- /dev/null +++ b/roles/partition-disk/README.md @@ -0,0 +1,44 @@ +Ansible Role for Partitioning Disk +================================== + +This Ansible role removes home partition and extends root partition. + +Requirements +------------ + +No Requirements are required for this role. + +Role Variables +-------------- + +No variables required for this role. + +Dependencies +------------ + +This role is not dependent upon any galaxy roles. + +Example Playbook +---------------- + +Here is a simple example of partitioning-disk role: + +- hosts: localhost + remote_user: root + roles: + - partition-disk + +License +------- + + GNU GENERAL PUBLIC LICENSE + + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + + +Author Information +------------------ + +This is developed by Satellite QE team, irc: #robottelo on Freenode diff --git a/roles/partition-disk/defaults/main.yml b/roles/partition-disk/defaults/main.yml new file mode 100644 index 0000000..e7e4263 --- /dev/null +++ b/roles/partition-disk/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for partition-disk \ No newline at end of file diff --git a/roles/partition-disk/handlers/main.yml b/roles/partition-disk/handlers/main.yml new file mode 100644 index 0000000..978d0df --- /dev/null +++ b/roles/partition-disk/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for partition-disk \ No newline at end of file diff --git a/roles/partition-disk/meta/main.yml b/roles/partition-disk/meta/main.yml new file mode 100644 index 0000000..eeaf238 --- /dev/null +++ b/roles/partition-disk/meta/main.yml @@ -0,0 +1,50 @@ +galaxy_info: + author: Satellite QE Team + description: Satellite QE Team + company: RedHat + + # 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: GPLv3 + + 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: RHEL + versions: + - 7 + + 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. diff --git a/roles/partition-disk/tasks/extend_root_partition.yaml b/roles/partition-disk/tasks/extend_root_partition.yaml new file mode 100644 index 0000000..c23bd3e --- /dev/null +++ b/roles/partition-disk/tasks/extend_root_partition.yaml @@ -0,0 +1,16 @@ + - name: "Extend root partition LV to all available VG space" + when: item.key in "lv_root" + lvol: + vg: "{{ item.value.vg }}" + lv: "{{ item.key }}" + size: +100%FREE + with_dict: "{{ ansible_lvm.lvs }}" + + - name: "Resize the root filesystem" + when: item.key in "lv_root" + filesystem: + dev: "/dev/{{ item.value.vg }}/{{ item.key }}" + fstype: xfs + resizefs: yes + with_dict: "{{ ansible_lvm.lvs }}" +... diff --git a/roles/partition-disk/tasks/main.yml b/roles/partition-disk/tasks/main.yml new file mode 100644 index 0000000..540ad8e --- /dev/null +++ b/roles/partition-disk/tasks/main.yml @@ -0,0 +1,4 @@ +--- +# tasks file for partition-disk +- include_tasks: remove_home_partition.yaml +- include_tasks: extend_root_partition.yaml diff --git a/roles/partition-disk/tasks/remove_home_partition.yaml b/roles/partition-disk/tasks/remove_home_partition.yaml new file mode 100644 index 0000000..f71d680 --- /dev/null +++ b/roles/partition-disk/tasks/remove_home_partition.yaml @@ -0,0 +1,18 @@ +--- + - name: "Unmount /home partition" + mount: + name: /home + state: unmounted + - name: "Remove /home entry from /etc/fstab" + mount: + name: /home + state: absent + - name: "Remove /home Logical Volume" + when: item.key in "lv_home" + lvol: + vg: "{{ item.value.vg }}" + lv: "{{ item.key }}" + state: absent + force: yes + with_dict: "{{ ansible_lvm.lvs }}" +... diff --git a/roles/partition-disk/tests/inventory b/roles/partition-disk/tests/inventory new file mode 100644 index 0000000..8bbaa16 --- /dev/null +++ b/roles/partition-disk/tests/inventory @@ -0,0 +1,2 @@ +[sat63] +sat63-rhel7 ansible_ssh_host=sat63-rhel7.example.com ansible_user=root diff --git a/roles/partition-disk/tests/test.yml b/roles/partition-disk/tests/test.yml new file mode 100644 index 0000000..cb26cb9 --- /dev/null +++ b/roles/partition-disk/tests/test.yml @@ -0,0 +1,4 @@ +--- +- hosts: sat63 + roles: + - partition-disk diff --git a/roles/partition-disk/vars/main.yml b/roles/partition-disk/vars/main.yml new file mode 100644 index 0000000..99f5a64 --- /dev/null +++ b/roles/partition-disk/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for partition-disk \ No newline at end of file