freezing-vase-18205
01/19/2024, 7:56 AMpulumi_command.local
to be dependent on a pulumi.Output
?
Imagine that I have to ansible playbooks pl1
and pl2
that I need to run in sequential order (can’t be part of the same command)
and therefore I need pl2
to not be started before pl1
finishes.
What would be the dependency tie up between the two?
Currently I do some wanky job of creating a function that runs pl1
and returns a bool pulumi.Output and then I use this output in the Environment
as a dependency:
def deploy(depends_on: List[pulumi.Output]):
local.Command(
"kubeone apply",
local.CommandArgs(
create="kubeone apply -y -m kubeone.yaml -c credentials.yaml && cp *-kubeconfig ~/.kube",
environment={
"PULUMI_DEPENDS_ON": f"{depends_on[0]} {depends_on[1]}",
},
triggers=depends_on,
),
)
but this feels like a square peg in the round holeechoing-dinner-19531
01/19/2024, 9:03 AMfreezing-vase-18205
01/19/2024, 9:23 AMc = local.Command(args)
I look for a way to return the same for a task that doesn’t use the resource.
Imagine if I generate a YAML file using outputs and native language libs, so I don’t interact with pulumi-managed resource, then the question is how to make the next step (which is a local.command) to depend on that function completion?freezing-vase-18205
01/19/2024, 9:28 AMdef render_credentials(subnet_id: pulumi.Output):
def render_creds(subnet_id):
env = Environment(loader=FileSystemLoader("."))
template = env.get_template("infra_modules/credentials_dev.yaml.j2")
with open("credentials.yaml", "w") as f:
f.write(
template.render(
os.environ,
subnet_id=subnet_id,
)
)
return True
return subnet_id.apply(render_creds)
then, in order to make sure that my next steps will depend in this step I return an output
creds_done = kubeone_cluster.render_credentials(subnet_id=sub.id)
cluster = kubeone_cluster.deploy(depends_on=[yaml_done, creds_done])
But may be I am rubbing it the wrong wayechoing-dinner-19531
01/19/2024, 10:54 AMoutput.all([a, b]).apply(([a, b]) => a)
to make an output that depends on b but doesn't use it's value in any way.freezing-vase-18205
01/19/2024, 11:05 AMfreezing-vase-18205
06/16/2024, 9:26 AMoutput.all
function. Can someone clarify? Thanks!echoing-dinner-19531
06/16/2024, 12:43 PMall
method are the union of all the dependencies of the outputs passed into the all
method. So this tracks the dependencies for a and b. Then the apply statement doesn't change dependencies but takes only the value of a.freezing-vase-18205
06/18/2024, 12:08 PMechoing-dinner-19531
06/22/2024, 7:20 PMfreezing-vase-18205
06/24/2024, 12:14 PM