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.

59 lignes
1.6KB

  1. ---
  2. - hosts: lxd_containers
  3. remote_user: root
  4. gather_facts: false
  5. vars:
  6. lxd_source:
  7. type: image
  8. mode: pull
  9. server: https://images.linuxcontainers.org
  10. protocol: lxd
  11. alias: debian/buster/amd64
  12. tasks:
  13. - name: lxd container installed and started
  14. community.general.lxd_container:
  15. name: "{{inventory_hostname}}"
  16. state: started
  17. source: "{{lxd_source}}"
  18. profiles: ["default"]
  19. wait_for_ipv4_addresses: true
  20. timeout: 600
  21. delegate_to: "{{ lxd_host }}"
  22. - name: install python3 in lxd container
  23. command: lxc exec {{inventory_hostname}} -- apt-get -y install python3
  24. delegate_to: "{{ lxd_host }}"
  25. - hosts: lxd_containers
  26. remote_user: root
  27. connection: lxc_ssh
  28. gather_facts: false
  29. vars:
  30. ansible_host: "{{lxd_host}}"
  31. ansible_ssh_extra_args: "{{inventory_hostname}}"
  32. ssh_ip: "{{ansible_default_ipv6.address}}"
  33. tasks:
  34. - setup:
  35. - name: openssh server
  36. apt:
  37. pkg: openssh-server
  38. - name: make sure host_vars directory is present for host
  39. local_action: file
  40. args:
  41. path: "{{inventory_dir}}/host_vars/{{inventory_hostname}}"
  42. state: directory
  43. - name: record lxd containers IPv6 address for connection in host_vars
  44. local_action: copy
  45. args:
  46. content:
  47. ansible_host: "{{ssh_ip}}"
  48. ssh_ip: "{{ssh_ip}}"
  49. dest: "{{inventory_dir}}/host_vars/{{inventory_hostname}}/lxd_host.auto.json"
  50. - import_role:
  51. name: root_user
  52. - import_role:
  53. name: ssh_host_key
  54. - hosts: lxd_containers
  55. remote_user: root