root@awx:~# apt-get install ansible … … E: ansible
deb http://mirror.yandex.ru/debian/ testing main contrib non-free
root@awx:~# apt-get update
root@awx:~# apt-get install ansible
wget http://ansibleworks.com/releases/awx/setup/awx-setup-latest.tar.gz
root@awx:~# tar xzvf awx-setup-latest.tar.gz
root@awx:~/awx-setup-1.3.1# ls group_vars myhosts README.md roles setup.sh site.yml
root@awx:~/awx-setup-1.3.1# cat setup.sh #!/bin/bash getopts "e:" EXTRA_ARGS if [ "$OPTARG" != "" ]; then echo "Running with extra args: ${OPTARG}" sudo ANSIBLE_ERROR_ON_UNDEFINED_VARS=True ansible-playbook -i myhosts -c local -v -e "$OPTARG" site.yml else sudo ANSIBLE_ERROR_ON_UNDEFINED_VARS=True ansible-playbook -i myhosts -c local -v site.yml fi
getopts "e:" EXTRA_ARGS if [ "$OPTARG" != "" ]; then echo "Running with extra args: ${OPTARG}" ANSIBLE_ERROR_ON_UNDEFINED_VARS=True ansible-playbook -i myhosts -c local -vvv -e "$OPTARG" site.yml else ANSIBLE_ERROR_ON_UNDEFINED_VARS=True ansible-playbook -i myhosts -c local -vvv site.yml fi
root@awx:~/awx-setup-1.3.1# cat site.yml --- # This playbook deploys the AWX application (database, web and worker) to a # single server. - hosts: all tasks: - name: group hosts by distribution group_by: key="{{ ansible_distribution }}-{{ ansible_distribution_version }}" - hosts: RedHat-6*:CentOS-6*:SL-6* user: root roles: - { role: packages_el6 } - { role: postgres, pg_hba_location: "/var/lib/pgsql/data/pg_hba.conf" } - { role: awx_install } - { role: supervisor, sup_init_name: "supervisord", sup_conf_location: "/etc/supervisord.conf" } - { role: httpd, httpd_init_name: "httpd" } - { role: iptables } - { role: misc } - hosts: Ubuntu-12*:Ubuntu-13* user: root roles: - { role: packages_ubuntu } - { role: postgres, pg_hba_location: "/etc/postgresql/9.1/main/pg_hba.conf" } - { role: awx_install } - { role: supervisor, sup_init_name: "supervisor", sup_conf_location: "/etc/supervisor/conf.d/awx.conf" } - { role: httpd, httpd_init_name: "apache2" } - { role: misc }
- hosts: Ubuntu-12*:Ubuntu-13*:Debian*
- { role: postgres, pg_hba_location: "/etc/postgresql/9.3/main/pg_hba.conf" }
root@awx:~/awx-setup-1.3.1# cat roles/packages_ubuntu/tasks/main.yml --- # Tasks to install required packages for awx - name: install ubuntu awx apt repository template: src=awx_repo.j2 dest=/etc/apt/sources.list.d/awx_repo.list - name: install python-pip package for ubuntu 12.04 apt: name=python-pip when: ansible_lsb.codename == "precise" - name: install django 1.5.4 via pip for ubuntu 12.04 pip: name=django version=1.5.4 when: ansible_lsb.codename == "precise" - name: install django via apt for ubuntu 12.10 or later apt: name=python-django when: ansible_lsb.codename != "precise" - name: install required packages via apt apt: name={{ item }} with_items: - apache2 - libapache2-mod-wsgi - postgresql - python-psycopg2 - python-setuptools - python-ldap - supervisor - git - subversion - mercurial - name: install awx package via apt apt: name=awx update_cache=yes force=yes state=latest
root@awx:~/awx-setup-1.3.1# cat roles/packages_ubuntu/templates/awx_repo.j2 deb {{ aw_repo_url }}/deb {{ansible_lsb.codename}} non-free
root@awx:~/awx-setup-1.3.1# cat roles/packages_ubuntu/templates/awx_repo.j2 deb {{ aw_repo_url }}/deb raring non-free
- name: install python-pip package for ubuntu 12.04 apt: name=python-pip when: ansible_lsb.codename == "precise" - name: install django 1.5.4 via pip for ubuntu 12.04 pip: name=django version=1.5.4 when: ansible_lsb.codename == "precise" - name: install django via apt for ubuntu 12.10 or later apt: name=python-django when: ansible_lsb.codename != "precise"
root@awx:~/awx-setup-1.3.1# cat roles/httpd/handlers/main.yml --- # Handlers for common notifications. - name: restart httpd service: name=httpd state=restarted when: ansible_distribution in ["CentOS","RedHat"] - name: restart apache2 service: name=apache2 state=restarted when: ansible_distribution in ["Ubuntu"]
root@awx:~/awx-setup-1.3.1# cat roles/postgres/tasks/main.yml # Tasks for configuring PostgreSQL server. - name: init postgresql command: service postgresql initdb creates=/var/lib/pgsql/data/PG_VERSION when: ansible_distribution != "Ubuntu" tags: postgresql
root@awx:~/awx-setup-1.3.1# ./setup.sh PLAY RECAP ******************************************************************** 127.0.0.1 : ok=30 changed=12 unreachable=0 failed=0
root@awx:~/awx-setup-1.3.1# ls /etc/apache2/conf.d awx.conf awx-plain.conf
mv /etc/apache2/conf.d/awx* /etc/apache2/sites-enabled/
Source: https://habr.com/ru/post/203502/
All Articles