From 54fd01e56ef3ead9cb96d0b532dd7423793a47fc Mon Sep 17 00:00:00 2001 From: Johnathan Kupferer Date: Tue, 14 May 2019 16:27:00 +0000 Subject: [PATCH 1/3] Fix SSH config Reorder ssh-bastion.cfg settings Switch ansible.cfg to use ssh-bastion.cfg --- ansible.cfg | 4 ++-- ssh-bastion.cfg | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ansible.cfg b/ansible.cfg index 7d6502e..785f60d 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -3,6 +3,6 @@ inventory = hosts retry_files_enabled = false [ssh_connection] -#ssh_args = -F ./ssh-bastion.cfg -ssh_args = -F ./ssh-laptop.cfg +ssh_args = -F ./ssh-bastion.cfg +#ssh_args = -F ./ssh-laptop.cfg # Uncomment above to work from remote control node diff --git a/ssh-bastion.cfg b/ssh-bastion.cfg index 5d4b0d0..30736f4 100644 --- a/ssh-bastion.cfg +++ b/ssh-bastion.cfg @@ -1,9 +1,9 @@ -Match User ec2-user - IdentityFile ./6400key.pem - Host *.internal User ec2-user StrictHostKeyChecking no ControlMaster auto ControlPath /tmp/%h-%r ControlPersist 5m + +Match User ec2-user + IdentityFile ~/.ssh/466ekey.pem From 29f74b93a40a32a03e4c6804ce308d340045a1fc Mon Sep 17 00:00:00 2001 From: Johnathan Kupferer Date: Tue, 14 May 2019 16:49:41 +0000 Subject: [PATCH 2/3] Move common config to role --- main.yml | 10 ++--- roles/common/README.md | 38 ++++++++++++++++++ roles/common/defaults/main.yml | 2 + roles/common/handlers/main.yml | 2 + roles/common/meta/main.yml | 14 +++++++ roles/common/tasks/.main.yml.swp | Bin 0 -> 12288 bytes roles/common/tasks/main.yml | 2 + roles/common/tasks/yum-repos.yml | 6 +++ .../templates/open_three-tier-app.repo.j2 | 32 +++++++++++++++ roles/common/tests/inventory | 2 + roles/common/tests/test.yml | 5 +++ roles/common/vars/main.yml | 2 + 12 files changed, 108 insertions(+), 7 deletions(-) create mode 100644 roles/common/README.md create mode 100644 roles/common/defaults/main.yml create mode 100644 roles/common/handlers/main.yml create mode 100644 roles/common/meta/main.yml create mode 100644 roles/common/tasks/.main.yml.swp create mode 100644 roles/common/tasks/main.yml create mode 100644 roles/common/tasks/yum-repos.yml create mode 100644 roles/common/templates/open_three-tier-app.repo.j2 create mode 100644 roles/common/tests/inventory create mode 100644 roles/common/tests/test.yml create mode 100644 roles/common/vars/main.yml diff --git a/main.yml b/main.yml index 49e92b5..110220c 100644 --- a/main.yml +++ b/main.yml @@ -13,17 +13,13 @@ # Bare variables # No use of handlers -- name: configuration +- name: Common configuration hosts: all gather_facts: false # remove later! speeds up testing become: true + roles: + - common - tasks: - - name: enable repos - template: - src: ./open_three-tier-app.repo - dest: /etc/yum.repos.d/open_three-tier-app.repo - mode: 0644 - name: deploy haproxy hosts: frontends diff --git a/roles/common/README.md b/roles/common/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/common/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +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 +------------ + +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 +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/common/defaults/main.yml b/roles/common/defaults/main.yml new file mode 100644 index 0000000..fa30550 --- /dev/null +++ b/roles/common/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for common \ No newline at end of file diff --git a/roles/common/handlers/main.yml b/roles/common/handlers/main.yml new file mode 100644 index 0000000..c6a8f0c --- /dev/null +++ b/roles/common/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for common \ No newline at end of file diff --git a/roles/common/meta/main.yml b/roles/common/meta/main.yml new file mode 100644 index 0000000..79addf8 --- /dev/null +++ b/roles/common/meta/main.yml @@ -0,0 +1,14 @@ +galaxy_info: + author: Johnathan Kupferer + description: Three tier app common + company: Red Hat + license: license (GPLv2, CC-BY, etc) + min_ansible_version: 2.7 + platforms: + - name: GenericLinux + versions: + - all + + galaxy_tags: [] + +dependencies: [] diff --git a/roles/common/tasks/.main.yml.swp b/roles/common/tasks/.main.yml.swp new file mode 100644 index 0000000000000000000000000000000000000000..ce5c374cd8c6a10231db333a6fd168940f5cddb4 GIT binary patch literal 12288 zcmeI&Jx;?g6bJBEhHeN118acUNr9>$CN{*tNGBxZB#sF6M-)3MUEmBHhJl5HAaMr{ zz<^UFq9P0(SStROEX($Lw%%`x;&?E=xD1ZNA^EmR^!)L5y>ounpZ1CFCRLG%Qm|5_ zx7>w^QFT|BZk2tZ(Yfy!m+#GJ|ZCi0SG_<0uX=z1Rwx` zl^1YDj~;y$YfUBX*lXtPxblUf00=+;0uX=z1Rwwb2tWV=5P-lx7T_t-%LdWA@Ad!x z_WS>{S$p;4Q@w`<0SG_<0uX=z1Rwwb2tWV=5P-nn39um7iL6p_Gk*Yo>ZjImDVa5y doAOf3U&A+1o#0ue{A>Nf*u|*tvwmzdMqfGRV(|a~ literal 0 HcmV?d00001 diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml new file mode 100644 index 0000000..c31a86a --- /dev/null +++ b/roles/common/tasks/main.yml @@ -0,0 +1,2 @@ +--- +- include_tasks: yum-repos.yml diff --git a/roles/common/tasks/yum-repos.yml b/roles/common/tasks/yum-repos.yml new file mode 100644 index 0000000..0b13522 --- /dev/null +++ b/roles/common/tasks/yum-repos.yml @@ -0,0 +1,6 @@ +--- +- name: enable repos + template: + src: open_three-tier-app.repo.j2 + dest: /etc/yum.repos.d/open_three-tier-app.repo + mode: u=rw,go=r diff --git a/roles/common/templates/open_three-tier-app.repo.j2 b/roles/common/templates/open_three-tier-app.repo.j2 new file mode 100644 index 0000000..3f368d6 --- /dev/null +++ b/roles/common/templates/open_three-tier-app.repo.j2 @@ -0,0 +1,32 @@ +[rhel-7-server-rpms] +name=Red Hat Enterprise Linux 7 +baseurl=http://admin.na.shared.opentlc.com/repos/ocp/3.6/rhel-7-server-rpms +enabled=1 +gpgcheck=0 + +[rhel-7-server-rh-common-rpms] +name=Red Hat Enterprise Linux 7 Common +baseurl=http://admin.na.shared.opentlc.com/repos/ocp/3.6/rhel-7-server-rh-common-rpms +enabled=1 +gpgcheck=0 + +[rhel-7-server-extras-rpms] +name=Red Hat Enterprise Linux 7 Extras +baseurl=http://admin.na.shared.opentlc.com/repos/ocp/3.6/rhel-7-server-extras-rpms +enabled=1 +gpgcheck=0 + +[rhel-7-server-optional-rpms] +name=Red Hat Enterprise Linux 7 Optional +baseurl=http://admin.na.shared.opentlc.com/repos/ocp/3.6/rhel-7-server-optional-rpms +enabled=1 +gpgcheck=0 + +[epel] +name=Extra Packages for Enterprise Linux 7 - $basearch +baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch +mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch +failovermethod=priority +enabled=1 +gpgcheck=0 +#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 diff --git a/roles/common/tests/inventory b/roles/common/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/common/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/common/tests/test.yml b/roles/common/tests/test.yml new file mode 100644 index 0000000..8d24282 --- /dev/null +++ b/roles/common/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - common \ No newline at end of file diff --git a/roles/common/vars/main.yml b/roles/common/vars/main.yml new file mode 100644 index 0000000..feaa92f --- /dev/null +++ b/roles/common/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for common \ No newline at end of file From 21f4f90ed55e176c63b45d4232ec22c4cbe36664 Mon Sep 17 00:00:00 2001 From: Johnathan Kupferer Date: Tue, 14 May 2019 17:06:22 +0000 Subject: [PATCH 3/3] Add yamllint and fix style --- .gitignore | 2 +- .yamllint | 9 ++++++ cleanup.yml | 46 +++++++++++++++---------------- roles/common/defaults/main.yml | 2 +- roles/common/handlers/main.yml | 2 +- roles/common/meta/main.yml | 1 + roles/common/tasks/.main.yml.swp | Bin 12288 -> 0 bytes roles/common/tests/inventory | 2 -- roles/common/tests/test.yml | 5 ---- roles/common/vars/main.yml | 2 +- 10 files changed, 37 insertions(+), 34 deletions(-) create mode 100644 .yamllint delete mode 100644 roles/common/tasks/.main.yml.swp delete mode 100644 roles/common/tests/inventory delete mode 100644 roles/common/tests/test.yml diff --git a/.gitignore b/.gitignore index 100afae..ff43108 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ */env *.pem */open_three-tier-app.repo - +.*.swp diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..bc764cb --- /dev/null +++ b/.yamllint @@ -0,0 +1,9 @@ +--- +extends: default +rules: + comments: disable + comments-indentation: disable + indentation: + indent-sequences: false + line-length: + max: 120 diff --git a/cleanup.yml b/cleanup.yml index c37588e..1a6b4f3 100644 --- a/cleanup.yml +++ b/cleanup.yml @@ -5,33 +5,33 @@ become: true vars: three_tier_packages: - - httpie - - python-pip - - haproxy - - tomcat - - postgresql-server + - httpie + - python-pip + - haproxy + - tomcat + - postgresql-server tasks: - - name: reverse the enabling of sudo without tty for some ansible commands - replace: - path: /etc/sudoers - regexp: 'Defaults\s*!requiretty' - replace: '^Defaults requiretty' - backup: yes + - name: reverse the enabling of sudo without tty for some ansible commands + replace: + path: /etc/sudoers + regexp: 'Defaults\s*!requiretty' + replace: '^Defaults requiretty' + backup: true - - name: Remove the repo file - file: - state: absent - path: /etc/yum.repos.d/open_three-tier-app.repo + - name: Remove the repo file + file: + state: absent + path: /etc/yum.repos.d/open_three-tier-app.repo - - name: Remove base tools and three tier app packages - yum: - name: "{{ three_tier_packages }}" - state: absent + - name: Remove base tools and three tier app packages + yum: + name: "{{ three_tier_packages }}" + state: absent - - name: Remove index.html - file: - path: /tmp/index.html - state: absent + - name: Remove index.html + file: + path: /tmp/index.html + state: absent ... diff --git a/roles/common/defaults/main.yml b/roles/common/defaults/main.yml index fa30550..205c4a1 100644 --- a/roles/common/defaults/main.yml +++ b/roles/common/defaults/main.yml @@ -1,2 +1,2 @@ --- -# defaults file for common \ No newline at end of file +# defaults file for common diff --git a/roles/common/handlers/main.yml b/roles/common/handlers/main.yml index c6a8f0c..2662adc 100644 --- a/roles/common/handlers/main.yml +++ b/roles/common/handlers/main.yml @@ -1,2 +1,2 @@ --- -# handlers file for common \ No newline at end of file +# handlers file for common diff --git a/roles/common/meta/main.yml b/roles/common/meta/main.yml index 79addf8..ab335ef 100644 --- a/roles/common/meta/main.yml +++ b/roles/common/meta/main.yml @@ -1,3 +1,4 @@ +--- galaxy_info: author: Johnathan Kupferer description: Three tier app common diff --git a/roles/common/tasks/.main.yml.swp b/roles/common/tasks/.main.yml.swp deleted file mode 100644 index ce5c374cd8c6a10231db333a6fd168940f5cddb4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&Jx;?g6bJBEhHeN118acUNr9>$CN{*tNGBxZB#sF6M-)3MUEmBHhJl5HAaMr{ zz<^UFq9P0(SStROEX($Lw%%`x;&?E=xD1ZNA^EmR^!)L5y>ounpZ1CFCRLG%Qm|5_ zx7>w^QFT|BZk2tZ(Yfy!m+#GJ|ZCi0SG_<0uX=z1Rwx` zl^1YDj~;y$YfUBX*lXtPxblUf00=+;0uX=z1Rwwb2tWV=5P-lx7T_t-%LdWA@Ad!x z_WS>{S$p;4Q@w`<0SG_<0uX=z1Rwwb2tWV=5P-nn39um7iL6p_Gk*Yo>ZjImDVa5y doAOf3U&A+1o#0ue{A>Nf*u|*tvwmzdMqfGRV(|a~ diff --git a/roles/common/tests/inventory b/roles/common/tests/inventory deleted file mode 100644 index 878877b..0000000 --- a/roles/common/tests/inventory +++ /dev/null @@ -1,2 +0,0 @@ -localhost - diff --git a/roles/common/tests/test.yml b/roles/common/tests/test.yml deleted file mode 100644 index 8d24282..0000000 --- a/roles/common/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - common \ No newline at end of file diff --git a/roles/common/vars/main.yml b/roles/common/vars/main.yml index feaa92f..fed6035 100644 --- a/roles/common/vars/main.yml +++ b/roles/common/vars/main.yml @@ -1,2 +1,2 @@ --- -# vars file for common \ No newline at end of file +# vars file for common