Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

60 строки
1.7KB

  1. ---
  2. - hosts: lxd_containers
  3. remote_user: root
  4. gather_facts: false
  5. vars:
  6. lxd_container_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_container_source}}"
  18. config: "{{lxd_container_config}}"
  19. profiles: ["default"]
  20. wait_for_ipv4_addresses: true
  21. timeout: 600
  22. delegate_to: "{{ lxd_host }}"
  23. - name: install python3 in lxd container
  24. command: lxc exec {{inventory_hostname}} -- apt-get -y install python3
  25. delegate_to: "{{ lxd_host }}"
  26. - hosts: lxd_containers
  27. remote_user: root
  28. connection: lxc_ssh
  29. gather_facts: false
  30. vars:
  31. ansible_host: "{{lxd_host}}"
  32. ansible_ssh_extra_args: "{{inventory_hostname}}"
  33. ssh_ip: "{{ansible_default_ipv6.address}}"
  34. tasks:
  35. - setup:
  36. - name: openssh server
  37. apt:
  38. pkg: openssh-server
  39. - name: make sure host_vars directory is present for host
  40. local_action: file
  41. args:
  42. path: "{{inventory_dir}}/host_vars/{{inventory_hostname}}"
  43. state: directory
  44. - name: record lxd containers IPv6 address for connection in host_vars
  45. local_action: copy
  46. args:
  47. content:
  48. ansible_host: "{{ssh_ip}}"
  49. ssh_ip: "{{ssh_ip}}"
  50. dest: "{{inventory_dir}}/host_vars/{{inventory_hostname}}/lxd_host.auto.json"
  51. - import_role:
  52. name: root_user
  53. - import_role:
  54. name: ssh_host_key
  55. - hosts: lxd_containers
  56. remote_user: root