├── README.md └── jss_upgrade_playbook ├── README.md ├── group_vars └── all ├── hosts ├── roles ├── stop_services │ └── tasks │ │ └── main.yml └── webapp │ ├── files │ ├── DataBase.xml │ ├── README.md │ └── log4j.properties.blank.properties │ └── tasks │ └── main.yml └── site.yml /README.md: -------------------------------------------------------------------------------- 1 | # public-ansible 2 | 3 | Misc Ansible Playbooks 4 | 5 | Click on the projects above to see more. 6 | -------------------------------------------------------------------------------- /jss_upgrade_playbook/README.md: -------------------------------------------------------------------------------- 1 | JSS Upgrade Ansible Playbook 2 | ============================ 3 | 4 | This playbook will update a clustered JSS using files from a manual installation. 5 | 6 | ### Requirements 7 | - Ansible 8 | - httplib2 on all remote hosts. (ubuntu: sudo apt-get install python-httplib2 osx: look it up based on your python install) 9 | 10 | ### Structure 11 | . 12 | ├── group_vars 13 | │ ├── all # Update this file to include the new/old versions you're working with. E.g. 9.7 to 9.72 14 | ├── hosts # Host file for your environment. This example has production and test 15 | ├── roles # Directory for server "roles" 16 | │ ├── stop_services # Load and stress tests 17 | │ │ ├── tasks 18 | │ │ │ ├── main.yml # .yml file to stop tomcat7 service 19 | ├── webapp # Directory for Web App Role 20 | │ ├── files 21 | │ │ ├── 9.7 # JSS Version 9.7 22 | │ │ │ ├── ROOT.war # ROOT.war from Manual Install on version 9.7 23 | │ │ ├── 9.72 # JSS Version 9.72 24 | │ │ │ ├── ROOT.war # ROOT.war from Manual Install on version 9.72 25 | │ │ ├── DataBase.xml # DataBase.xml from YOUR server. Note: This is blank 26 | │ │ ├── log4j.properties # log4j.properties from YOUR server. Note: This is blank 27 | │ ├── tasks 28 | │ │ ├── main.yml # .yml file to perform the upgrade 29 | │ └── site.yml # Main .yml file for playbook. 30 | └── 31 | 32 | ### Steps to Take 33 | - Setup Ansible 34 | - Setup Hosts with Public Key Authentication 35 | - Configure hosts file for your orginization 36 | - configure group_vars/all file to include version you are working with 37 | - Copy the ROOT.war from JSS Manual Install Download into appropriate directory. (Create one if you need) 38 | - Replace DataBase.xml with one from your environment /path/to/tomcat/webapps/ROOT/WEB-INF/xml/DataBase.xml 39 | - Replace log4j.properties with one from your environment /path/to/tomcat/webapps/ROOT/WEB-INF/classes/log4j.properties 40 | - Only run in a test environment until you are comfortable with changes that are being made. 41 | 42 | ### Test run of this playbook 43 | ``` 44 | ansible-playbook -i /path/to/hosts /path/to/site.yml --verbose --check 45 | ``` 46 | Update: 06-06-2015 Added logic to wait on upgrade to complete before continuing to upgrade additoinal webapps. 47 | -------------------------------------------------------------------------------- /jss_upgrade_playbook/group_vars/all: -------------------------------------------------------------------------------- 1 | --- 2 | # Variables listed here are applicable to all host groups 3 | 4 | new_ver: 9.72 5 | old_ver: 9.70 6 | new_war: "{{ new_ver }}/ROOT.war" 7 | db_xml: DataBase.xml 8 | log4j: log4j.properties 9 | xml_dir: /var/lib/tomcat7/webapps/ROOT/WEB-INF/xml/ 10 | classes_dir: /var/lib/tomcat7/webapps/ROOT/WEB-INF/classes/ -------------------------------------------------------------------------------- /jss_upgrade_playbook/hosts: -------------------------------------------------------------------------------- 1 | [test_master] 2 | 172.16.0.1 ansible_ssh_user=admin 3 | 4 | [test_nonmaster] 5 | 172.16.0.2 ansible_ssh_user=admin 6 | 7 | [prod_master] 8 | 10.0.0.1 ansible_ssh_user=admin 9 | 10 | [prod_nonmaster] 11 | 10.0.0.2 ansible_ssh_user=admin 12 | 10.0.0.3 ansible_ssh_user=admin 13 | 10.0.0.4 ansible_ssh_user=admin 14 | 15 | [prod:children] 16 | prod_master 17 | prod_nonmaster -------------------------------------------------------------------------------- /jss_upgrade_playbook/roles/stop_services/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: stop tomcat on all servers 3 | service: name=tomcat7 state=stopped -------------------------------------------------------------------------------- /jss_upgrade_playbook/roles/webapp/files/DataBase.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FredCox3/public-ansible/f4df2161d92a76b60c21f764816aef79aba9e800/jss_upgrade_playbook/roles/webapp/files/DataBase.xml -------------------------------------------------------------------------------- /jss_upgrade_playbook/roles/webapp/files/README.md: -------------------------------------------------------------------------------- 1 | # These files are blank. 2 | ### You must replace with files from your environenment. 3 | ### Otherwise, you will have a bad time. 4 | -------------------------------------------------------------------------------- /jss_upgrade_playbook/roles/webapp/files/log4j.properties.blank.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FredCox3/public-ansible/f4df2161d92a76b60c21f764816aef79aba9e800/jss_upgrade_playbook/roles/webapp/files/log4j.properties.blank.properties -------------------------------------------------------------------------------- /jss_upgrade_playbook/roles/webapp/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: copy updated ROOT.war file to host 3 | copy: src="{{ new_war }}" dest=/tmp mode=0755 4 | - name: stop tomcat service 5 | service: name=tomcat7 state=stopped 6 | - name: wait for tomcat to stop 7 | wait_for: port=8080 state=stopped 8 | - name: backup current state to home directory of ansible_ssh_user 9 | command: /bin/mv /var/lib/tomcat7/webapps/ROOT /home/{{ ansible_ssh_user }}/ROOT_{{ old_ver }}_{{ ansible_date_time.date}}_{{ ansible_date_time.time}} 10 | - name: remove old root.war 11 | file: path=/var/lib/tomcat7/webapps/ROOT.war state=absent 12 | - name: move new ROOT.war into place 13 | command: /bin/mv /tmp/ROOT.war /var/lib/tomcat7/webapps 14 | - name: start tomcat to unpack ROOT.war 15 | service: name=tomcat7 state=started 16 | - name: wait for Tomcat to complete 17 | wait_for: port=8080 state=started delay=15 18 | - name: move DataBase.xml into place 19 | copy: src="{{ db_xml }}" dest={{ xml_dir }} 20 | - name: move log4j.properties into WEB-INF folder. 21 | copy: src="{{ log4j }}" dest={{ classes_dir }} 22 | - name: restart tomcat to pickup Database and logging changes. 23 | service: name=tomcat7 state=restarted 24 | - name: Wait for tomcat to kick in again 25 | wait_for: port=8080 delay=15 connect_timeout=15 26 | - name: giving tomcat a chance to give a proper response 27 | pause: seconds=15 28 | - name: Check if API call contains `401` status code. Wait of up to 1 hour. 29 | uri: url=http://127.0.0.1:8080/JSSResource/activationcode return_content=true status_code=401,200 30 | register: response 31 | until: response.status|int == 401 32 | retries: 240 33 | delay: 15 -------------------------------------------------------------------------------- /jss_upgrade_playbook/site.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook updates JAMF Software's Casper Server in Clustered Environments 3 | 4 | - hosts: test 5 | remote_user: root 6 | sudo: yes 7 | serial: 4 8 | 9 | roles: 10 | - stop_services 11 | 12 | - hosts: test_master 13 | remote_user: root 14 | sudo: yes 15 | serial: 1 16 | 17 | roles: 18 | - webapp 19 | 20 | - hosts: test_nonmaster 21 | remote_user: root 22 | sudo: yes 23 | serial: 2 24 | 25 | roles: 26 | - webapp --------------------------------------------------------------------------------