Old ansible configuration for servers
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

dmdirc-buildagent.yml 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ---
  2. # Sets up accounts for DMDirc build agents
  3. - hosts: dmdirc-buildagents
  4. sudo: yes
  5. user: root
  6. vars:
  7. home_dir: /home/{{ teamcity_user }}/
  8. agent_sh: "{{ home_dir }}/bin/agent.sh"
  9. conf: "{{ home_dir }}/conf/buildAgent.properties"
  10. pid: "{{ home_dir }}/logs/buildAgent.pid"
  11. temp_key: /etc/ansible/data/auto/keys/teamcity-{{ ansible_hostname }}
  12. htaccess: /home/dmdirc/www/private/.htaccess
  13. header: "# {{ inventory_hostname }}"
  14. tasks:
  15. - name: create teamcity user
  16. user: name={{ teamcity_user }} generate_ssh_key=yes
  17. - name: install pre-requisites
  18. apt: pkg={{ item }}
  19. with_items:
  20. - ant
  21. - git
  22. - unzip
  23. - nsis
  24. - dpkg-dev
  25. - cdbs
  26. - debhelper
  27. - javahelper
  28. - mkisofs
  29. - alien
  30. - fakeroot
  31. - include: includes/install-java8
  32. - name: fetch agent zip
  33. sudo_user: "{{ teamcity_user }}"
  34. get_url: url=http://teamcity.dmdirc.com/update/buildAgent.zip dest={{ home_dir }}
  35. - name: unpack agent zip
  36. sudo_user: "{{ teamcity_user }}"
  37. command: creates={{ agent_sh }} chdir={{ home_dir }} unzip -o buildAgent.zip
  38. - name: make agent.sh executable
  39. sudo_user: "{{ teamcity_user }}"
  40. file: path={{ agent_sh }} mode=0755
  41. - name: copy default configuration
  42. sudo_user: "{{ teamcity_user }}"
  43. command: creates={{ conf }} chdir={{ home_dir }}/conf cp buildAgent.dist.properties buildAgent.properties
  44. - name: set teamcity server URL
  45. sudo_user: "{{ teamcity_user }}"
  46. lineinfile: dest={{ conf }} regexp=^serverUrl= line=serverUrl=http://teamcity.dmdirc.com/
  47. - name: set build agent name
  48. sudo_user: "{{ teamcity_user }}"
  49. lineinfile: dest={{ conf }} regexp=^name= line=name={{ inventory_hostname }}
  50. - name: add dmdirc.com to known hosts
  51. sudo_user: "{{ teamcity_user }}"
  52. lineinfile: dest={{ home_dir }}/.ssh/known_hosts regexp=^dmdirc.com
  53. line="dmdirc.com,85.234.138.10 {{ hostvars['renji.org.uk']['ssh_public_key'] }}"
  54. - name: retrieve public key
  55. sudo_user: "{{ teamcity_user }}"
  56. fetch: src={{ home_dir }}/.ssh/id_rsa.pub dest={{ temp_key }} flat=yes
  57. - name: add SSH key to dmdirc-artifacts
  58. delegate_to: renji.org.uk
  59. authorized_key: key="{{ lookup('file', temp_key) }}" user=dmdirc-artifacts
  60. - name: add header to private .htaccess file
  61. delegate_to: renji.org.uk
  62. sudo_user: dmdirc
  63. lineinfile: dest={{ htaccess }} line="{{ header }}" insertafter="^# Build agents:"
  64. - name: add all IP addresses to .htaccess file
  65. delegate_to: renji.org.uk
  66. sudo_user: dmdirc
  67. lineinfile: dest={{ htaccess }} line="Allow from {{ item }}" insertafter="{{ header }}"
  68. with_items: ansible_all_ipv4_addresses
  69. - include: includes/launch-app pid_file="{{ pid }}" start_command="{{ agent_sh }} start"
  70. sudo_user: "{{ teamcity_user }}"