2
2
* @module ansible
3
3
* @description This module provides a set of functions to run ansible playbooks and to create a development environment with ansible installed.
4
4
*/
5
-
6
- import Client , { Directory , Container } from "../../deps.ts" ;
7
- import { connect } from "../../sdk/connect.ts" ;
5
+ import { dag , Directory , Container } from "../../deps.ts" ;
8
6
import { getDirectory } from "./lib.ts" ;
9
7
10
8
export enum Job {
@@ -27,20 +25,16 @@ export async function playbook(
27
25
playbook : string ,
28
26
tag = "latest"
29
27
) : Promise < string > {
30
- let stdout = "" ;
31
- await connect ( async ( client : Client ) => {
32
- const context = await getDirectory ( client , src ) ;
33
- const ctr = client
34
- . pipeline ( Job . playbook )
35
- . container ( )
36
- . from ( `cytopia/ansible:${ tag } ` )
37
- . withDirectory ( "/app" , context )
38
- . withWorkdir ( "/app" )
39
- . withExec ( [ "ansible-playbook" , playbook ] ) ;
28
+ const context = await getDirectory ( src ) ;
29
+ const ctr = dag
30
+ . pipeline ( Job . playbook )
31
+ . container ( )
32
+ . from ( `cytopia/ansible:${ tag } ` )
33
+ . withDirectory ( "/app" , context )
34
+ . withWorkdir ( "/app" )
35
+ . withExec ( [ "ansible-playbook" , playbook ] ) ;
40
36
41
- stdout = await ctr . stdout ( ) ;
42
- } ) ;
43
- return stdout ;
37
+ return ctr . stdout ( ) ;
44
38
}
45
39
46
40
/**
@@ -54,20 +48,16 @@ export async function dev(
54
48
src : string | Directory | undefined = "." ,
55
49
tag = "latest"
56
50
) : Promise < Container | string > {
57
- let id = "" ;
58
- await connect ( async ( client : Client ) => {
59
- const context = await getDirectory ( client , src ) ;
60
- const ctr = client
61
- . pipeline ( Job . dev )
62
- . container ( )
63
- . from ( `cytopia/ansible:${ tag } ` )
64
- . withDirectory ( "/app" , context )
65
- . withWorkdir ( "/app" ) ;
51
+ const context = await getDirectory ( src ) ;
52
+ const ctr = dag
53
+ . pipeline ( Job . dev )
54
+ . container ( )
55
+ . from ( `cytopia/ansible:${ tag } ` )
56
+ . withDirectory ( "/app" , context )
57
+ . withWorkdir ( "/app" ) ;
66
58
67
- await ctr . stdout ( ) ;
68
- id = await ctr . id ( ) ;
69
- } ) ;
70
- return id ;
59
+ await ctr . stdout ( ) ;
60
+ return ctr . id ( ) ;
71
61
}
72
62
73
63
export type JobExec =
0 commit comments