split subtasks into separate files
This commit is contained in:
19
roles/docker/tasks/install_docker.yml
Normal file
19
roles/docker/tasks/install_docker.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
- name: docker | install docker | get convenience script
|
||||||
|
get_url:
|
||||||
|
url: "https://get.docker.com"
|
||||||
|
dest: "/tmp/get-docker.sh"
|
||||||
|
mode: "0777" # not required. The permissions the resulting file or directory should have. For those used to I(/usr/bin/chmod) remember that modes are actually octal numbers. You must either add a leading zero so that Ansible's YAML parser knows it is an octal number (like C(0644) or C(01777)) or quote it (like C('644') or C('1777')) so Ansible receives a string and can do its own conversion from string into number. Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results. As of Ansible 1.8, the mode may be specified as a symbolic mode (for example, C(u+rwx) or C(u=rw,g=r,o=r)). As of Ansible 2.6, the mode may also be the special string C(preserve). When set to C(preserve) the file will be given the same permissions as the source file.
|
||||||
|
|
||||||
|
- name: docker | install docker | execute convenience script
|
||||||
|
shell:
|
||||||
|
cmd: "/tmp/get-docker.sh"
|
||||||
|
|
||||||
|
- name: docker | install docker | cleanup
|
||||||
|
file:
|
||||||
|
path: "/tmp/get-docker.sh" # required. Path to the file being managed.
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: docker | install docker-compose
|
||||||
|
package:
|
||||||
|
name: docker-compose
|
||||||
|
state: latest
|
||||||
11
roles/docker/tasks/install_portainer.yml
Normal file
11
roles/docker/tasks/install_portainer.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
- name: docker | install portainer | create directory
|
||||||
|
file:
|
||||||
|
path: "/opt/docker/portainer"
|
||||||
|
state: present
|
||||||
|
owner: "root" # not required. Name of the user that should own the file/directory, as would be fed to I(chown).
|
||||||
|
|
||||||
|
- name: docker | install portainer | docker run
|
||||||
|
command:
|
||||||
|
cmd: "docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /opt/docker/portainer/data:/data portainer/portainer:latest" # not required. The command to run.
|
||||||
|
creates: /opt/docker/portainer/data
|
||||||
@@ -6,22 +6,6 @@
|
|||||||
- include_vars: "{{ ansible_fqdn }}.yml"
|
- include_vars: "{{ ansible_fqdn }}.yml"
|
||||||
ignore_errors: True
|
ignore_errors: True
|
||||||
|
|
||||||
- name: docker | install docker | get convenience script
|
- import_tasks: install_docker.yml
|
||||||
get_url:
|
- import_tasks: install_portainer.yml
|
||||||
url: "https://get.docker.com"
|
when: run_portainer == true
|
||||||
dest: "/tmp/get-docker.sh"
|
|
||||||
mode: "0777" # not required. The permissions the resulting file or directory should have. For those used to I(/usr/bin/chmod) remember that modes are actually octal numbers. You must either add a leading zero so that Ansible's YAML parser knows it is an octal number (like C(0644) or C(01777)) or quote it (like C('644') or C('1777')) so Ansible receives a string and can do its own conversion from string into number. Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results. As of Ansible 1.8, the mode may be specified as a symbolic mode (for example, C(u+rwx) or C(u=rw,g=r,o=r)). As of Ansible 2.6, the mode may also be the special string C(preserve). When set to C(preserve) the file will be given the same permissions as the source file.
|
|
||||||
|
|
||||||
- name: docker | install docker | execute convenience script
|
|
||||||
shell:
|
|
||||||
cmd: "/tmp/get-docker.sh"
|
|
||||||
|
|
||||||
- name: docker | install docker | cleanup
|
|
||||||
file:
|
|
||||||
path: "/tmp/get-docker.sh" # required. Path to the file being managed.
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: docker | install docker-compose
|
|
||||||
package:
|
|
||||||
name: docker-compose
|
|
||||||
state: latest
|
|
||||||
Reference in New Issue
Block a user